You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In beab6cf last year @Firestar99 downgraded bitflags in spirv-std to version 1.3.2 because the "backend fails with 2.X". This of course causes two instances of bitflags to be compiled in when rust-gpu is used alongside e.g. cargo-gpu-install or vulkano.
I tried upgrading spirv-std to the latest bitflags 2.11.0 anyway but I did not notice any apparent issues when building or running tests on today's main, but I have not a clue if I am doing it right.
For some reason, our backend doesn't like the following expression which bitflags 2.X expands to. I downgraded it back to 1.X for now. eddyb any ideas?
error: cannot offset a pointer to an arbitrary element
--> /home/firestar99/workspace/rust-gpu/crates/spirv-std/src/ray_tracing.rs:675:28
|
675 | let flag = <RayFlagsas bitflags::Flags>::FLAGS[i].value().bits();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
Curious to hear it just works right now, cause I don't remember us changing anything that may lead to this being fixed.
Feel free to PR in the version upgrade, I'll have a look if I can find the cause why this suddenly works.
Upgrading to bitflags@2 on current main still fails the ray_query_get_ray_flags_khr compiletest (cargo compiletest ray_flags optional --bless), by that test calling RayFlags::from_bits_truncate(..) (via get_ray_flags()) which causes the compile error
You're so fast! My laptop is still frying my thighs running the tests on unmodified main as a sanity check.
In that case the downgrade is still adequate and I have peace of mind telling Clippy to shut up. I suppose this issue could be left open to document this work-around until fixing it becomes feasible.
Index: crates/spirv-std/src/ray_tracing.rs
===================================================================diff --git a/crates/spirv-std/src/ray_tracing.rs b/crates/spirv-std/src/ray_tracing.rs--- a/crates/spirv-std/src/ray_tracing.rs (revision bc4b857b89483b7bfc899dd24282759c46bbb33c)+++ b/crates/spirv-std/src/ray_tracing.rs (revision 78f12b7307eb48389e840223f5a14fb2a5bcb5c3)@@ -441,7 +441,7 @@
/// Convert from a bits value, unsetting any unknown bits.
#[inline]
pub const fn from_bits_truncate(bits: u32) -> Self {
- Self(bits & Self::all().0)+ Self(bits & const { Self::all() }.0)
}
/// Convert from a bits value exactly.
This works due to Self::all() now being evaluated by rustc's const eval engine (aka miri-ish) instead of passed onwards to our codegen backend. Would still result in broken code if you'd use Self::all() from outside this function without a const block.
Activity
Firestar99 commentedon Feb 27, 2026
The commit links to #349 where I left this comment:
Curious to hear it just works right now, cause I don't remember us changing anything that may lead to this being fixed.
Feel free to PR in the version upgrade, I'll have a look if I can find the cause why this suddenly works.
git-staus commentedon Feb 27, 2026
I completely missed the link back to that issue, thanks!
Firestar99 commentedon Feb 27, 2026
Upgrading to bitflags@2 on current main still fails the
ray_query_get_ray_flags_khrcompiletest (cargo compiletest ray_flagsoptional--bless), by that test callingRayFlags::from_bits_truncate(..)(viaget_ray_flags()) which causes the compile errorgit-staus commentedon Feb 27, 2026
You're so fast! My laptop is still frying my thighs running the tests on unmodified
mainas a sanity check.In that case the downgrade is still adequate and I have peace of mind telling Clippy to shut up. I suppose this issue could be left open to document this work-around until fixing it becomes feasible.
nazar-pc commentedon Mar 5, 2026
The issue with bitflags points to the same issue with pointers that qptr is supposed to resolve.
The reason is that despite being known at compile time, bitflags converts array to a slice, which breaks indexing:
If only they made it look like this:
or this:
It would have worked just fine.
Firestar99 commentedon Mar 5, 2026
Even funnier, this fixes it:
This works due to
Self::all()now being evaluated by rustc's const eval engine (aka miri-ish) instead of passed onwards to our codegen backend. Would still result in broken code if you'd useSelf::all()from outside this function without a const block.