diff --git a/crates/spirv-std/src/arch.rs b/crates/spirv-std/src/arch.rs index df0d061c74..ead313c6ae 100644 --- a/crates/spirv-std/src/arch.rs +++ b/crates/spirv-std/src/arch.rs @@ -153,7 +153,7 @@ pub fn kill() -> ! { /// #[spirv_std_macros::gpu_only] #[doc(alias = "OpReadClockKHR")] -pub unsafe fn read_clock_khr() -> u64 { +pub fn read_clock_khr() -> u64 { unsafe { let mut result: u64; @@ -175,7 +175,7 @@ pub unsafe fn read_clock_khr() -> u64 { /// bits and the second component containing the 32 most significant bits.' #[spirv_std_macros::gpu_only] #[doc(alias = "OpReadClockKHR")] -pub unsafe fn read_clock_uvec2_khr, const SCOPE: u32>() -> V { +pub fn read_clock_uvec2_khr, const SCOPE: u32>() -> V { unsafe { let mut result = V::default(); diff --git a/crates/spirv-std/src/arch/barrier.rs b/crates/spirv-std/src/arch/barrier.rs index aa7df1746c..4d08e17cb2 100644 --- a/crates/spirv-std/src/arch/barrier.rs +++ b/crates/spirv-std/src/arch/barrier.rs @@ -33,7 +33,7 @@ use core::arch::asm; #[spirv_std_macros::gpu_only] #[doc(alias = "OpControlBarrier")] #[inline] -pub unsafe fn control_barrier< +pub fn control_barrier< const EXECUTION: u32, // Scope const MEMORY: u32, // Scope const SEMANTICS: u32, // Semantics @@ -70,7 +70,7 @@ pub unsafe fn control_barrier< #[spirv_std_macros::gpu_only] #[doc(alias = "OpMemoryBarrier")] #[inline] -pub unsafe fn memory_barrier< +pub fn memory_barrier< const MEMORY: u32, // Scope const SEMANTICS: u32, // Semantics >() { @@ -93,16 +93,14 @@ pub unsafe fn memory_barrier< /// From #[spirv_std_macros::gpu_only] #[inline] -pub unsafe fn workgroup_memory_barrier() { - unsafe { - memory_barrier::< - { crate::memory::Scope::Workgroup as u32 }, - { - crate::memory::Semantics::WORKGROUP_MEMORY.bits() - | crate::memory::Semantics::ACQUIRE_RELEASE.bits() - }, - >(); - } +pub fn workgroup_memory_barrier() { + memory_barrier::< + { crate::memory::Scope::Workgroup as u32 }, + { + crate::memory::Semantics::WORKGROUP_MEMORY.bits() + | crate::memory::Semantics::ACQUIRE_RELEASE.bits() + }, + >(); } /// Blocks execution of all threads in a group until all group shared accesses have been completed and all threads in the group have reached this call. @@ -112,17 +110,15 @@ pub unsafe fn workgroup_memory_barrier() { /// From #[spirv_std_macros::gpu_only] #[inline] -pub unsafe fn workgroup_memory_barrier_with_group_sync() { - unsafe { - control_barrier::< - { crate::memory::Scope::Workgroup as u32 }, - { crate::memory::Scope::Workgroup as u32 }, - { - crate::memory::Semantics::WORKGROUP_MEMORY.bits() - | crate::memory::Semantics::ACQUIRE_RELEASE.bits() - }, - >(); - } +pub fn workgroup_memory_barrier_with_group_sync() { + control_barrier::< + { crate::memory::Scope::Workgroup as u32 }, + { crate::memory::Scope::Workgroup as u32 }, + { + crate::memory::Semantics::WORKGROUP_MEMORY.bits() + | crate::memory::Semantics::ACQUIRE_RELEASE.bits() + }, + >(); } /// Blocks execution of all threads in a group until all device memory accesses have been completed. @@ -132,17 +128,15 @@ pub unsafe fn workgroup_memory_barrier_with_group_sync() { /// From #[spirv_std_macros::gpu_only] #[inline] -pub unsafe fn device_memory_barrier() { - unsafe { - memory_barrier::< - { crate::memory::Scope::Device as u32 }, - { - crate::memory::Semantics::IMAGE_MEMORY.bits() - | crate::memory::Semantics::UNIFORM_MEMORY.bits() - | crate::memory::Semantics::ACQUIRE_RELEASE.bits() - }, - >(); - } +pub fn device_memory_barrier() { + memory_barrier::< + { crate::memory::Scope::Device as u32 }, + { + crate::memory::Semantics::IMAGE_MEMORY.bits() + | crate::memory::Semantics::UNIFORM_MEMORY.bits() + | crate::memory::Semantics::ACQUIRE_RELEASE.bits() + }, + >(); } /// Blocks execution of all threads in a group until all device memory accesses have been completed and all threads in the group have reached this call. @@ -152,18 +146,16 @@ pub unsafe fn device_memory_barrier() { /// From #[spirv_std_macros::gpu_only] #[inline] -pub unsafe fn device_memory_barrier_with_group_sync() { - unsafe { - control_barrier::< - { crate::memory::Scope::Workgroup as u32 }, - { crate::memory::Scope::Device as u32 }, - { - crate::memory::Semantics::IMAGE_MEMORY.bits() - | crate::memory::Semantics::UNIFORM_MEMORY.bits() - | crate::memory::Semantics::ACQUIRE_RELEASE.bits() - }, - >(); - } +pub fn device_memory_barrier_with_group_sync() { + control_barrier::< + { crate::memory::Scope::Workgroup as u32 }, + { crate::memory::Scope::Device as u32 }, + { + crate::memory::Semantics::IMAGE_MEMORY.bits() + | crate::memory::Semantics::UNIFORM_MEMORY.bits() + | crate::memory::Semantics::ACQUIRE_RELEASE.bits() + }, + >(); } /// Blocks execution of all threads in a group until all memory accesses have been completed. @@ -173,18 +165,16 @@ pub unsafe fn device_memory_barrier_with_group_sync() { /// From #[spirv_std_macros::gpu_only] #[inline] -pub unsafe fn all_memory_barrier() { - unsafe { - memory_barrier::< - { crate::memory::Scope::Device as u32 }, - { - crate::memory::Semantics::WORKGROUP_MEMORY.bits() - | crate::memory::Semantics::IMAGE_MEMORY.bits() - | crate::memory::Semantics::UNIFORM_MEMORY.bits() - | crate::memory::Semantics::ACQUIRE_RELEASE.bits() - }, - >(); - } +pub fn all_memory_barrier() { + memory_barrier::< + { crate::memory::Scope::Device as u32 }, + { + crate::memory::Semantics::WORKGROUP_MEMORY.bits() + | crate::memory::Semantics::IMAGE_MEMORY.bits() + | crate::memory::Semantics::UNIFORM_MEMORY.bits() + | crate::memory::Semantics::ACQUIRE_RELEASE.bits() + }, + >(); } /// Blocks execution of all threads in a group until all memory accesses have been completed and all threads in the group have reached this call. @@ -194,17 +184,15 @@ pub unsafe fn all_memory_barrier() { /// From #[spirv_std_macros::gpu_only] #[inline] -pub unsafe fn all_memory_barrier_with_group_sync() { - unsafe { - control_barrier::< - { crate::memory::Scope::Workgroup as u32 }, - { crate::memory::Scope::Device as u32 }, - { - crate::memory::Semantics::WORKGROUP_MEMORY.bits() - | crate::memory::Semantics::IMAGE_MEMORY.bits() - | crate::memory::Semantics::UNIFORM_MEMORY.bits() - | crate::memory::Semantics::ACQUIRE_RELEASE.bits() - }, - >(); - } +pub fn all_memory_barrier_with_group_sync() { + control_barrier::< + { crate::memory::Scope::Workgroup as u32 }, + { crate::memory::Scope::Device as u32 }, + { + crate::memory::Semantics::WORKGROUP_MEMORY.bits() + | crate::memory::Semantics::IMAGE_MEMORY.bits() + | crate::memory::Semantics::UNIFORM_MEMORY.bits() + | crate::memory::Semantics::ACQUIRE_RELEASE.bits() + }, + >(); } diff --git a/crates/spirv-std/src/arch/demote_to_helper_invocation_ext.rs b/crates/spirv-std/src/arch/demote_to_helper_invocation_ext.rs index 8be3d572a1..8f7fdbaea1 100644 --- a/crates/spirv-std/src/arch/demote_to_helper_invocation_ext.rs +++ b/crates/spirv-std/src/arch/demote_to_helper_invocation_ext.rs @@ -19,7 +19,7 @@ use core::arch::asm; /// of [demote_to_helper_invocation]. #[spirv_std_macros::gpu_only] #[doc(alias = "OpDemoteToHelperInvocationEXT", alias = "discard")] -pub unsafe fn demote_to_helper_invocation() { +pub fn demote_to_helper_invocation() { unsafe { asm!("OpDemoteToHelperInvocationEXT"); } diff --git a/crates/spirv-std/src/arch/mesh_shading.rs b/crates/spirv-std/src/arch/mesh_shading.rs index 5a06197f07..c9fadf118a 100644 --- a/crates/spirv-std/src/arch/mesh_shading.rs +++ b/crates/spirv-std/src/arch/mesh_shading.rs @@ -17,6 +17,11 @@ use core::arch::asm; /// by this instruction. /// /// This instruction is only valid in the *`MeshEXT`* Execution Model. +/// +/// # Safety +/// * Must be called **exactly once** in mesh shaders +/// * Must be called in uniform control flow +/// * Must not write any output before this instruction in invoked #[spirv_std_macros::gpu_only] #[doc(alias = "OpSetMeshOutputsEXT")] #[inline] @@ -54,6 +59,10 @@ pub unsafe fn set_mesh_outputs_ext(vertex_count: u32, primitive_count: u32) { /// This instruction must be the last instruction in a block. /// /// This instruction is only valid in the *`TaskEXT`* Execution Model. +/// +/// # Safety +/// * Must be called **exactly once** in task shaders +/// * Must be called in uniform control flow #[spirv_std_macros::gpu_only] #[doc(alias = "OpEmitMeshTasksEXT")] #[inline] @@ -93,6 +102,10 @@ pub unsafe fn emit_mesh_tasks_ext(group_count_x: u32, group_count_y: u32, group_ /// This instruction must be the last instruction in a block. /// /// This instruction is only valid in the *`TaskEXT`* Execution Model. +/// +/// # Safety +/// * Must be called **exactly once** in task shaders +/// * Must be called in uniform control flow #[spirv_std_macros::gpu_only] #[doc(alias = "OpEmitMeshTasksEXT")] #[inline] diff --git a/crates/spirv-std/src/arch/subgroup.rs b/crates/spirv-std/src/arch/subgroup.rs index 0d53c85191..e9793db114 100644 --- a/crates/spirv-std/src/arch/subgroup.rs +++ b/crates/spirv-std/src/arch/subgroup.rs @@ -64,18 +64,16 @@ pub enum GroupOperation { #[doc(alias = "subgroupBarrier")] #[inline] pub fn subgroup_barrier() { - unsafe { - barrier::control_barrier::< - SUBGROUP, - SUBGROUP, - { - Semantics::ACQUIRE_RELEASE.bits() - | Semantics::UNIFORM_MEMORY.bits() - | Semantics::WORKGROUP_MEMORY.bits() - | Semantics::IMAGE_MEMORY.bits() - }, - >(); - } + barrier::control_barrier::< + SUBGROUP, + SUBGROUP, + { + Semantics::ACQUIRE_RELEASE.bits() + | Semantics::UNIFORM_MEMORY.bits() + | Semantics::WORKGROUP_MEMORY.bits() + | Semantics::IMAGE_MEMORY.bits() + }, + >(); } /// The function `subgroupMemoryBarrier()` enforces the ordering of all memory @@ -87,17 +85,15 @@ pub fn subgroup_barrier() { #[doc(alias = "subgroupMemoryBarrier")] #[inline] pub fn subgroup_memory_barrier() { - unsafe { - barrier::memory_barrier::< - SUBGROUP, - { - Semantics::ACQUIRE_RELEASE.bits() - | Semantics::UNIFORM_MEMORY.bits() - | Semantics::WORKGROUP_MEMORY.bits() - | Semantics::IMAGE_MEMORY.bits() - }, - >(); - } + barrier::memory_barrier::< + SUBGROUP, + { + Semantics::ACQUIRE_RELEASE.bits() + | Semantics::UNIFORM_MEMORY.bits() + | Semantics::WORKGROUP_MEMORY.bits() + | Semantics::IMAGE_MEMORY.bits() + }, + >(); } /// The function `subgroupMemoryBarrierBuffer()` enforces the ordering of all @@ -109,12 +105,10 @@ pub fn subgroup_memory_barrier() { #[doc(alias = "subgroupMemoryBarrierBuffer")] #[inline] pub fn subgroup_memory_barrier_buffer() { - unsafe { - barrier::memory_barrier::< - SUBGROUP, - { Semantics::ACQUIRE_RELEASE.bits() | Semantics::UNIFORM_MEMORY.bits() }, - >(); - } + barrier::memory_barrier::< + SUBGROUP, + { Semantics::ACQUIRE_RELEASE.bits() | Semantics::UNIFORM_MEMORY.bits() }, + >(); } /// The function `subgroupMemoryBarrierShared()` enforces the ordering of all @@ -128,12 +122,10 @@ pub fn subgroup_memory_barrier_buffer() { #[doc(alias = "subgroupMemoryBarrierShared")] #[inline] pub fn subgroup_memory_barrier_shared() { - unsafe { - barrier::memory_barrier::< - SUBGROUP, - { Semantics::ACQUIRE_RELEASE.bits() | Semantics::WORKGROUP_MEMORY.bits() }, - >(); - } + barrier::memory_barrier::< + SUBGROUP, + { Semantics::ACQUIRE_RELEASE.bits() | Semantics::WORKGROUP_MEMORY.bits() }, + >(); } /// The function `subgroupMemoryBarrierImage()` enforces the ordering of all @@ -145,12 +137,10 @@ pub fn subgroup_memory_barrier_shared() { #[doc(alias = "subgroupMemoryBarrierImage")] #[inline] pub fn subgroup_memory_barrier_image() { - unsafe { - barrier::memory_barrier::< - SUBGROUP, - { Semantics::ACQUIRE_RELEASE.bits() | Semantics::IMAGE_MEMORY.bits() }, - >(); - } + barrier::memory_barrier::< + SUBGROUP, + { Semantics::ACQUIRE_RELEASE.bits() | Semantics::IMAGE_MEMORY.bits() }, + >(); } /// Result is true only in the active invocation with the lowest id in the group, otherwise result is false. diff --git a/examples/shaders/reduce/src/lib.rs b/examples/shaders/reduce/src/lib.rs index 892e956bd2..a100ac5359 100644 --- a/examples/shaders/reduce/src/lib.rs +++ b/examples/shaders/reduce/src/lib.rs @@ -54,7 +54,7 @@ pub fn main( if subgroup_local_invocation_id == 0 { shared[subgroup_id as usize] = sum; } - unsafe { spirv_std::arch::workgroup_memory_barrier_with_group_sync() }; + spirv_std::arch::workgroup_memory_barrier_with_group_sync(); let mut sum = 0; if subgroup_id == 0 { if subgroup_local_invocation_id < num_subgroups { diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_ballot.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_ballot.stderr index d5171d95e9..ffc7660bb9 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_ballot.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_ballot.stderr @@ -1,9 +1,9 @@ %1 = OpFunction %2 None %3 %4 = OpFunctionParameter %2 %5 = OpLabel -OpLine %6 377 13 +OpLine %6 367 13 %7 = OpGroupNonUniformBallot %8 %9 %4 -OpLine %6 416 13 +OpLine %6 406 13 %10 = OpGroupNonUniformInverseBallot %2 %9 %7 OpNoLine OpReturnValue %10 diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_ballot_bit_count.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_ballot_bit_count.stderr index 0d224f07d0..0ecffc39c4 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_ballot_bit_count.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_ballot_bit_count.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpFunctionParameter %5 %6 = OpLabel -OpLine %7 511 0 +OpLine %7 501 0 %8 = OpGroupNonUniformBallotBitCount %2 %9 Reduce %4 OpNoLine OpReturnValue %8 diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_broadcast_first.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_broadcast_first.stderr index 9a99f698e6..9bb737c779 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_broadcast_first.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_broadcast_first.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpFunctionParameter %2 %5 = OpLabel -OpLine %6 344 13 +OpLine %6 334 13 %7 = OpGroupNonUniformBroadcastFirst %2 %8 %4 OpNoLine OpReturnValue %7 diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr index 6d9aa75c7a..821239dc33 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr @@ -1,27 +1,27 @@ error[E0080]: evaluation panicked: `ClusterSize` must be at least 1 - --> $SPIRV_STD_SRC/arch/subgroup.rs:839:1 + --> $SPIRV_STD_SRC/arch/subgroup.rs:829:1 | -839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" -840 | | An integer add group operation of all `value` operands contributed by active invocations in the group. -841 | | -842 | | Result Type must be a scalar or vector of integer type. +829 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" +830 | | An integer add group operation of all `value` operands contributed by active invocations in the group. +831 | | +832 | | Result Type must be a scalar or vector of integer type. ... | -855 | | * `ClusterSize` must not be greater than the size of the group -856 | | "); +845 | | * `ClusterSize` must not be greater than the size of the group +846 | | "); | |__^ evaluation of `spirv_std::arch::subgroup_clustered_i_add::<0, u32, u32>::{constant#0}` failed here | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $SPIRV_STD_SRC/arch/subgroup.rs:839:1 + --> $SPIRV_STD_SRC/arch/subgroup.rs:829:1 | -839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" -840 | | An integer add group operation of all `value` operands contributed by active invocations in the group. -841 | | -842 | | Result Type must be a scalar or vector of integer type. +829 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" +830 | | An integer add group operation of all `value` operands contributed by active invocations in the group. +831 | | +832 | | Result Type must be a scalar or vector of integer type. ... | -855 | | * `ClusterSize` must not be greater than the size of the group -856 | | "); +845 | | * `ClusterSize` must not be greater than the size of the group +846 | | "); | |__^ | = note: this note originates in the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr index ed0fbbf35f..8ef6ee7cb1 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr @@ -1,27 +1,27 @@ error[E0080]: evaluation panicked: `ClusterSize` must be a power of 2 - --> $SPIRV_STD_SRC/arch/subgroup.rs:839:1 + --> $SPIRV_STD_SRC/arch/subgroup.rs:829:1 | -839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" -840 | | An integer add group operation of all `value` operands contributed by active invocations in the group. -841 | | -842 | | Result Type must be a scalar or vector of integer type. +829 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" +830 | | An integer add group operation of all `value` operands contributed by active invocations in the group. +831 | | +832 | | Result Type must be a scalar or vector of integer type. ... | -855 | | * `ClusterSize` must not be greater than the size of the group -856 | | "); +845 | | * `ClusterSize` must not be greater than the size of the group +846 | | "); | |__^ evaluation of `spirv_std::arch::subgroup_clustered_i_add::<5, u32, u32>::{constant#0}` failed here | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $SPIRV_STD_SRC/arch/subgroup.rs:839:1 + --> $SPIRV_STD_SRC/arch/subgroup.rs:829:1 | -839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" -840 | | An integer add group operation of all `value` operands contributed by active invocations in the group. -841 | | -842 | | Result Type must be a scalar or vector of integer type. +829 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r" +830 | | An integer add group operation of all `value` operands contributed by active invocations in the group. +831 | | +832 | | Result Type must be a scalar or vector of integer type. ... | -855 | | * `ClusterSize` must not be greater than the size of the group -856 | | "); +845 | | * `ClusterSize` must not be greater than the size of the group +846 | | "); | |__^ | = note: this note originates in the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_elect.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_elect.stderr index 10c5624049..d18849b6f6 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_elect.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_elect.stderr @@ -1,6 +1,6 @@ %1 = OpFunction %2 None %3 %4 = OpLabel -OpLine %5 174 13 +OpLine %5 164 13 %6 = OpGroupNonUniformElect %2 %7 OpNoLine OpReturnValue %6 diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_clustered.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_clustered.stderr index d1d520364d..4d06f8f632 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_clustered.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_clustered.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpFunctionParameter %2 %5 = OpLabel -OpLine %6 839 0 +OpLine %6 829 0 %7 = OpGroupNonUniformIAdd %2 %8 ClusteredReduce %4 %9 OpNoLine OpReturnValue %7 diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_exclusive_scan.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_exclusive_scan.stderr index 00a742fc98..4890551e39 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_exclusive_scan.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_exclusive_scan.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpFunctionParameter %2 %5 = OpLabel -OpLine %6 826 0 +OpLine %6 816 0 %7 = OpGroupNonUniformIAdd %2 %8 ExclusiveScan %4 OpNoLine OpReturnValue %7 diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_inclusive_scan.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_inclusive_scan.stderr index 694495fb73..a41a806a40 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_inclusive_scan.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_inclusive_scan.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpFunctionParameter %2 %5 = OpLabel -OpLine %6 826 0 +OpLine %6 816 0 %7 = OpGroupNonUniformIAdd %2 %8 InclusiveScan %4 OpNoLine OpReturnValue %7 diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_reduce.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_reduce.stderr index 4776bf1903..2e8d77e479 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_i_add_reduce.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_i_add_reduce.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpFunctionParameter %2 %5 = OpLabel -OpLine %6 826 0 +OpLine %6 816 0 %7 = OpGroupNonUniformIAdd %2 %8 Reduce %4 OpNoLine OpReturnValue %7 diff --git a/tests/difftests/tests/arch/atomic_ops/atomic_ops-rust/src/lib.rs b/tests/difftests/tests/arch/atomic_ops/atomic_ops-rust/src/lib.rs index f80b63d41f..0a59047970 100644 --- a/tests/difftests/tests/arch/atomic_ops/atomic_ops-rust/src/lib.rs +++ b/tests/difftests/tests/arch/atomic_ops/atomic_ops-rust/src/lib.rs @@ -31,9 +31,7 @@ pub fn main_cs( // Thread 0 stores the final values after all operations complete if tid == 0 { // Use atomic loads to ensure we read the final values - unsafe { - spirv_std::arch::workgroup_memory_barrier_with_group_sync(); - } + spirv_std::arch::workgroup_memory_barrier_with_group_sync(); output[0] = counters[0]; // Should be initial + 32 output[1] = counters[1]; // Should be initial - 32 output[2] = counters[2]; // Should be min(initial, 0) diff --git a/tests/difftests/tests/arch/memory_barriers/memory_barriers-rust/src/lib.rs b/tests/difftests/tests/arch/memory_barriers/memory_barriers-rust/src/lib.rs index 63d75c3aba..4a3979bf03 100644 --- a/tests/difftests/tests/arch/memory_barriers/memory_barriers-rust/src/lib.rs +++ b/tests/difftests/tests/arch/memory_barriers/memory_barriers-rust/src/lib.rs @@ -19,9 +19,7 @@ pub fn main_cs( shared[lid] = input[tid]; // Workgroup barrier to ensure all threads have loaded their data - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); // Perform operations on shared memory let mut result = shared[lid]; @@ -53,17 +51,13 @@ pub fn main_cs( } // Another barrier before writing back - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); // Write result back to shared memory shared[lid] = result; // Memory barrier to ensure writes are visible - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); // Final read and output output[tid] = shared[lid]; diff --git a/tests/difftests/tests/arch/workgroup_memory/workgroup_memory-rust/src/shader.rs b/tests/difftests/tests/arch/workgroup_memory/workgroup_memory-rust/src/shader.rs index d743a1cea8..45bc392497 100644 --- a/tests/difftests/tests/arch/workgroup_memory/workgroup_memory-rust/src/shader.rs +++ b/tests/difftests/tests/arch/workgroup_memory/workgroup_memory-rust/src/shader.rs @@ -14,9 +14,7 @@ pub fn main_cs( shared[lid] = input[lid]; // Synchronize to ensure all threads have loaded - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); // Each thread sums its value with its neighbor (reduction step) if lid < 32 { @@ -24,49 +22,37 @@ pub fn main_cs( } // Synchronize again - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); if lid < 16 { shared[lid] += shared[lid + 16]; } - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); if lid < 8 { shared[lid] += shared[lid + 8]; } - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); if lid < 4 { shared[lid] += shared[lid + 4]; } - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); if lid < 2 { shared[lid] += shared[lid + 2]; } - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); if lid < 1 { shared[lid] += shared[lid + 1]; } - unsafe { - workgroup_memory_barrier_with_group_sync(); - } + workgroup_memory_barrier_with_group_sync(); // Write final result if lid == 0 {