-
Notifications
You must be signed in to change notification settings - Fork 143
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
Use vello_shaders crate to load and preprocess WGSL #563
Conversation
Since the copyright check is failing, you'll need to modify the 2 checks to account for the new location of the CPU shaders. That's in |
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.
Awesome. I looked into this previously, but thought the hot reload support would have been dropped - I missed that from_dir
function.
It's unfortunate that we can't use the pipeline struct of vello_shaders
(because it doesn't allow parallel initialisation), but that could be resolved in the future, I guess?
I've not ran this locally, but CI passes (and since #439, that actually means something)
@@ -55,6 +55,7 @@ workspace = true | |||
|
|||
[dependencies] | |||
vello_encoding = { workspace = true } | |||
vello_shaders = { workspace = true } |
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.
Do we still need the compile
feature to be enabled even if we're not hot reloading?
I guess it doesn't really matter, because we share the Naga version with wgpu
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.
That's a good point. Even though the features match, I think there is merit to excluding the feature when it's not needed. Though I generally tend to rely on linkers being smart about excluding unused code from binaries (which is desirable in the wasm build case) I went ahead and made "compile" an optional feature, which feels right to me.
src/shaders.rs
Outdated
) | ||
}; | ||
($name:ident, $bindings:expr) => { | ||
add_shader!($name, $bindings, &full_config) | ||
add_shader!($name, $bindings) |
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 is the exact as above and can be removed
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.
Pretty interesting, does rust/clippy not cover equal macro branches? O.o
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.
Good catch!
This is something I've been considering. I'm not entirely convinced yet that the shaders crate should abstract the pipeline initialization (which is what the currently unused PipelineHost trait declarations were intended for). If we do that, then it might make sense to have the shaders crate handle multi-threaded pipeline compilation. I should write down my thoughts on this in an issue. I'm particularly thinking about non-wgpu engines and I'm not sure yet how to best organize that code. |
This replaces the shader preprocessing code in the vello crate with invocations to the vello_shaders crate, which supports both reading from a directory at runtime (for hot_reload) and bundlng pre-compiled shader code into the binary (which is suitable for wasm).
This also moves the CPU shader code over to the vello_shaders crate behind the "cpu" feature.
Resolves #467