-
Notifications
You must be signed in to change notification settings - Fork 60
Optimize constant casts to avoid unnecessary capabilities #302
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
Conversation
I think this is safe to do...everywhere we widen a const, just replace with a wider const, after everything is done look to see what types we use and match the capabilities used. But I haven't really thought through all the cases. One thing that can happen if there are a ton of constant casts we could be creating a ton of constants rather than a ton of cast instructions...not sure if that is better or worse from a perf perspective. |
Add constant folding for widening casts (u8->u32, f32->f64) to avoid creating intermediate types. Remove capability checks during type creation and add bidirectional validation in linker to remove unused type capabilities. Fixes Rust-GPU#300
Will this handle a case like |
No, this only does |
Pushed another commit to support |
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.
Very nice!
I'd love to have a remove_unused_type_capabilities
for all capabilities in the future, so instead of pre-declaring all needed capabilities, each shader would just have the capabilities it needs, and end users can use standard features instead of relying on target_features
to mask out certain capabilities.
Add constant folding for widening casts (u8->u32, f32->f64) to avoid creating intermediate types. Remove capability checks during type creation and add bidirectional validation in linker to remove unused type capabilities.
Fixes #300