Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions crates/spirv-std/src/arch/barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ pub unsafe fn control_barrier<
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpMemoryBarrier")]
#[inline]
pub unsafe fn memory_barrier<const MEMORY: Scope, const SEMANTICS: Semantics>() {
// FIXME(eddyb) use a `bitflags!` `Semantics` for `SEMANTICS`.
pub unsafe fn memory_barrier<const MEMORY: Scope, const SEMANTICS: u32>() {
asm! {
"%u32 = OpTypeInt 32 0",
"%memory = OpConstant %u32 {memory}",
"%semantics = OpConstant %u32 {semantics}",
"OpMemoryBarrier %memory %semantics",
memory = const MEMORY as u8,
semantics = const SEMANTICS as u8,
semantics = const SEMANTICS,
}
}
1 change: 1 addition & 0 deletions crates/spirv-std/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum Scope {
QueueFamily = 5,
}

// FIXME(eddyb) use `bitflags!` for this.
#[derive(Debug, PartialEq, Eq)]
pub enum Semantics {
/// No memory semantics.
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/arch/control_barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use spirv_std::memory::{Scope, Semantics};
pub fn main() {
unsafe {
spirv_std::arch::control_barrier::<
{ Scope::Workgroup },
{ Scope::Workgroup },
{ Scope::Subgroup },
{ Scope::Subgroup },
{ Semantics::None },
>();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/arch/memory_barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use spirv_std::memory::{Scope, Semantics};
pub fn main() {
unsafe {
spirv_std::arch::memory_barrier::<
{ Scope::Workgroup },
{ Semantics::None },
{ Scope::Subgroup },
{ (Semantics::AcquireRelease as u32) | (Semantics::UniformMemory as u32) },
>();
}
}