From fc79fdd4e9906a138b6695ff404bfb305931e8fa Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 5 Nov 2026 02:05:35 -0800 Subject: [PATCH] Announce every NVIDIA RTX 5080 Laptop clear and plain fill off a whole code: its clears take either nearest code runtime_lane::color_fills::plain_color_fills_are_the_device_s_clear (vkCmdClearColorImage of 762 colours into each of 70 formats) on the RTX 5080 Laptop GPU at 0b556ddfd6: 352 fills stored 382 normalized channels a code from Metal's, each one of the two codes nearest the scaled value, unannounced where the value was not near a midpoint. Vulkan allows it ("returns one of the two unsigned binary integer values with exactly b bits which are closest to the floating-point value r. Implementations should round to nearest"). The 8- and 16-bit unorm and snorm channels went toward zero (R16Unorm's 0.001, 65.535 codes, stored 65; R8Snorm's -0.5 stored -63), packed and 10-bit channels and an sRGB format's alpha at times to the code above the nearest. An under-note. What: - DriverFact::ColorClearTakesEitherCode, on the RTX 5080 Laptop GPU (NVIDIA), with its measurement in its doc. - clear_value::rounds_apart takes the fact: on such a driver a normalized channel's clear is in question wherever its scaled value is off a whole code, not only near a midpoint; the clear and the plain colour fill (blit_fill, fill_value, render_pass) announce device-color-conversion then. - docs/API.md's catalogue entry for the clear conversion names the fact. - Tests: driver_facts' table test; a fill_value unit test of the rule on the measured cases with and without the fact; api_signatures for the new variant. Verified: in the lane proof runs on the 5080 and the M3 (counts in the series' last commit). The M3's and lavapipe's facts are unchanged, so their notices are. (cherry picked from commit f2da9346bb51ed034f0d5f8bf076c8d55c57f277) --- crates/metal2vulkan-runtime/src/blit_fill.rs | 9 ++- .../metal2vulkan-runtime/src/clear_value.rs | 65 +++++++++++++++---- crates/metal2vulkan-runtime/src/fill_value.rs | 12 ++-- .../metal2vulkan-runtime/src/render_pass.rs | 8 ++- .../src/tests/fill_value.rs | 26 +++++++- .../src/tests/heap_tiled.rs | 2 +- .../metal2vulkan/src/device/driver_facts.rs | 21 ++++++ .../src/device/tests/driver_facts.rs | 13 +++- crates/metal2vulkan/tests/api_signatures.tsv | 2 + docs/API.md | 14 ++-- 10 files changed, 142 insertions(+), 30 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/blit_fill.rs b/crates/metal2vulkan-runtime/src/blit_fill.rs index 9705edd6b..5ed39572e 100644 --- a/crates/metal2vulkan-runtime/src/blit_fill.rs +++ b/crates/metal2vulkan-runtime/src/blit_fill.rs @@ -553,13 +553,16 @@ fn placement( /// texel than Metal's fill packs ([`device_apart`], `device-color-conversion`), and where it /// converts a half or small-float NaN as the device likes ([`device_nan`], `device-nan-encoding`). fn degrade_fill_conversion(device: &Device, pf: PixelFormat, color: [f64; 4]) { - if device_apart(pf, color) { + let either = (device.properties().driver_facts) + .contains(&metal2vulkan::device::DriverFact::ColorClearTakesEitherCode); + if device_apart(pf, color, either) { device.degrade(Degradation::DeviceColorConversion, || { ( format!("a color fill of a {pf:?} texture to {color:?}"), "the device clears the region by its own conversion of the color, which Vulkan \ - asks it to round to nearest, leaving a tie, an sRGB encode and a float's \ - rounding to it, where Metal's fill packs it by rules of its own (a tie rounded \ + lets store either of the two codes nearest a normalized channel's value (it asks \ + for the nearest) and which takes an sRGB encode and a float's rounding its own \ + way, where Metal's fill packs it by rules of its own (a tie rounded \ half up, an sRGB channel the code whose decoded value is nearest): a channel can \ store a code next to Metal's" .to_owned(), diff --git a/crates/metal2vulkan-runtime/src/clear_value.rs b/crates/metal2vulkan-runtime/src/clear_value.rs index c89f82092..cf10955c1 100644 --- a/crates/metal2vulkan-runtime/src/clear_value.rs +++ b/crates/metal2vulkan-runtime/src/clear_value.rs @@ -20,11 +20,14 @@ //! **The device converts a float clear.** A normalized, sRGB, packed 16-bit, half, float or small //! float channel's clear value is the clear color as a `float` ([`color`]), which the device //! converts to the format by its own rules, as a depth's is ([`depth`]). Vulkan clamps a -//! normalized value and asks the device to round it to nearest, and leaves a float format's +//! normalized value and lets the device store either of the two codes nearest it, asking it to +//! round to nearest ("Implementations should round to nearest"), and leaves a float format's //! rounding and an sRGB encode's precision to the device. So the device's texel can stand a code //! from Metal's where the rounding is in question ([`rounds_apart`], announced //! `device-color-conversion`): a normalized channel's value scaled within [`TIE`] of a midpoint //! between two codes (a packed 16-bit channel's within the error of Metal's step through `half`), +//! or anywhere off a whole code on a driver measured to take either code +//! (`DriverFact::ColorClearTakesEitherCode`), //! an sRGB channel's value inside `(0, 1)`, a half or small float's value it does not hold //! exactly, and a shared exponent's texel it does not; and a `Depth16Unorm` depth scaled at or //! within [`TIE`] of a midpoint or above it, which Metal's clear truncates and a device rounding @@ -282,10 +285,12 @@ fn near_tie(r: f64, margin: f64) -> bool { /// Whether the device's conversion of [`color`]'s clear value of `color` for an attachment of /// `pf` may store another texel than Metal's clear (the module docs): a channel whose rounding is -/// in question. False for a clear the device converts nothing of (an integer, extended-range or -/// YCbCr format's, or a format with no clear rule), and for a NaN, whose half or small float the -/// device converts as it likes (`nan_clear::degrade_nan_clears`). -pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4]) -> bool { +/// in question, a normalized one's anywhere off a whole code where the device takes either nearest +/// code (`either`, `DriverFact::ColorClearTakesEitherCode`). False for a clear the device converts +/// nothing of (an integer, extended-range or YCbCr format's, or a format with no clear rule), and +/// for a NaN, whose half or small float the device converts as it likes +/// (`nan_clear::degrade_nan_clears`). +pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bool { if ExtendedRange::of(pf).is_some() || ycbcr_renders(pf) { return false; } @@ -294,6 +299,9 @@ pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4]) -> bool { }; let values: [f32; 4] = std::array::from_fn(|i| native(channels[i], color[i])); let scaled = |v: f32, lo: f32, max: u64| f64::from(v.clamp(lo, 1.0)) * max as f64; + // In question near a midpoint, or anywhere off a whole code where the device takes either + // nearest code. + let apart = |r: f64, margin: f64| near_tie(r, margin) || (either && r != r.round()); channels .iter() .zip(values) @@ -303,14 +311,14 @@ pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4]) -> bool { | Channel::Uint(_) | Channel::Sint(_) | Channel::Float => false, - Channel::Unorm(bits) => near_tie(scaled(v, 0.0, (1 << bits) - 1), TIE), + Channel::Unorm(bits) => apart(scaled(v, 0.0, (1 << bits) - 1), TIE), // Metal steps through `half`, which moves the scaled value by up to its code range // times 2^-11. Channel::HalfUnorm(bits) => { let max = (1u64 << bits) - 1; - near_tie(scaled(v, 0.0, max), TIE + max as f64 / 2048.0) + apart(scaled(v, 0.0, max), TIE + max as f64 / 2048.0) } - Channel::Snorm(bits) => near_tie(scaled(v, -1.0, (1 << (bits - 1)) - 1), TIE), + Channel::Snorm(bits) => apart(scaled(v, -1.0, (1 << (bits - 1)) - 1), TIE), Channel::Srgb => v > 0.0 && v < 1.0, Channel::Half => !v.is_nan() && f16_to_f32(f32_to_f16(v)) != v, Channel::Ufloat(mantissa) => { @@ -1129,6 +1137,37 @@ pub(crate) mod tests { /// A clear whose rounding is in question is the one announced: a normalized value at a tie, an /// sRGB value inside its range, a value a half, small float or shared exponent does not hold; + /// On a driver that takes either code nearest a normalized channel's scaled value + /// (`DriverFact::ColorClearTakesEitherCode`) a clear is in question wherever such a channel's + /// scaled value is off a whole code, as the RTX 5080 Laptop GPU's clears stored (`R16Unorm`'s + /// 0.001 is 65.535 codes, which it stored as 65, Metal 66), a scaled `float` a hair off a + /// whole code included (it may go either way); elsewhere only near a midpoint. A whole code, + /// and a channel of another kind, is in question as before on both. + #[test] + fn a_driver_taking_either_code_has_every_clear_off_a_code_in_question() { + let off = [ + (P::R16Unorm, [0.001, 0.0, 0.0, 0.0]), + (P::RGBA8Unorm, [0.25, 0.0, 0.0, 1.0]), + (P::RG8Unorm, [0.0, 0.904, 0.0, 0.0]), + (P::R8Snorm, [-0.3, 0.0, 0.0, 0.0]), + (P::B5G6R5Unorm, [0.7529, 0.0, 0.0, 0.0]), + ]; + for (pf, c) in off { + assert!(rounds_apart(pf, c, true), "{pf:?} {c:?}"); + assert!(!rounds_apart(pf, c, false), "{pf:?} {c:?}"); + } + let whole = [ + (P::RGBA8Unorm, [0.0, 1.0, 0.0, 1.0]), + (P::R8Snorm, [-1.0, 0.0, 0.0, 0.0]), + (P::RGBA8Uint, [3.0, 0.0, 0.0, 1.0]), + (P::R32Float, [0.1, 0.0, 0.0, 0.0]), + ]; + for (pf, c) in whole { + assert!(!rounds_apart(pf, c, true), "{pf:?} {c:?}"); + } + assert!(rounds_apart(P::RGBA8Unorm, [0.5, 0.0, 0.0, 1.0], true)); + } + /// not a code, a value past the range, a value the format holds, a 32-bit float or an integer. #[test] fn a_clear_whose_rounding_is_in_question_is_the_one_announced() { @@ -1147,7 +1186,7 @@ pub(crate) mod tests { (P::B5G6R5Unorm, [15.5 / 31.0, 0.0, 0.0, 0.0]), ]; for (pf, c) in apart { - assert!(rounds_apart(pf, c), "{pf:?} {c:?}"); + assert!(rounds_apart(pf, c, false), "{pf:?} {c:?}"); } let held = [ (P::RGBA8Unorm, [0.0, 1.0, 0.25, 0.75]), @@ -1169,7 +1208,7 @@ pub(crate) mod tests { (P::BGRA10XR, [0.1, 0.2, 0.3, 0.4]), ]; for (pf, c) in held { - assert!(!rounds_apart(pf, c), "{pf:?} {c:?}"); + assert!(!rounds_apart(pf, c, false), "{pf:?} {c:?}"); } } @@ -1197,7 +1236,7 @@ pub(crate) mod tests { for (i, &channel) in channels.iter().enumerate() { let mut one = [0.0; 4]; one[i] = c[i]; - if rounds_apart(pf, one) { + if rounds_apart(pf, one, false) { continue; } let v = native(channel, c[i]); @@ -1223,7 +1262,7 @@ pub(crate) mod tests { (P::RG11B10Float, [1.0, 0.5, 2.0, 0.0]), (P::RGB9E5Float, [1.0, 0.5, 2.0, 0.0]), ] { - assert!(!rounds_apart(pf, c), "{pf:?} {c:?}"); + assert!(!rounds_apart(pf, c, false), "{pf:?} {c:?}"); // SAFETY (union read): a float format's clear is `float32`. let value = unsafe { color(pf, c, ClearRoute::ThroughHalf).unwrap().float32 }; assert_eq!( @@ -1267,7 +1306,7 @@ pub(crate) mod tests { for (i, (x, b)) in f.iter().zip(bytes).enumerate() { let mut one = [0.0; 4]; one[(i + 3) % 4] = clear[(i + 3) % 4]; - if rounds_apart(P::ARGB8Unorm, one) { + if rounds_apart(P::ARGB8Unorm, one, false) { continue; } let code = (f64::from(x.clamp(0.0, 1.0)) * 255.0).round(); diff --git a/crates/metal2vulkan-runtime/src/fill_value.rs b/crates/metal2vulkan-runtime/src/fill_value.rs index c12a9ed40..e2690c39d 100644 --- a/crates/metal2vulkan-runtime/src/fill_value.rs +++ b/crates/metal2vulkan-runtime/src/fill_value.rs @@ -412,7 +412,8 @@ pub(super) fn device_converts(pf: PixelFormat) -> bool { } /// How near a midpoint between two codes a normalized channel's scaled color may lie where the -/// device, which Vulkan asks to round to nearest, may store the other code than Metal's fill: a +/// device, which Vulkan asks to round to nearest (it may store either nearest code), may store the +/// other code than Metal's fill: a /// tie (which the fill rounds up, half away from zero signed), or a value the device's arithmetic /// may take across one, as for a clear (`clear_value.rs`). const TIE: f64 = 1.0 / 1024.0; @@ -426,11 +427,13 @@ fn near_tie(r: f64, margin: f64) -> bool { /// another texel than Metal's fill packs (the module docs), announced `device-color-conversion`: /// a normalized channel's value scaled within [`TIE`] of a midpoint between two codes (widened by /// the fill's rounding of the product to `float`, and for a packed 16-bit format by a step -/// through `half`, which a device's clear may take as Metal's own clear does), an sRGB channel's +/// through `half`, which a device's clear may take as Metal's own clear does), or anywhere off a +/// whole code where the device takes either of the two nearest codes (`either`, +/// `DriverFact::ColorClearTakesEitherCode`), an sRGB channel's /// value inside `(0, 1)` (the fill takes the code whose decoded value is nearest, the device /// encodes), and a half's, small float's or shared exponent's value it does not hold exactly. A /// NaN is [`device_nan`]'s, or stores 0 on both. -pub(super) fn device_apart(pf: PixelFormat, color: [f64; 4]) -> bool { +pub(super) fn device_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bool { use Conversion as C; if pf == PixelFormat::RGB9E5Float { return !shared_exact(color); @@ -456,7 +459,8 @@ pub(super) fn device_apart(pf: PixelFormat, color: [f64; 4]) -> bool { true => TIE + m / 2048.0, false => TIE + m / f64::from(1u32 << 24), }; - near_tie(f64::from(v.clamp(low, 1.0)) * m, margin) + let r = f64::from(v.clamp(low, 1.0)) * m; + near_tie(r, margin) || (either && r != r.round()) } C::Srgb => v > 0.0 && v < 1.0, C::Half => { diff --git a/crates/metal2vulkan-runtime/src/render_pass.rs b/crates/metal2vulkan-runtime/src/render_pass.rs index 59b1f4c28..0bb302ba5 100644 --- a/crates/metal2vulkan-runtime/src/render_pass.rs +++ b/crates/metal2vulkan-runtime/src/render_pass.rs @@ -1631,9 +1631,11 @@ pub(super) fn layout( // The device converts a float clear its own way, which can stand a code from Metal's // where the rounding is in question (`clear_value::rounds_apart`), announced once the // render area is known (below); a word attachment's clear is Metal's codes. + let either = + (device.properties().driver_facts).contains(&DriverFact::ColorClearTakesEitherCode); let withheld_clear = (color.load_action == LoadAction::Clear && word.is_none() - && clear_value::rounds_apart(texture.pixel_format(), channels)) + && clear_value::rounds_apart(texture.pixel_format(), channels, either)) .then_some(channels); let straight_clear = ExtendedRange::of(texture.pixel_format()).and_then(|_| { clear_value::color(texture.pixel_format(), channels, ClearRoute::Straight) @@ -1970,7 +1972,9 @@ pub(super) fn degrade_clear_conversion(device: &Device, pf: PixelFormat, color: ( format!("a {pf:?} color attachment's clear to {color:?}"), "the device converts the clear color to the format's codes its own way, where \ - Vulkan leaves a tie, an sRGB encode and a float's rounding to it and Metal's clear \ + Vulkan lets it store either of the two codes nearest a normalized channel's value \ + (it asks for the nearest) and leaves an sRGB encode and a float's rounding to it, \ + and Metal's clear \ rounds each channel to nearest, a tie to even (a small float's and a shared \ exponent's mantissas truncated): a channel can store a code next to Metal's" .to_owned(), diff --git a/crates/metal2vulkan-runtime/src/tests/fill_value.rs b/crates/metal2vulkan-runtime/src/tests/fill_value.rs index 894d5e312..341ffbd51 100644 --- a/crates/metal2vulkan-runtime/src/tests/fill_value.rs +++ b/crates/metal2vulkan-runtime/src/tests/fill_value.rs @@ -316,6 +316,30 @@ fn every_measured_fill_texel_is_metal_s() { /// Unsigned normalized: a 4- or 8-bit channel rounds the exact product half up, any other width /// the product's `float` (the probe's thresholds). +/// On a driver that takes either code nearest a normalized channel's scaled value +/// (`DriverFact::ColorClearTakesEitherCode`), a plain fill is announced wherever such a channel's +/// scaled color is off a whole code, as the RTX 5080 Laptop GPU's clears stored; elsewhere only +/// near a midpoint. A whole code, and a float channel, is not announced on either. +#[test] +fn a_driver_taking_either_code_announces_every_fill_off_a_code() { + for (pf, color) in [ + (P::R16Unorm, [0.001, 0.0, 0.0, 0.0]), + (P::RG8Unorm, [0.0, 0.904, 0.0, 0.0]), + (P::R8Snorm, [0.649_799_282_935_052, 0.0, 0.0, 0.0]), + (P::B5G6R5Unorm, [0.0, 0.0, 0.752_941_176_470_588_2, 0.0]), + ] { + assert!(device_apart(pf, color, true), "{pf:?} {color:?}"); + assert!(!device_apart(pf, color, false), "{pf:?} {color:?}"); + } + for (pf, color) in [ + (P::RGBA8Unorm, [0.0, 1.0, 0.0, 1.0]), + (P::R8Snorm, [-1.0, 0.0, 0.0, 0.0]), + (P::R32Float, [0.1, 0.0, 0.0, 0.0]), + ] { + assert!(!device_apart(pf, color, true), "{pf:?} {color:?}"); + } +} + #[test] fn unorm_rounds_its_product_by_width() { // 0.5/65535's `float` times 65535 rounds to 0.5 in `float`, which rounds up; a clear stores 0. @@ -1076,7 +1100,7 @@ fn the_device_s_clear_is_announced_where_its_conversion_is_in_question() { (P::RGB9E5Float, [1e6, 0.0, 0.0, 0.0], true), ]; for (pf, color, want) in apart { - assert_eq!(device_apart(pf, color), want, "{pf:?} {color:?}"); + assert_eq!(device_apart(pf, color, false), want, "{pf:?} {color:?}"); } for (pf, want) in [ (P::RGBA16Float, true), diff --git a/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs b/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs index cb67b9d21..6061d5b8e 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs @@ -1339,7 +1339,7 @@ fn fresh_patterns_clear_colors_write_their_texels() { let bytes = crate::clear_value::tests::texel_bytes(pf, color); assert_eq!(bytes.as_deref(), Some(texel), "{pf:?}: {color:?}"); assert!( - !crate::clear_value::rounds_apart(pf, color), + !crate::clear_value::rounds_apart(pf, color, false), "{pf:?}: {color:?}" ); cleared += 1; diff --git a/crates/metal2vulkan/src/device/driver_facts.rs b/crates/metal2vulkan/src/device/driver_facts.rs index f4667da88..15ba3d44e 100644 --- a/crates/metal2vulkan/src/device/driver_facts.rs +++ b/crates/metal2vulkan/src/device/driver_facts.rs @@ -966,6 +966,23 @@ pub enum DriverFact { /// and small floats, shared exponents and NaNs among them) into a 1x1 attachment, its 11 /// depth and 4 stencil clears beside them: all 86 texels Metal's bytes, none a code apart. ColorClearIsMetals, + /// A colour clear's normalized channel (a render pass's `CLEAR` load operation's, and + /// `vkCmdClearColorImage`'s) stores either of the two codes nearest its scaled value, not + /// always the nearest, as Vulkan allows ("returns one of the two unsigned binary integer values + /// with exactly b bits which are closest to the floating-point value r. Implementations should + /// round to nearest", Conversion from Floating-Point to Normalized Fixed-Point). On a driver + /// with it the runtime announces `device-color-conversion` for a clear or a plain colour fill + /// of a normalized channel whose scaled value is not a whole code, not only for one near a + /// midpoint between two. Measured by + /// `runtime_lane::color_fills::plain_color_fills_are_the_device_s_clear` (`vkCmdClearColorImage` + /// of 762 colours into each of 70 formats) on the RTX 5080 Laptop GPU at 0b556ddfd6 + /// (2026-11-04): 352 fills stored 382 normalized channels a code from Metal's, each one of the + /// two codes nearest the scaled value. The 8- and 16-bit unorm and snorm channels went toward + /// zero (`R16Unorm`'s 0.001, 65.535 codes, stored 65; `R8Snorm`'s -0.5, -63.5, stored -63), the + /// packed 16-bit and 10-bit channels and an sRGB format's alpha at times to the code above the + /// nearest (`B5G6R5Unorm`'s 0.7529 red, 23.34 codes, stored 24). The load operation's tie of an + /// 8-bit channel (127.5 codes) stores 127 there (`runtime_lane::clear_reach`, `sample_fills`). + ColorClearTakesEitherCode, /// An optimal colour image may keep its compression state apart from the memory it is bound /// to, so a write through a buffer or another image over its bytes can leave its texels as /// they were. Vulkan leaves an optimal image's texels undefined after such a write; Metal's @@ -2069,6 +2086,10 @@ pub(crate) const MEASURED: &[Measured] = &[ device: Some(APPLE9), ..moltenvk_on_apple(DriverFact::ColorClearIsMetals) }, + nvidia_on( + DriverFact::ColorClearTakesEitherCode, + NVIDIA_RTX_5080_LAPTOP, + ), Measured { fact: DriverFact::CompressedImagesHideAliasedWrites, driver: DriverId::INTEL_OPEN_SOURCE_MESA, diff --git a/crates/metal2vulkan/src/device/tests/driver_facts.rs b/crates/metal2vulkan/src/device/tests/driver_facts.rs index 9cedce5b3..e41227091 100644 --- a/crates/metal2vulkan/src/device/tests/driver_facts.rs +++ b/crates/metal2vulkan/src/device/tests/driver_facts.rs @@ -384,6 +384,7 @@ const FRAGDEPTH: DriverFact = DriverFact::FragmentDepthStoresUnchanged; const APART: DriverFact = DriverFact::DepthStencilImagesLieApart; const AVERAGE: DriverFact = DriverFact::ColorResolveAverageIsMetals; const CLEAR: DriverFact = DriverFact::ColorClearIsMetals; +const EITHER_CODE: DriverFact = DriverFact::ColorClearTakesEitherCode; const HIDE: DriverFact = DriverFact::CompressedImagesHideAliasedWrites; const HOST: DriverFact = DriverFact::HostTransferImagesKeepTheirBytes; const OPTIMIZED: DriverFact = DriverFact::DepthStencilImagesStayGpuOptimized; @@ -562,7 +563,17 @@ fn the_committed_profiles_drivers_have_their_facts() { ( "nvidia-rtx5080-laptop", vec![ - ZERO, DENORMALS, FETCH, SPLIT, PLANES, BC6H, BC7, ROWS, STALL, STALL_1024, + ZERO, + DENORMALS, + EITHER_CODE, + FETCH, + SPLIT, + PLANES, + BC6H, + BC7, + ROWS, + STALL, + STALL_1024, ], ), ] diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 58df28074..f77b15055 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -11390,6 +11390,7 @@ variant metal2vulkan-runtime::DriverFact::BlendlessColorAttachmentsWarn Blendles variant metal2vulkan-runtime::DriverFact::ChannelBlockDecodeIsMetals ChannelBlockDecodeIsMetals variant metal2vulkan-runtime::DriverFact::ColorBlockDecodeIsMetals ColorBlockDecodeIsMetals variant metal2vulkan-runtime::DriverFact::ColorClearIsMetals ColorClearIsMetals +variant metal2vulkan-runtime::DriverFact::ColorClearTakesEitherCode ColorClearTakesEitherCode variant metal2vulkan-runtime::DriverFact::ColorImagesLieAsMetalHeapTextures ColorImagesLieAsMetalHeapTextures variant metal2vulkan-runtime::DriverFact::ColorResolveAverageIsMetals ColorResolveAverageIsMetals variant metal2vulkan-runtime::DriverFact::CompressedImagesHideAliasedWrites CompressedImagesHideAliasedWrites @@ -12641,6 +12642,7 @@ variant metal2vulkan::device::DriverFact::BlendlessColorAttachmentsWarn Blendles variant metal2vulkan::device::DriverFact::ChannelBlockDecodeIsMetals ChannelBlockDecodeIsMetals variant metal2vulkan::device::DriverFact::ColorBlockDecodeIsMetals ColorBlockDecodeIsMetals variant metal2vulkan::device::DriverFact::ColorClearIsMetals ColorClearIsMetals +variant metal2vulkan::device::DriverFact::ColorClearTakesEitherCode ColorClearTakesEitherCode variant metal2vulkan::device::DriverFact::ColorImagesLieAsMetalHeapTextures ColorImagesLieAsMetalHeapTextures variant metal2vulkan::device::DriverFact::ColorResolveAverageIsMetals ColorResolveAverageIsMetals variant metal2vulkan::device::DriverFact::CompressedImagesHideAliasedWrites CompressedImagesHideAliasedWrites diff --git a/docs/API.md b/docs/API.md index 260e14e9e..80ae6cbbf 100644 --- a/docs/API.md +++ b/docs/API.md @@ -3321,17 +3321,21 @@ bound. stored up to 11 codes from Metal's). Also a render pass's clear of a normalized, sRGB, packed 16-bit, half or small-float color attachment to a color whose conversion is in question - (a normalized channel within 1/1024 of a midpoint between two codes, an sRGB channel inside its - range, a value the format does not hold exactly): the device converts the clear color, where - Metal's clear rounds each channel to nearest, a tie to even, and truncates a small float's and a - shared exponent's mantissas. Not for a clear by the load operation of an attachment the pass's + (a normalized channel within 1/1024 of a midpoint between two codes, or anywhere off a whole code + on a driver that takes either code nearest it, `DriverFact::ColorClearTakesEitherCode`: NVIDIA's + on the RTX 5080 Laptop GPU, whose 8- and 16-bit channels' clears went toward zero; an sRGB channel + inside its range, a value the format does not hold exactly): the device converts the clear color, + where Metal's clear rounds each channel to nearest, a tie to even, and truncates a small float's + and a shared exponent's mantissas. Vulkan lets the device store either of the two codes nearest a + normalized channel's scaled value, asking for the nearest. Not for a clear by the load operation of an attachment the pass's render area covers on a driver whose load operation clears as Metal's `Clear` load action does (`DriverFact::ColorClearIsMetals`: MoltenVK on the Apple9 GPUs under macOS 27, measured on the M3 Max); a clear made before the pass, of an attachment its first instance leaves out, is announced there too. Also a plain color fill (`BlitCommandEncoder::fill_texture_color` without a pixel format) of a texture of such a format the device renders, which the device's clear of the color writes, to a color whose conversion is in question against Metal's fill packing (a normalized - channel within 1/1024 of a midpoint between two codes, more for a packed 16-bit channel, an sRGB + channel within 1/1024 of a midpoint between two codes, more for a packed 16-bit channel, or + anywhere off a whole code on a driver with `DriverFact::ColorClearTakesEitherCode`; an sRGB channel inside its range, a value a half, small float or shared exponent does not hold exactly): Metal's fill rounds a tie half up and takes an sRGB channel's code whose decoded value is nearest.