-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass constants into #[spirv(compute(threads(...)))] ? #697
Comments
Seems like you might be able to use rust-lang/rust#83366 |
yeah! Would have to define a tiny macro though instead of using a constant :) |
Perhaps unsurprisingly, that doesn't actually work, unfortunately. I've been investigating doing this properly, and it has me stumped. Basically, I can't find any way to go from But if there is no way to do this, I have to take it as intentional - during the couse of my search this zulip message:
Although this is in a very specific context, so I might be over extrapolating. If this is truly impossible, then one way we could do this is to abuse const generics, i.e. basically: const N_THREADS: u64 = 100;
#[spirv(compute)]
fn my_entry_point(threads: NumberOfThreads<{N_THREADS}, 0, 0>){} |
The Clippy uses this function: https://github.com/rust-lang/rust-clippy/blob/43905d9f8d0f27d7ad71008bec9ef3c0b0982782/clippy_utils/src/lib.rs#L476 It doesn't handle for example hygiene though and it requires an absolute path. |
Is there any reason the entry can't have const generic parameters?
|
That won't resolve to the const. It will introduce a completely new binding. |
Closing this as a won't fix. Our hands are tied wrt Rust support, and we're not considering another design atm. |
Quite often, an algorithm will have a working data size configurable by a constant, and this size is correlated with the thread group size. Here's what I would like to do, but doesn't work:
Instead I have to fall back to:
I guess the way attributes work might make this impossible? Or is there a way?
In GLSL/HLSL, this is trivial but that's because there's a preprocessor which just injects a
#define
-d value through text replacement.The text was updated successfully, but these errors were encountered: