Skip to content

Commit 0c20561

Browse files
nazar-pcFirestar99
authored andcommitted
Use adt_const_params for Scope and Semantics const generics
1 parent 3c74afb commit 0c20561

21 files changed

Lines changed: 241 additions & 148 deletions

.github/workflows/ci.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,11 @@ jobs:
380380
run: cargo fmt --check --all --manifest-path tests/difftests/tests/Cargo.toml
381381
- name: Check docs are valid
382382
run: RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps
383-
- name: Check docs for `spirv-std` and `spirv-builder` on stable (for docs.rs)
384-
run: |
385-
RUSTDOCFLAGS=-Dwarnings cargo +stable doc --no-deps -p spirv-std
386-
RUSTDOCFLAGS=-Dwarnings cargo +stable doc --no-deps -p spirv-builder --no-default-features
383+
# TODO: Stable is not supported due to use of nightly features
384+
# - name: Check docs for `spirv-std` and `spirv-builder` on stable (for docs.rs)
385+
# run: |
386+
# RUSTDOCFLAGS=-Dwarnings cargo +stable doc --no-deps -p spirv-std
387+
# RUSTDOCFLAGS=-Dwarnings cargo +stable doc --no-deps -p spirv-builder --no-default-features
387388
- name: cargo clippy
388389
run: cargo clippy --all-targets -- -D warnings
389390
- name: custom lints

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
10+
### Changed 🛠
11+
12+
- [PR#635](https://github.com/Rust-GPU/rust-gpu/pull/635) started using `Scope`- and `Semantics`-typed const generics (`control_barrier`, `memory_barrier`, atomic intrinsics, `read_clock_khr`/`read_clock_uvec2_khr`) now take `spirv_std::memory::Scope`/`Semantics` directly (e.g. `{ Scope::Workgroup }`, `{ Semantics::WORKGROUP_MEMORY.union(Semantics::ACQUIRE_RELEASE) }`) instead of raw `u32` bit patterns, using `adt_const_params`. Composing `Semantics` flags now compiles with an assertion that at most one memory-ordering flag (`ACQUIRE`/`RELEASE`/`ACQUIRE_RELEASE`/`SEQUENTIALLY_CONST`) is set, per the SPIR-V spec.
13+
914
## [0.10.0-alpha.1](https://github.com/Rust-GPU/rust-gpu/compare/v0.9.0...v0.10.0-alpha.1) - 2026-04-13
1015

1116
Toolchain: `nightly-2026-04-11` (rustc 1.96.0)

crates/spirv-std/src/arch.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#[cfg(target_arch = "spirv")]
77
use crate::Integer;
88
use crate::glam::UVec2;
9+
use crate::memory::Scope;
910
use crate::{Scalar, SignedInteger, UnsignedInteger, Vector};
1011
#[cfg(target_arch = "spirv")]
1112
use core::arch::asm;
@@ -150,7 +151,7 @@ pub fn kill() -> ! {
150151
/// <https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/KHR/SPV_KHR_shader_clock.html>
151152
#[spirv_std_macros::gpu_only]
152153
#[doc(alias = "OpReadClockKHR")]
153-
pub fn read_clock_khr<const SCOPE: u32>() -> u64 {
154+
pub fn read_clock_khr<const SCOPE: Scope>() -> u64 {
154155
unsafe {
155156
let mut result: u64;
156157

@@ -159,7 +160,7 @@ pub fn read_clock_khr<const SCOPE: u32>() -> u64 {
159160
"%scope = OpConstant %uint {scope}",
160161
"{result} = OpReadClockKHR typeof*{result} %scope",
161162
result = out(reg) result,
162-
scope = const SCOPE,
163+
scope = const { SCOPE as u32 },
163164
};
164165

165166
result
@@ -172,7 +173,7 @@ pub fn read_clock_khr<const SCOPE: u32>() -> u64 {
172173
/// bits and the second component containing the 32 most significant bits.'
173174
#[spirv_std_macros::gpu_only]
174175
#[doc(alias = "OpReadClockKHR")]
175-
pub fn read_clock_uvec2_khr<const SCOPE: u32>() -> UVec2 {
176+
pub fn read_clock_uvec2_khr<const SCOPE: Scope>() -> UVec2 {
176177
unsafe {
177178
let mut result = UVec2::default();
178179

@@ -182,7 +183,7 @@ pub fn read_clock_uvec2_khr<const SCOPE: u32>() -> UVec2 {
182183
"%result = OpReadClockKHR typeof*{result} %scope",
183184
"OpStore {result} %result",
184185
result = in(reg) &mut result,
185-
scope = const SCOPE,
186+
scope = const { SCOPE as u32 },
186187
};
187188

188189
result

0 commit comments

Comments
 (0)