From 7e0f98c09dfaaef3613932bbc5ae2d334db1e8e6 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 09:28:37 -0800 Subject: [PATCH] Runtime tests: the typed-atomic select test takes the device's answer for 64-bit buffer atomics every_device_loads_through_a_select_of_a_typed_atomic_s_slot_and_another made the ADDRESSED_AND_VIEWED state on every device, but its `ulong` add is a 64-bit buffer atomic, which Vulkan's shaderBufferInt64Atomics answers (a rule 2 query). KosmicKrisp on the M3 Max does not offer the feature, so the translator refuses the state there, Int64Atomics needing ShaderBufferInt64Atomics, and the test panicked in its state helper (pin T's Mac leg, job m3-max-84350: "Apple M3 Max: plain: refused: unsupported: Int64Atomics; needs AnyOf([[Feature(ShaderBufferInt64Atomics)]])", then "the translator made no pipeline of addressed_and_viewed"). The test now reads the feature from the translator's profile (what device creation enabled). Without it, it asserts the state's refusal, Error::Translation of Unsupported Int64Atomics needing AnyOf([[Feature(ShaderBufferInt64Atomics)]]), and runs nothing; with it, it runs today's value checks. The 64-bit add stays: a typed atomic (a u64 one, or a native f32 add, which needs a feature too) is what moves its slot to its device address, the shape under test. A third leg opens each device without shaderBufferInt64Atomics (without_int64_atomics), so every device, lavapipe in CI included, runs the refusal branch, and each device that has the feature runs the value checks in its own form and in the address form. The same assumption elsewhere: no other device test in the runtime, harness or conformance crates uses a 64-bit atomic (searched for `atomicrmw ... i64`, `air.atomic.*.i64`, `atomic_ulong` and `atomic` in their sources, and in the 58 engine and example fixtures their tests load). Verified: the observed red is pin T's Mac leg, job m3-max-84350 (KosmicKrisp 26.3.1 on the M3 Max), quoted above. Green on lavapipe (llvmpipe, LLVM 23.1.4, 256 bits), job m3-max-84503: the test passed, printing its own form and the address form reading both slots, and the leg without shaderBufferInt64Atomics "the state is refused, Int64Atomics". Green on the Iris Xe (RPL-P, ANV), job m3-max-84505: the same, its own form the bound form. The M3's proof comes from the next round's Mac leg. --- .../src/tests/translate.rs | 67 +++++++++++++++++-- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/translate.rs b/crates/metal2vulkan-runtime/src/tests/translate.rs index 006573de8..4b1e207e4 100644 --- a/crates/metal2vulkan-runtime/src/tests/translate.rs +++ b/crates/metal2vulkan-runtime/src/tests/translate.rs @@ -6079,12 +6079,28 @@ declare i32 @air.atomic.global.add.u.i32(ptr addrspace(1), i32, i32, i32, i1) } } + /// A device's description without `shaderBufferInt64Atomics`, as KosmicKrisp's on the M3 Max + /// is: the form of a device without 64-bit buffer atomics. + fn without_int64_atomics() -> DeviceOptions { + DeviceOptions { + described: Some(|mut d: DeviceDescription| { + d.features.remove(&VkFeature::ShaderBufferInt64Atomics); + d + }), + ..DeviceOptions::default() + } + } + /// [`ADDRESSED_AND_VIEWED`] in one threadgroup of 64 threads on every device, in the device's - /// own form and in the address form ([`address_form`]): `wide[0]` ends at the sum of the - /// threads' indices and `words[0]` at 64, each atomic exact; each thread other than 0 stored a - /// value of `words[0]` from after its own add, 1 to 64; thread 0 a low word of `wide[0]` no - /// larger than the sum; and no word past the last thread's changed. The select's load reads - /// inside both buffers, so a checked load there reads the slot's memory, never the zero range. + /// own form, in the address form ([`address_form`]) and without 64-bit buffer atomics + /// ([`without_int64_atomics`]): `wide[0]` ends at the sum of the threads' indices and + /// `words[0]` at 64, each atomic exact; each thread other than 0 stored a value of `words[0]` + /// from after its own add, 1 to 64; thread 0 a low word of `wide[0]` no larger than the sum; + /// and no word past the last thread's changed. The select's load reads inside both buffers, so + /// a checked load there reads the slot's memory, never the zero range. The `ulong` add is a + /// 64-bit buffer atomic, which Vulkan's `shaderBufferInt64Atomics` answers: a device whose + /// creation did not enable it refuses the state, `Int64Atomics` needing that feature, and runs + /// nothing. #[test] fn every_device_loads_through_a_select_of_a_typed_atomic_s_slot_and_another() { const SIZE: u32 = 64; @@ -6109,6 +6125,35 @@ declare i32 @air.atomic.global.add.u.i32(ptr addrspace(1), i32, i32, i32, i1) true => "bound form", false => "address form", }; + let on = (device.translator().profile().enabled().features) + .contains(&VkFeature::ShaderBufferInt64Atomics); + if !on { + use metal2vulkan::error::{Capability, Error as Translator, Feature, Needs}; + let made = device + .new_compute_pipeline_state(&descriptor, crate::tests::no_constexpr_samplers); + match made { + Err(Error::Translation { + error: Translator::Unsupported(u), + .. + }) => { + let needs = Needs::AnyOf(vec![vec![Capability::Feature( + VkFeature::ShaderBufferInt64Atomics, + )]]); + assert_eq!( + (&u.feature, &u.needs), + (&Feature::Int64Atomics, &needs), + "{name}: {u:?}" + ); + } + Err(error) => panic!("{name}: {error}"), + Ok(_) => panic!("{name}: a state made without shaderBufferInt64Atomics"), + } + println!( + "{name}: {form}: no shaderBufferInt64Atomics; the state is refused, \ + Int64Atomics" + ); + return; + } let queue = device.new_command_queue(4).expect("a queue"); let state = state(name, &device, &descriptor); let mut buffers = Buffers::new(&device, 1 << 16); @@ -6178,6 +6223,18 @@ declare i32 @air.atomic.global.add.u.i32(ptr addrspace(1), i32, i32, i32, i1) body(n, i, d) }, ); + each_device_with( + "compute_addressed_and_viewed_without_int64_atomics", + without_int64_atomics, + |n, i, d| { + let features = &d.translator().profile().enabled().features; + assert!( + !features.contains(&VkFeature::ShaderBufferInt64Atomics), + "{n}: without shaderBufferInt64Atomics" + ); + body(n, i, d) + }, + ); } /// A kernel of 64 threads that observes its threadgroups through two barriers in a loop of four