From be59d462401ca965303093975f0cf9667b256e44 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 9 Nov 2026 07:12:23 -0800 Subject: [PATCH] word_samples_msaa: read the samples in a threadgroup of whole subgroups on every device What: the sample reads (wsm_read_f, wsm_read_u) are dispatched in one threadgroup of 128 threads (GROUP), whole simdgroups and whole subgroups of every size a kernel's simdgroups run on (32, or 64 or 128 for wider subgroups split into simdgroups), instead of the row rounded up to thread_execution_width (32). Why: on the RX 550 (RADV POLARIS12, 64-wide subgroups) the lane failed with "announced past [...]: [EmulatedSimdgroups]": "a dispatch of kernel `wsm_read_u`: its threadgroups of [32, 1, 1] threads are not whole subgroups of the size the kernel's simdgroups run on". The kernels have no simdgroup operation or barrier in their source, but their translations carry one OpControlBarrier and LocalSizeConstraint { multiple: 64 } there (printed by a probe): the lockstep pass orders each thread's stores in its loop over the samples, whose index the analysis does not prove apart between threads, so a 32-thread group is a partial subgroup and runs on the emulated-simdgroups variant, announced. The lane's comment already meant to avoid that route; whole simdgroups are not whole subgroups on a 64-wide device. Ran on the RX 550 (um790, MESA_VK_DEVICE_SELECT=1002:699f!) at this change on 3d5ed3b021: runtime_lane::word_samples_msaa passed (announced: ShaderResolve, WordResolve, DeviceRoundedResolve and the allowed kinds; no EmulatedSimdgroups), with runtime_lane::shader_stencil's four tests in the same run. (cherry picked from commit b9e255758cedde5b27b079c75938000b446c172f) --- .../src/runtime_lane/word_samples_msaa.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/word_samples_msaa.rs b/crates/metal2vulkan-validation/src/runtime_lane/word_samples_msaa.rs index 7165329f4..bf6905846 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/word_samples_msaa.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/word_samples_msaa.rs @@ -70,6 +70,14 @@ pub(super) const WORD_RESOLVE: [Degradation; 1] = [Degradation::WordResolve]; /// The target's width (the probe's), and the pixels the lane draws: its first row. const WIDTH: u64 = 16; +/// The threads of the sample reads' threadgroup: whole simdgroups, and whole subgroups of every +/// size a kernel's simdgroups run on (32, or the 64 or 128 of wider subgroups split into +/// simdgroups). A threadgroup of fewer is a partial subgroup on some device (the row's 16 threads +/// on every one, 32 on the RX 550's 64-wide subgroups), which a kernel with simdgroup semantics +/// runs on its emulated-simdgroups variant (announced), a route this lane does not read: the +/// sample reads have them, from the simdgroup barriers that order each thread's stores in its +/// loop over the samples for Metal's lockstep. +const GROUP: u64 = 128; const PIXELS: usize = 16; /// Metal's answers for one format and sample count, over the probe's first [`PIXELS`] pixels: @@ -782,16 +790,9 @@ impl Lane { encoder.set_compute_pipeline_state(&state).unwrap(); encoder.set_buffer(Some(&out), 0, 0).unwrap(); encoder.set_texture(Some(t), 0).unwrap(); - // One threadgroup of whole simdgroups, the threads past the row returning: a threadgroup - // of the row's 16 threads is a partial simdgroup, which a device whose simdgroups are its - // subgroups runs on the kernel's emulated-simdgroups variant (announced), a route this - // lane does not read. - let width = u64::from(state.thread_execution_width()); + // One threadgroup of whole subgroups ([`GROUP`]), the threads past the row returning. encoder - .dispatch_threadgroups( - Size::new(1, 1, 1), - Size::new(WIDTH.div_ceil(width) * width, 1, 1), - ) + .dispatch_threadgroups(Size::new(1, 1, 1), Size::new(GROUP, 1, 1)) .unwrap(); encoder.end_encoding().unwrap(); command_buffer.commit().unwrap();