-
Notifications
You must be signed in to change notification settings - Fork 244
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
Add capability attribute #529
Conversation
Just out of curiosity, could capabilities be detected at compile time and would that be desirable? |
@dragostis In theory, I believe so, I believe you probably could visit each instruction, see what capabilities it requires, and construct a set of a capabilities to emit at the end. However whether that's desirable is another part, because as I understand, these capabilities affect platform availability, meaning that some platforms don't have certain capabilities. So unintentionally enabling them can be a frustrating experience as your code will compile successfully to SPIR-V, but will fail when that SPIR-V is compiled on the target platform. |
FWIW we kind of do that right now, and we're moving away from that.
(that file should also go away with this PR, along with this rust-gpu/crates/rustc_codegen_spirv/src/builder_spirv.rs Lines 223 to 226 in 908487a
|
@khyperia Removing
|
Yes, those systems in the compiler will need to be updated to the new capability computation system, in this case, my comment
in #42. (Don't remove |
9c1daad
to
9efa832
Compare
9efa832
to
2e1b819
Compare
Okay, well I think we should make removing those a separate PR, as they aren't incompatible with the new attribute, and it keeps both PRs smaller and easier to test. |
Sorry, I guess I was confused by the scope of this PR |
No worries, I don't think there was a explicit scope when I opened, and this discussion helped clarified it. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think multiple.rs
and invalid-target.rs
need to be updated with this. not_entry_point.rs
can probably also be folded into invalid-target.rs
?
.filter_map(|i| { | ||
CAPABILITIES | ||
.iter() | ||
.find(|x| Symbol::intern(x.0) == i.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be cached and put in a HashMap, similar to how const BUILTINS
/Symbols::attributes
is done - interning is relatively expensive, especially in a O(n) find loop. The array should probably also be defined alongside the other large chunks of data, to consolidate them into something more manageable.
Going with #555 instead of attributes, so closing this |
rip, race condition on closing it, hit the button literally the moment github flipped it to "reopen", haha |
This PR adds the
#[spirv(capabilities)]
attribute, which accepts a list of capabilities on an entrypoint function and emits those capabilities.To Do
#[spirv(capabilities)]
with entry point functions.