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