-
Notifications
You must be signed in to change notification settings - Fork 437
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
ShaderModule::single_entry_point() #2301
ShaderModule::single_entry_point() #2301
Conversation
1b186e1
to
44f7af1
Compare
I wonder if most ShaderModules are just a single entry point anyway, if |
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.
We put self
in backquotes everywhere else in the library (and parameters in general).
Sure, I don't see a reason to have both fields, even when it you have multiple entry points. The end goal is to use |
…ed linearly search though a Vec
about |
LGTM, thanks! |
* added ShaderModule::single_entry_point() functions * single_entry_point() always verifies it's the sole entry point, search optimizations * single_entry_point() docs adjustments * ShaderModule removed entry_point_map, instead entry points are searched linearly search though a Vec --------- Co-authored-by: Firestar99 <4696087-firestar99@users.noreply.gitlab.com>
Almost all of your userbase* will have a single glsl file, containing a single shader, generating a single
*.spv
file which contains the sole entry pointmain
. And it's loaded like this:I'm annoyed at constantly having to write that the entry point is
main
. I know there is only a single entry point in that file, so just give me that one, without me having to writemain
every time. This PR adds a function just for that, simplifying the code above to:rust-gpu, or why I actually wanted this
Rust-gpu by default compiles all shaders into a single
*.spv
with varying entry points. However yourshader!
macro does not like that, so typically users will turn on "multimodule" which generates one*.spv
per shader. But the entry point name will still be the rust module path to the shader function, eg.renderer::lodobj::vs
, and specifying that is even more annoying. I've solved it by codegening all theshader!
macro calls in the build script, where I have access to both the spv file path and entry point name, so I won't benefit from this PR anymore, but others using glsl will probably like this as well.Testing
The other entry_point() methods are only covered by unit-tests through shader cache tests. And with the shader! macro not being available in tests it seems pretty difficult to automatically test.
So I've just reverted to manually testing the
single_entry_point
method in the triangle example, but testing thesingle_entry_point_of_execution
may prove difficult as glslc will not generate an spv with multiple entry points from what I can tell.Checklist
Update documentation to reflect any user-facing changes - in this repository.
Make sure that the changes are covered by unit-tests.
See Testing
Run
cargo fmt
on the changes.Please put changelog entries in the description of this Pull Request
if knowledge of this change could be valuable to users. No need to put the
entries to the changelog directly, they will be transferred to the changelog
file by maintainers right after the Pull Request merge.
Please remove any items from the template below that are not applicable.
Describe in common words what is the purpose of this change, related
Github Issues, and highlight important implementation aspects.
Changelog: