Uh oh!
There was an error while loading. Please reload this page.
add trait ScalarComposite - #441
Conversation
ce822f1 to
5b6cf85Compare
nazar-pc
left a comment
There was a problem hiding this comment.
Interesting, assuming this is zero cost abstraction (like when a struct contains a single scalar field I expect it to compile to the same code as if it was just a single scalar), this makes sense to me.
One opaque thing I do not like as much is that it can implicitly result in multiple subgroup operations. For example like when array is used it'll clearly iterate over each individual value instead of calling a vector form with all or part of the values, which may not be what the user would expect to happen.
2143e1b to
80dda7dCompare5b6cf85 to
5ebd674Compare5ebd674 to
6a62178CompareFirestar99
commented
Oct 16, 2025
Pretty much, otherwise you'd see the subgroup compiletests with disassembly fail due to different codegen.
If you can't observe the difference between a single operation and multiple operations back-to-back, does that actually matter? |
6a62178 to
5a7d997Compare80dda7d to
449c894Compare5a7d997 to
ceaceffCompare449c894 to
e2d766bCompareceaceff to
462a4faComparee2d766b to
9a6d9abCompare462a4fa to
bd37adbComparebd37adb to
1a90208CompareLegNeato
commented
Oct 27, 2025
Going to let @eddyb review |
2a8211d to
0e4b51dCompareFirestar99
commented
Oct 28, 2025
I'm surprised you say that, since this is only changing some ordinary rust code in |
nazar-pc
commented
Nov 8, 2025
I'd love for this to land, it'll make a few places in my code much less awkward |
| /// [`FromPrimitive`]: https://docs.rs/num_enum/latest/num_enum/derive.FromPrimitive.html | ||
| /// [`IntoPrimitive`]: https://docs.rs/num_enum/latest/num_enum/derive.IntoPrimitive.html | ||
| /// [`num_enum`]: https://crates.io/crates/num_enum | ||
| pub trait ScalarOrVectorComposite: Copy + Send + Sync + 'static { |
There was a problem hiding this comment.
Thought: shorten the name to ScalarComposite. Vectors are made from scalars, so it is still correctly named.
0e4b51d to
6db1894Compare6db1894 to
95e557cCompare
eddyb
left a comment
There was a problem hiding this comment.
Neat approach, impl seems correct (add ?w=1 to the GitHub URL hide whitespace changes), we should land this if there aren't design concerns.
(to be honest I didn't even realize this was blocked on me)
Requires #440
rust-gpu/crates/spirv-std/src/scalar_or_vector.rs
Lines 22 to 49 in 6db1894
Also see previous iteration at #411
todo
subgroup_all_equal()subgroup_broadcast_constadded in subgroup: fix docs and broadcast const variant #443close#410