-
Notifications
You must be signed in to change notification settings - Fork 969
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
Procedural Macros to create VertexBufferLayout
#5621
Comments
I also think this would be pretty cool (and also dunno if its been talked about before). It feels like something that could also be done by a separate crate, though it may be a good edition to the util module? I'd like to give it a crack |
Do note that we have a |
Agreed that this could probably be developed in a separate crate. I actually kind of like the wgsl reflection proc macro idea even more than just the derive macro. It could be invoked like this: wgpu::wgsl_module! {
file: "my_shader.wgsl", // file to load
module: my_shader, // Rust module name to create
} And the macro would:
Of course not all of that would be necessary, a MVP would just be creating a Rust representation for any |
Second that this is a very interesting idea, but definitely not in scope for the |
Thirding this and closing as won't fix. |
Is your feature request related to a problem? Please describe.
I think it is fairly common to have code like this:
This is a bit tedious to maintain but is fairly boilerplate, so a macro could help usability here.
Describe the solution you'd like
Probably extract the vertex format to a trait:
And then add a derive macro that leverages
GpuFormat
and the recently-stabilizedoffset_of
:Note that this exact code above currently hits rust-lang/rust#124478, but that should be fixed soon in rust-lang/rust#124484.
Describe alternatives you've considered
It would be nice if more information could be reflected from the shader, rather than needing to keep the shader and the Rust code in sync (pretty big source of my errors when just getting started). Maybe an alternative to
include_wgsl!
could create a rust module with automatically created types for everything in WGSL shader?I am sure this has been talked about somewhere :)
The text was updated successfully, but these errors were encountered: