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
{{ message }}
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
spir-v has vector types that are dramatically useful on e.g. nvidia hardware for optimizing loads/stores. At first, let's just directly expose vector types, instead of trying to do things like auto-vectorization.
Rustc already has the notion of vector types, and we directly translate them to spir-v vector types. We need to investigate under what conditions rustc emits vector types, and if we can re-use the same framework.
let elem_spirv = trans_scalar(cx, ty, element,None, is_immediate);
SpirvType::Vector{
element: elem_spirv,
count: count asu32,
}
.def(cx)
}
If we cannot re-use the same framework, create an attribute to specify a type is a builtin vector, recognize the attribute in abi.rs (example for storage classes), and emit a vector type. Perhaps do a mix of the two, e.g. if rust supports f32x2 and f32x4, but not f32x3, then we need to define our own f32x3.
Investigate the spec: is emitting a spir-v "OpTypeVector" enough, or are there additional decorations/etc. we need to apply to get it to be a proper "vector type"?
Implement the above in spirv-std, adding things like swizzling ops and other shenanigans (can come later).
This seems like a good not-quite-first-but-kinda-first task for someone other than me to do. Step 2 is a little involved and will likely need some mentorship - abi.rs is hecking wild - but getting more people who know how abi.rs works would be really really good.
It looks like item 2 is not necessary - seems like #[repr(simd)] is all that needed. So yeah, definitely good first issue! Mostly just step 4 is necessary, although a more senior person digging deeper into points 1 and 3 would be nice - I don't think there's any surprises there, though (but it's good to be sure).
f32x4 is already implemented in spirv-std by copying the above type, but it's just that, and needs all the impls and operators and whatnot (as well as all the other types). Defining all that repitition using macros seems neat.
This issue is a bit out of date, though: #71 added quite a few vector items. However, it wasn't very cleanly or thoroughly implemented, and needs significant work. Some tasks remaining are:
vec4 and f32x4 are duplicated right now. One of them needs to be removed. Discussing which naming scheme to go with in discord would be nice, if you're able to join there!
A lot of cruft from glam was copied over, this needs to be fixed (e.g. reciprocal), and many weird comments.
There's a lot of duplication: it'd be nice if we could deduplicate with macros or somesuch.
The clippy use_self lint is disabled on spirv-std, primarily due to violations in the vector code, it'd be good to fix those.
Tests are disabled on spirv-std right now, either remove the tests or enable them.
Activity
khyperia commentedon Sep 26, 2020
Possibly relevant: https://github.com/hsivonen/simd/blob/045d4dae4e65f99fd43cd9042f5132812cae717e/src/lib.rs#L75-L79
khyperia commentedon Oct 20, 2020
It looks like item 2 is not necessary - seems like
#[repr(simd)]is all that needed. So yeah, definitely good first issue! Mostly just step 4 is necessary, although a more senior person digging deeper into points 1 and 3 would be nice - I don't think there's any surprises there, though (but it's good to be sure).f32x4 is already implemented in spirv-std by copying the above type, but it's just that, and needs all the impls and operators and whatnot (as well as all the other types). Defining all that repitition using macros seems neat.
nipunG314 commentedon Oct 24, 2020
Hi, I would be interested with working on this.
From what I understand in this thread, the first thing to do would be to write the operators and impls for f32x4 using macros?
khyperia commentedon Oct 24, 2020
Awesome!
This issue is a bit out of date, though: #71 added quite a few vector items. However, it wasn't very cleanly or thoroughly implemented, and needs significant work. Some tasks remaining are:
reciprocal), and many weird comments.use_selflint is disabled onspirv-std, primarily due to violations in the vector code, it'd be good to fix those.nipunG314 commentedon Oct 24, 2020
Sure. I'll ping you on #rust-gpu on Discord.
khyperia commentedon Nov 12, 2020
With glam and whatnot in, this is pretty much resolved.