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
Both Vec3 and Vec3A impl Vector<f32, 3>, so you can't use them interchangeably anymore. We expect most people to use Vec3, and conversion is a trivial From::from.
Cases where we are generic on the vector element type, or element count, or both should remain as generic, eg:
And in #380 we're moving towards an explicit #[spirv(vector)] declaration that is currently tailor made for how glam vector types are declared. (In the future, it should probably impl spirv_std::Vector for that type as well).
If we want to support other vector libraries as well, I suggest we make a tracking issue for each one we want. Then we can make real steps towards supporting them. Comparing how different libraries implement Vec3 and how difficult it would be to support:
glam: struct Vec3 { x, y, z: f32 }
ultraviolet: easy, Vec3 like glam
nalgebra: hard, Vector3<T> is typedef'ed as Matrix { data: ArrayStorage([[T; 3]; 1]), _phantom: PhantomData }
our validation would need to be adjusted to support nesting and handling arrays as a OpTypeVector
would need support for the T generic, since it may be a valid element type but might not
it's a typedef and not a struct, that could complicate things. If we just redefine the typedef to a OpTypeVector, rust allows you to cast a Matrix<f32, U3, U1, ArrayStorage<T, 3, 1>> to Vector3<T> but the types would mismatch. So any solution would need to be placed at struct Matrix level.
We probably want an nalgebra specific solution (instead of a generic one)
any other vector lib I'm missing?
You can still use any of these vector libraries! You just can't pass them to any spirv intrinsics directly, you must manually convert them to glam vectors first, with crates like mint.
Activity
[-]`glam`-ification of `spirv-std`[/-][+]RFC: `glam`-ification of `spirv-std`[/+]schell commentedon Sep 17, 2025
This is a nice simplification from my perspective, no need to make these more general than they need to be.
LegNeato commentedon Sep 17, 2025
I thought we wanted to get away from requiring glam?
Firestar99 commentedon Sep 18, 2025
Vectorhas only ever been implemented for glam, no other vector library was ever properly supported:rust-gpu/crates/spirv-std/src/vector.rs
Lines 28 to 52 in de03e8d
And in #380 we're moving towards an explicit
#[spirv(vector)]declaration that is currently tailor made for how glam vector types are declared. (In the future, it should probablyimpl spirv_std::Vectorfor that type as well).If we want to support other vector libraries as well, I suggest we make a tracking issue for each one we want. Then we can make real steps towards supporting them. Comparing how different libraries implement
Vec3and how difficult it would be to support:struct Vec3 { x, y, z: f32 }Vector3<T>is typedef'ed asMatrix { data: ArrayStorage([[T; 3]; 1]), _phantom: PhantomData }OpTypeVectorOpTypeVector, rust allows you to cast aMatrix<f32, U3, U1, ArrayStorage<T, 3, 1>>toVector3<T>but the types would mismatch. So any solution would need to be placed atstruct Matrixlevel.You can still use any of these vector libraries! You just can't pass them to any spirv intrinsics directly, you must manually convert them to glam vectors first, with crates like
mint.