Skip to content
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

don't panic if naga parsing of shader source fails #5034

Conversation

waynr
Copy link
Contributor

@waynr waynr commented Jan 10, 2024

Connections
#5019

fixes #2545

Description
In my application shaders are meant to be hot-reloaded on filesystem changes.
If there is a syntax issue with the newly-updated shader source naga parsing
of the file can fail. In current trunk, the Result returned by naga parsing
is simply unwrapped.

This PR removes the naga parse unwrap and instead bubbles the Result up
through the call stack so to be handled by the calling code.

I am opening this PR prior to updating the changelog and getting cargo xtask test to run just to start discussion (should have commits addressing those
shortly after opening it).

Testing
I've updated the examples and test cases that were already calling
Device.create_shader_module.

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@waynr waynr requested a review from a team as a code owner January 10, 2024 20:32
@waynr waynr force-pushed the device-dont-panic-if-naga-parsign-of-shader-source-fails branch from 67503e7 to 7148796 Compare January 11, 2024 07:47
@waynr waynr force-pushed the device-dont-panic-if-naga-parsign-of-shader-source-fails branch from 7148796 to 0061d54 Compare January 17, 2024 06:33
@waynr waynr requested a review from a team January 17, 2024 06:33
@teoxoy
Copy link
Member

teoxoy commented Jan 18, 2024

@waynr could you rebase the PR on latest trunk? so the new CI jobs can run.

@teoxoy
Copy link
Member

teoxoy commented Jan 18, 2024

Ah, nvm, they didn't run because the clippy jobs are failing.

@waynr waynr force-pushed the device-dont-panic-if-naga-parsign-of-shader-source-fails branch from 0061d54 to 73d6fae Compare January 18, 2024 15:27
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good to me, it's consistent with how we deal with WGSL shaders as well.

@teoxoy
Copy link
Member

teoxoy commented Jan 19, 2024

@nical do you want to take another look?

@waynr waynr force-pushed the device-dont-panic-if-naga-parsign-of-shader-source-fails branch from e31179a to 4d53a97 Compare January 21, 2024 22:35
@cwfitzgerald cwfitzgerald requested a review from nical January 21, 2024 22:38
@waynr waynr force-pushed the device-dont-panic-if-naga-parsign-of-shader-source-fails branch from 7159d78 to f8bc24b Compare January 22, 2024 15:38
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
@teoxoy teoxoy requested a review from cwfitzgerald January 23, 2024 13:29
@teoxoy
Copy link
Member

teoxoy commented Jan 23, 2024

This should be ready to go. Pinging @nical & @cwfitzgerald for pending reviews.

@cwfitzgerald cwfitzgerald merged commit c4b5cc9 into gfx-rs:trunk Jan 23, 2024
27 checks passed
@waynr
Copy link
Contributor Author

waynr commented Jan 23, 2024

Thanks for working through this with me!

@waynr waynr deleted the device-dont-panic-if-naga-parsign-of-shader-source-fails branch July 13, 2024 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ShaderSource::Glsl panics if shader has syntax error
5 participants