diff --git a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16.rs b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16.rs index fb1fa7752..4de5e1553 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16.rs @@ -30,11 +30,14 @@ //! where it announces `device-nan-encoding` (the storage image's store of the blend's NaN, the //! device's where not measured to be Metal's: ANV stores `0xfe00`). On a device that fetches //! through the pixel interlock (RADV, ANV, NVIDIA, MoltenVK) the function computes Metal's blend -//! itself, exactly, announcing none of the three, which is asserted. Through input attachments -//! (lavapipe) the device blends; what it announces and how many channels are Metal's is printed. -//! Each draw prints a `FETCH-BLEND16` line (`FETCH-BLEND16-DIFFERENCE` under a difference) naming -//! its function and blend. A device that has neither form (RADV on the RX 550) skips them -//! (`fetches`). +//! itself, exactly, announcing none of the first two, which is asserted; it announces +//! `device-color-conversion` exactly where its output is a `float` and the device's profile does +//! not take `DriverDeviation::MetalHalfStorageWrites` ([`interlocked_notes`]): the storage image's +//! store converts the blend's `float` to `half` by the device's own rule there. Through input +//! attachments (lavapipe) the device blends; what it announces and how many channels are Metal's +//! is printed. Each draw prints a `FETCH-BLEND16` line (`FETCH-BLEND16-DIFFERENCE` under a +//! difference) naming its function and blend. A device that has neither form (RADV on the RX 550) +//! skips them (`fetches`). mod nans; mod narrow; @@ -45,6 +48,7 @@ use crate::runtime_lane::buffer_with; use crate::runtime_lane::degrade_notices::counts; use crate::runtime_lane::resolves::{lane_with, quiet, Lane}; use crate::runtime_lane::WAIT; +use metal2vulkan::error::DriverDeviation; use metal2vulkan::metal::{ BlendFactor, BlendOperation, ColorWriteMask, PixelFormat, PrimitiveType, TextureUsage, }; @@ -69,6 +73,22 @@ const NOTES: [PrecisionNote; 3] = [ PrecisionNote::DeviceColorConversion, ]; +/// The kinds of [`NOTES`] a draw through the pixel interlock announces, its output a `float` one +/// where `float`: none, but `device-color-conversion` for a `float` output on a device whose +/// profile does not take `DriverDeviation::MetalHalfStorageWrites`. The shader blends in the +/// output's type and the storage image's store converts a `float` result to `half`: Metal's +/// conversion (toward zero) where the profile takes the deviation, else the device's own, noted +/// (`lower/fragment/fetch.rs`). A `half` output's blend stores a `half`, which no conversion +/// changes. +fn interlocked_notes(lane: &Lane, float: bool) -> Vec { + let metal = (lane.device.compile_device().profile()) + .takes_driver_deviation(DriverDeviation::MetalHalfStorageWrites); + match float && !metal { + true => vec![Degradation::DeviceColorConversion], + false => Vec::new(), + } +} + /// A deterministic stream of 64-bit words (xorshift). struct Words(u64); @@ -338,15 +358,16 @@ fn filled(lane: &Lane, texels: &[u16]) -> Texture { } /// Each draw's channels are Metal's where it announces none of [`NOTES`], and on a device that -/// fetches through the pixel interlock it announces none (the module docs). +/// fetches through the pixel interlock it announces those [`interlocked_notes`] names alone (the +/// module docs). #[test] fn a_blended_sixteen_bit_float_fetch_stores_metals_blend() { stores_metals_blend(&FAST, &[OVER], "FETCH-BLEND16"); } /// Each blend constant's difference: each draw's channels are Metal's where it announces none of -/// [`NOTES`], and on a device that fetches through the pixel interlock it announces none (the -/// module docs). Before the shader computed a difference in Metal's form, the color channels' +/// [`NOTES`], and on a device that fetches through the pixel interlock it announces those +/// [`interlocked_notes`] names alone (the module docs). Before the shader computed a difference in Metal's form, the color channels' /// blend color difference took a rounded near-equivalent and every difference announced /// `half-output-fast-math-blend` there. #[test] @@ -479,7 +500,11 @@ fn stores_metals_blend(sweep: &Sweep, blends: &[Blending], tag: &str) { TEXELS, ); if interlock { - assert!(noted.is_empty(), "{what}: announced {noted:?}"); + let expected = interlocked_notes(&lane, case.float); + assert!( + noted.iter().copied().eq(&expected), + "{what}: announced {noted:?}, where the interlock announces {expected:?}" + ); } if noted.is_empty() { let shown = &wrong[..wrong.len().min(8)]; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/nans.rs b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/nans.rs index 2e13a2a4b..ac393f6e0 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/nans.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/nans.rs @@ -107,7 +107,8 @@ fn blends() -> Vec { /// Without fast math: each draw's channels are Metal's, every NaN `0x7e00` (any NaN where the draw /// announces `device-nan-encoding`), where it announces none of [`super::NOTES`], and on a device -/// that fetches through the pixel interlock it announces none of them (the module docs). +/// that fetches through the pixel interlock it announces those [`super::interlocked_notes`] names +/// alone (the module docs). #[test] fn a_safe_blended_nan_of_either_sign_or_payload_stores_metals_nan() { stores_metals_blend(&SAFE_NANS, &blends(), "FETCH-BLEND16-NAN"); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/narrow.rs b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/narrow.rs index fac89e93b..358d481d8 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/narrow.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/narrow.rs @@ -22,13 +22,15 @@ //! //! Where the draw announces none of [`super::NOTES`], every channel is Metal's. On a device that //! fetches through the pixel interlock (RADV, ANV, NVIDIA, MoltenVK) the function computes Metal's -//! blend itself, exactly, announcing none of them, which is asserted. Through input attachments +//! blend itself, exactly, announcing none of them but `device-color-conversion` for the `float2` +//! output where the device's store converts its `float` to `half` by its own rule +//! ([`interlocked_notes`]), which is asserted. Through input attachments //! (lavapipe) the device blends; what it announces and how many channels are Metal's is printed. //! Each draw prints a `FETCH-BLEND16-NARROW` line, naming its blend. A device that has neither //! form skips it (`fetches`). use super::super::{fetches, form, library, through_inputs}; -use super::{half_bits, half_value, Words, NOTES, SIDE, TEXELS}; +use super::{half_bits, half_value, interlocked_notes, Words, NOTES, SIDE, TEXELS}; use crate::runtime_lane::buffer_with; use crate::runtime_lane::degrade_notices::counts; use crate::runtime_lane::resolves::{lane_with, quiet, Lane}; @@ -147,7 +149,8 @@ fn unwritten(lane: &Lane) -> Texture { } /// Each draw's channels are Metal's where it announces none of [`NOTES`], and on a device that -/// fetches through the pixel interlock it announces none (the module docs). +/// fetches through the pixel interlock it announces those [`interlocked_notes`] names alone (the +/// module docs). #[test] fn a_two_lane_output_into_a_blended_two_channel_fetch_stores_metals_blend() { let kinds = NOTES.map(Degradation::from_precision_note); @@ -263,7 +266,11 @@ fn a_two_lane_output_into_a_blended_two_channel_fetch_stores_metals_blend() { TEXELS, ); if interlock { - assert!(noted.is_empty(), "{what}: announced {noted:?}"); + let expected = interlocked_notes(&lane, case.float); + assert!( + noted.iter().copied().eq(&expected), + "{what}: announced {noted:?}, where the interlock announces {expected:?}" + ); } if noted.is_empty() { let shown = &wrong[..wrong.len().min(8)]; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/zero.rs b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/zero.rs index abc406fcd..3b0f794be 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/zero.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/blend16/zero.rs @@ -26,7 +26,8 @@ //! to store the blend's NaN as Metal's in a storage image (ANV, which stores `0xfe00`; before the //! note, its draws stored that unannounced). On a device that fetches through the pixel interlock //! (RADV, ANV, NVIDIA, MoltenVK) the function computes Metal's blend itself, exactly, announcing -//! none of [`super::NOTES`], which is asserted. Through input attachments +//! of [`super::NOTES`] those [`super::interlocked_notes`] names alone (the store's conversion of a +//! `float` output), which is asserted. Through input attachments //! (lavapipe) the device blends, one and zero, added, too (announcing //! `half-output-precision`, which Metal's kept product by zero there needs); what it announces and //! how many channels are Metal's is printed. @@ -171,7 +172,8 @@ fn metal(case: Case, b: Blending, s: [f64; 4], d: [f64; 4]) -> [u16; 4] { } /// Each draw's channels are Metal's where it announces none of [`super::NOTES`], and on a device -/// that fetches through the pixel interlock it announces none (the module docs). +/// that fetches through the pixel interlock it announces those [`super::interlocked_notes`] names +/// alone (the module docs). #[test] fn a_safe_blended_fetch_keeps_a_zero_factors_product() { stores_metals_blend(&SAFE, &blends(), "FETCH-BLEND16-ZERO");