From d10a14d5af5022d2cbadd786887dde45c1fc4ab2 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 20 Nov 2026 21:47:32 -0800 Subject: [PATCH] Fix forward of b0e351ffbc: the multisample test checks contents its fixture fixes per sample each_sample_of_a_multisampled_target_holds_its_own_invocation read samples (2, 3, 2, 3) on lavapipe through the runtime too (focus m3-max-61748), the same words as the executor's own context. Its premise was wrong, not either context: sample_rate_mask_in reads [[sample_mask]] beside [[sample_id]], so the translator compiles it without sample shading, its body looped over the coverage's set bits, each written sample taking the last pass's outputs (PrecisionNote::LoopedSampleOutputs, docs/API.md). Vulkan lets the device run more than one invocation per pixel there: lavapipe ran two, over samples {0, 2} and {1, 3}, whose last passes are samples 2 and 3. Both contexts gave what the note allows; neither gives Metal's per-sample index, which is the note's recorded difference. The test is now each_sample_of_a_multisampled_target_keeps_its_own_contents: one pixel of 4 samples authored apart (sample s holds 10+s, 20+s, 30+s, 40+s as RGBA32Float), drawn by sample_rate_mask_out, whose sample mask 0x5 writes (1, 0, 1, 1) to samples 0 and 2. Samples 1 and 3 keep their own authored words, so the per-sample fill and the per-sample read-back are both checked, through the runtime on Linux and on the executor's own context, against one expected byte string. The fixture's output carries no precision note. Verified: cargo fmt. The focused run follows as a potluck job. --- .../src/candidate/tests/engine_render.rs | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs b/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs index e23ab3f0b..879fcfa54 100644 --- a/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs +++ b/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs @@ -460,50 +460,39 @@ fn an_observed_vertex_case_draws_into_its_generated_observer() { } } -/// A pass of 4 samples: `sample_rate_mask_in` runs once per sample (`sample_id`) and writes its -/// coverage beside its sample index, so sample `s` of the one pixel holds `(mask, s, 0, 1)` over -/// the authored contents, each sample's own. Through the runtime the target is filled and read -/// back sample by sample (`platform::runtime_multisample`) and holds the same words. +/// A pass of 4 samples whose one pixel's samples are authored apart, sample `s` holding +/// `(10 + s, 20 + s, 30 + s, 40 + s)`: `sample_rate_mask_out` writes `(1, 0, 1, 1)` under the +/// sample mask `0x5`, so samples 0 and 2 take its color and samples 1 and 3 keep their own +/// authored contents. Through the runtime the target is filled and read back sample by sample +/// (`platform::runtime_multisample`) and holds the same words. #[cfg(any(target_os = "linux", target_os = "macos"))] #[test] -fn each_sample_of_a_multisampled_target_holds_its_own_invocation() { +fn each_sample_of_a_multisampled_target_keeps_its_own_contents() { let fragment = public("engine/sample_rate.ll"); let mut authored = crate::companion::tests::case( Stage::Fragment, - "sample_rate_mask_in", - TextureFormat::Rgba32Uint, + "sample_rate_mask_out", + TextureFormat::Rgba32Float, ); authored.raster_sample_count = Some(4); - authored.render_targets[0].initial_bytes_b64 = b64(&[0xab; 4 * 16]); + let sample = |s: f32| [10.0 + s, 20.0 + s, 30.0 + s, 40.0 + s]; + let authored_samples: Vec = (0..4u8).flat_map(|s| sample(f32::from(s))).collect(); + authored.render_targets[0].initial_bytes_b64 = b64(&floats(&authored_samples)); authored.output = OutputSelection::RenderTarget { index: 0, origin: [0, 0], dimensions: [1, 1], }; let (case, companion) = with_companion(&authored, &fragment); - // Each sample's `(sample, 0, 1)`, after its coverage word. - let indices = |output: &[u8]| -> Vec<[u32; 3]> { - let words: Vec = output - .as_chunks::<4>() - .0 - .iter() - .map(|word| u32::from_le_bytes(*word)) - .collect(); - words - .as_chunks::<4>() - .0 - .iter() - .map(|sample| [sample[1], sample[2], sample[3]]) - .collect() - }; - let expected = [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1]]; + let written = [1.0, 0.0, 1.0, 1.0]; + let expected = floats(&[written, sample(1.0), written, sample(3.0)].concat()); #[cfg(target_os = "linux")] { assert!(crate::candidate::engine::runs_render_through_runtime( &authored, &case )); let through = run_on_runtime(&case, &fragment, Some(&companion)).unwrap(); - assert_eq!(indices(&through.output), expected, "through the runtime"); + assert_eq!(through.output, expected, "through the runtime"); } let run = run( &case, @@ -513,11 +502,7 @@ fn each_sample_of_a_multisampled_target_holds_its_own_invocation() { }, ) .unwrap(); - assert_eq!( - indices(&run.output), - expected, - "on the executor's own context" - ); + assert_eq!(run.output, expected, "on the executor's own context"); } /// A tessellation case drawn through the render executor's patch path: the factor buffer bound