-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Initial precompiled shaders implementation #7834
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
base: trunk
Are you sure you want to change the base?
Initial precompiled shaders implementation #7834
Conversation
…orporated/wgpu into dxil-passthrough
Hmm, I think in general I like the ideas put forward in your plan you wrote up, that makes sense to me. As for the code changes themselves, I don't think that we need another variant internally - this feels redundant when all the other variants exist. Maybe what would need to be added is an optional reflection info to each of the variants? |
@cwfitzgerald The purpose of this variant is so that the user can pass a single shader without considering backend-specific code. This way we can also later on add a macro that creates this struct, filling fields for all the backends that are supported, and it doesn't need to be passed a |
Yeah, I agree that it makes sense in |
True, didn't think about that to be honest. I'll rewrite that part of this PR |
@cwfitzgerald When you're back - this has been waiting for a while. |
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'm really looking forward to this! Just some things which popped up!
@DJMcNab Thanks for the review! Upon further inspection it seems my PR was not super well thought through or checked, so I'll have another look over everything myself in addition to addressing your comments. |
@DJMcNab I've just given this PR a final look and it looks good. Some of your comments I left open as I wasn't sure how to handle them. Let me know what you think, you get the final say of course! Also pinging @cwfitzgerald because this hopefully can be merged soon Another note: the only backend not currently supported is OpenGL. Once we get that done, maybe we should consider removing this as a feature? I'm not sure how that would interact with e.g. custom backends so I'll wait until later to inquire about that. |
I'm not planning to review this again - it needs to be reviewed by someone with write access, and I was providing a "first pass" review to help speed this along, but I can't give a fully "in-context" review. Thanks for actioning the review feedback so well! I've found it easy to submit PRs which don't hold up when given a second reading myself as well - that's what review is for, after all! |
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.
A few small comments, but this is exactly what I was looking for!
CHANGELOG.md
Outdated
### General | ||
- Added `Features::EXPERIMENTAL_PRECOMPILED_SHADERS`, replacing existing passthrough types with a unified `CreateShaderModuleDescriptorPassthrough` which allows passing multiple shader codes for different backends. By @SupaMaggie70Incorporated in [#7834](https://github.com/gfx-rs/wgpu/pull/7834) |
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 a major changes with a small things showing off the diff and the new API
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 made a new changelog entry, let me know if you want more changes to it
Alright @cwfitzgerald, I think I've addressed most of the recent changes (and also updated the PR to latest trunk). If there's anything more let me know. |
Connections
Works towards #3103
Depends on #7831
Also, as this is the start of a big change, I'd like to ping @cwfitzgerald to at least make sure I haven't gone off in the wrong direction.
Description
This adds a
CreateShaderModuleDescriptorPassthrough::Generic
enum variant which contains code for multiple types of shader source,allows creating passthrough shaders without writing backend specific code (if on metal pass MSL, etc). This variant also includes an optional reflection thing. For now, I don't know exactly what reflection info is needed, but if possible, we should make sure this can live inwgpu-types
orwgpu-core
to avoid dependency onnaga
. It seems the best model for this is thewgpu_core::validation::Interface
, we might just have to replace some of the naga types.Using this requires enabling the EXPERIMENTAL_PRECOMPILED_SHADERS feature. This feature is only supported on DX12, Vulkan, and Metal. Logic on these backends is otherwise identical to the respective specific passthrough methods.
Nothing is currently done with the reflection info.
An overview of my approach can be found in this comment. If this process takes longer than expected we can make a tracking issue. For now I will be posting updates by editing that comment and referencing it in PRs.
Testing
No testing yet. However, the code seems somewhat small and robust.
Squash pls
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.