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

Shader compilation errors are cryptic #3760

Closed
luke-biel opened this issue Jan 24, 2022 · 5 comments
Closed

Shader compilation errors are cryptic #3760

luke-biel opened this issue Jan 24, 2022 · 5 comments
Labels
A-Diagnostics Logging, crash handling, error reporting and performance analysis A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Comments

@luke-biel
Copy link
Contributor

luke-biel commented Jan 24, 2022

What problem does this solve or what need does it fill?

During wgsl shader compilation errors that bevy emits are only partial. Compare:

2022-01-24T15:17:42.140124Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader: 
error: 


to naga equivalent:

error:

Entry point vertex at Vertex is invalid:
	Argument 0 varying error
	Entry point arguments and return values must all have bindings

when missing [[builtin(vertex_index)]] in fn vertex(vertex_index: u32) -> VertexOutput {

or

2022-01-24T15:24:32.360440Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader: 
error: 
  ┌─ wgsl:8:9
  │
8 │     if (vertex_index == 0) {
  │         ^^^^^^^^^^^^^^^^^ naga::Expression [4]

vs naga:

error:
  ┌─ static_grid_copy.wgsl:8:9
  │
8 │     if (vertex_index == 0) {
  │         ^^^^^^^^^^^^^^^^^ naga::Expression [4]

Entry point vertex at Vertex is invalid:
	Expression [4] is invalid
	Operation Equal can't work with [1] and [3]

when trying to compare u32 vs signed value.

What solution would you like?

I'd like last part provided by naga that describes what's happening to be attached along with rest of the error.

Additional context

https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/render_resource/pipeline_cache.rs#L463
looks identical to
https://github.com/gfx-rs/naga/blob/master/cli/src/main.rs#L500

In naga there's second function https://github.com/gfx-rs/naga/blob/master/cli/src/main.rs#L150 that prints remainder of the error. Simply copy pasting print_err body expanded my error to:

2022-01-24T15:24:32.342290Z ERROR naga::valid::expression: Right: Constant([1]) of type Scalar { kind: Sint, width: 4 }    
Entry point vertex at Vertex is invalid: 
	Expression [4] is invalid
	Operation Equal can't work with [1] and [3]
2022-01-24T15:24:32.360440Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader: 
error: 
  ┌─ wgsl:8:9
  │
8 │     if (vertex_index == 0) {
  │         ^^^^^^^^^^^^^^^^^ naga::Expression [4]

which is sufficient.

I can provide a PR if this is acceptable solution.

@luke-biel luke-biel added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jan 24, 2022
@jakobhellermann
Copy link
Contributor

There's a PR that includes the causes in the error message: #3724.

@jakobhellermann jakobhellermann added A-Diagnostics Logging, crash handling, error reporting and performance analysis A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Jan 24, 2022
@luke-biel
Copy link
Contributor Author

Missed that. Great news then :)

@mockersf
Copy link
Member

mockersf commented Feb 5, 2022

#3724 has been merged, is it ok for you now?
would #3675 also improve error reporting?

@luke-biel
Copy link
Contributor Author

In this issue I focused purely on #3724. #3675 isn't directly connected to problems I had so I'm gonna close the issue.

@ErichDonGubler
Copy link

In case anybody still thinks that errors are cryptic, like we on the Firefox team do, we're planning on doing some work to make diagnostics nicer: gfx-rs/wgpu#4494

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Diagnostics Logging, crash handling, error reporting and performance analysis A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

4 participants