Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
move mod: move arch::barrier to barrier
  • Loading branch information
Firestar99 committed Apr 8, 2026
commit 0655455b80f5ee564831740652eacf1b4270c36f
4 changes: 0 additions & 4 deletions crates/spirv-std/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ use crate::{Scalar, SignedInteger, UnsignedInteger, Vector};
#[cfg(target_arch = "spirv")]
use core::arch::asm;

mod barrier;

pub use barrier::*;

/// Result is true if any component of `vector` is true, otherwise result is
/// false.
#[spirv_std_macros::gpu_only]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Intrinsics for barrier operations

#[cfg(target_arch = "spirv")]
use core::arch::asm;

Expand Down
1 change: 1 addition & 0 deletions crates/spirv-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub use macros::{debug_printf, debug_printfln};

pub mod arch;
pub mod atomic;
pub mod barrier;
pub mod byte_addressable_buffer;
pub mod debug_printf;
pub mod float;
Expand Down
2 changes: 1 addition & 1 deletion crates/spirv-std/src/subgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#[cfg(target_arch = "spirv")]
use crate::ScalarOrVectorTransform;
#[cfg(target_arch = "spirv")]
use crate::arch::{control_barrier, memory_barrier};
use crate::barrier::{control_barrier, memory_barrier};
#[cfg(target_arch = "spirv")]
use crate::memory::{Scope, Semantics};
use crate::{Float, Integer, ScalarComposite, ScalarOrVector, SignedInteger, UnsignedInteger};
Expand Down
2 changes: 1 addition & 1 deletion examples/shaders/reduce/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn main(
if subgroup_local_invocation_id == 0 {
shared[subgroup_id as usize] = sum;
}
spirv_std::arch::workgroup_memory_barrier_with_group_sync();
spirv_std::barrier::workgroup_memory_barrier_with_group_sync();
let mut sum = 0;
if subgroup_id == 0 {
if subgroup_local_invocation_id < num_subgroups {
Expand Down
3 changes: 2 additions & 1 deletion tests/compiletests/ui/arch/all_memory_barrier.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// build-pass
// compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model
// compile-flags: -C llvm-args=--disassemble-fn=all_memory_barrier::all_memory_barrier
// normalize-stderr-test "OpLine .*\n" -> ""

use spirv_std::spirv;

unsafe fn all_memory_barrier() {
spirv_std::arch::all_memory_barrier();
spirv_std::barrier::all_memory_barrier();
}

#[spirv(compute(threads(1, 1, 1)))]
Expand Down
1 change: 0 additions & 1 deletion tests/compiletests/ui/arch/all_memory_barrier.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%1 = OpFunction %2 None %3
%4 = OpLabel
OpLine %5 82 13
OpMemoryBarrier %6 %7
OpNoLine
OpReturn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// build-pass
// compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model
// compile-flags: -C llvm-args=--disassemble-fn=all_memory_barrier_with_group_sync::all_memory_barrier_with_group_sync
// normalize-stderr-test "OpLine .*\n" -> ""

use spirv_std::spirv;

unsafe fn all_memory_barrier_with_group_sync() {
spirv_std::arch::all_memory_barrier_with_group_sync();
spirv_std::barrier::all_memory_barrier_with_group_sync();
}

#[spirv(compute(threads(1, 1, 1)))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%1 = OpFunction %2 None %3
%4 = OpLabel
OpLine %5 47 13
OpControlBarrier %6 %7 %8
OpNoLine
OpReturn
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/arch/control_barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use spirv_std::spirv;
#[spirv(fragment)]
pub fn main() {
unsafe {
spirv_std::arch::control_barrier::<
spirv_std::barrier::control_barrier::<
{ Scope::Subgroup as u32 },
{ Scope::Subgroup as u32 },
{ Semantics::NONE.bits() },
Expand Down
3 changes: 2 additions & 1 deletion tests/compiletests/ui/arch/device_memory_barrier.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// build-pass
// compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model
// compile-flags: -C llvm-args=--disassemble-fn=device_memory_barrier::device_memory_barrier
// normalize-stderr-test "OpLine .*\n" -> ""

use spirv_std::spirv;

unsafe fn device_memory_barrier() {
spirv_std::arch::device_memory_barrier();
spirv_std::barrier::device_memory_barrier();
}

#[spirv(compute(threads(1, 1, 1)))]
Expand Down
1 change: 0 additions & 1 deletion tests/compiletests/ui/arch/device_memory_barrier.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%1 = OpFunction %2 None %3
%4 = OpLabel
OpLine %5 82 13
OpMemoryBarrier %6 %7
OpNoLine
OpReturn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// build-pass
// compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model
// compile-flags: -C llvm-args=--disassemble-fn=device_memory_barrier_with_group_sync::device_memory_barrier_with_group_sync
// normalize-stderr-test "OpLine .*\n" -> ""

use spirv_std::spirv;

unsafe fn device_memory_barrier_with_group_sync() {
spirv_std::arch::device_memory_barrier_with_group_sync();
spirv_std::barrier::device_memory_barrier_with_group_sync();
}

#[spirv(compute(threads(1, 1, 1)))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%1 = OpFunction %2 None %3
%4 = OpLabel
OpLine %5 47 13
OpControlBarrier %6 %7 %8
OpNoLine
OpReturn
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/arch/memory_barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use spirv_std::spirv;
#[spirv(fragment)]
pub fn main() {
unsafe {
spirv_std::arch::memory_barrier::<
spirv_std::barrier::memory_barrier::<
{ Scope::Subgroup as u32 },
{ Semantics::ACQUIRE_RELEASE.bits() | Semantics::UNIFORM_MEMORY.bits() },
>();
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/arch/shared/dce_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ignore-vulkan1.0
// ignore-vulkan1.1

use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
use spirv_std::barrier::workgroup_memory_barrier_with_group_sync;
use spirv_std::glam::*;
use spirv_std::spirv;

Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/arch/shared/reduction_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ignore-vulkan1.0

use core::ops::{Add, AddAssign, Deref, DerefMut};
use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
use spirv_std::barrier::workgroup_memory_barrier_with_group_sync;
use spirv_std::glam::*;
use spirv_std::spirv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ignore-vulkan1.0

use core::ops::{Add, AddAssign};
use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
use spirv_std::barrier::workgroup_memory_barrier_with_group_sync;
use spirv_std::glam::*;
use spirv_std::spirv;

Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/arch/shared/reduction_u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// ignore-spv1.2
// ignore-vulkan1.0

use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
use spirv_std::barrier::workgroup_memory_barrier_with_group_sync;
use spirv_std::glam::*;
use spirv_std::spirv;

Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/arch/shared/reduction_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// ignore-spv1.2
// ignore-vulkan1.0

use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
use spirv_std::barrier::workgroup_memory_barrier_with_group_sync;
use spirv_std::glam::*;
use spirv_std::spirv;

Expand Down
3 changes: 2 additions & 1 deletion tests/compiletests/ui/arch/workgroup_memory_barrier.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// build-pass
// compile-flags: -C llvm-args=--disassemble-fn=workgroup_memory_barrier::workgroup_memory_barrier
// normalize-stderr-test "OpLine .*\n" -> ""

use spirv_std::spirv;

unsafe fn workgroup_memory_barrier() {
spirv_std::arch::workgroup_memory_barrier();
spirv_std::barrier::workgroup_memory_barrier();
}

#[spirv(compute(threads(1, 1, 1)))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%1 = OpFunction %2 None %3
%4 = OpLabel
OpLine %5 82 13
OpMemoryBarrier %6 %7
OpNoLine
OpReturn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// build-pass
// compile-flags: -C llvm-args=--disassemble-fn=workgroup_memory_barrier_with_group_sync::workgroup_memory_barrier_with_group_sync
// normalize-stderr-test "OpLine .*\n" -> ""

use spirv_std::spirv;

unsafe fn workgroup_memory_barrier_with_group_sync() {
spirv_std::arch::workgroup_memory_barrier_with_group_sync();
spirv_std::barrier::workgroup_memory_barrier_with_group_sync();
}

#[spirv(compute(threads(1, 1, 1)))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%1 = OpFunction %2 None %3
%4 = OpLabel
OpLine %5 47 13
OpControlBarrier %6 %6 %7
OpNoLine
OpReturn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +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
spirv_std::arch::workgroup_memory_barrier_with_group_sync();
spirv_std::barrier::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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![no_std]

use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
use spirv_std::barrier::workgroup_memory_barrier_with_group_sync;
use spirv_std::spirv;

#[spirv(compute(threads(64)))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
use spirv_std::barrier::workgroup_memory_barrier_with_group_sync;
use spirv_std::spirv;

#[spirv(compute(threads(64)))]
Expand Down
Loading