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

Naga error messages not as useful as they could be #104

Closed
almarklein opened this issue May 21, 2021 · 9 comments
Closed

Naga error messages not as useful as they could be #104

almarklein opened this issue May 21, 2021 · 9 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@almarklein
Copy link
Collaborator

When the provided WGSL shader code is invalid, the error messages are usually less useful than if I run Naga directly on that shader code.

Example:

...
return vec4<f32>(value, value, value, 1);

wgpu-native:

Vector component[3] type Scalar { kind: Sint, width: 4 }
thread '<unnamed>' panicked at 'Validation(EntryPoint { stage: Fragment, name: "fs_main", error: Function(Expression { handle: [9], error: Compose(ComponentType { index: 3 }) }) })', src\device.rs:87:5

Naga:

Entry point fs_main at Fragment is invalid:
        Expression [9] is invalid
        Composing 3's component type is not expected
error: process didn't exit successfully: `target\debug\naga.exe c:/dev/py/tmp.wgsl` (exit code: 0xffffffff)

With naga it will sometimes also indicate where in the code the error occurs.

Is this something that can be improved somehow?

@kvark
Copy link
Member

kvark commented May 21, 2021

Absolutely! The error function needs to walk the chain of errors, not just debug print it ({:?}). See https://github.com/gfx-rs/naga/blob/72fca17dbc56a33acdf53ab6eab113386a774731/bin/naga.rs#L26

@kvark kvark added enhancement New feature or request help wanted Extra attention is needed labels May 21, 2021
@almarklein
Copy link
Collaborator Author

Is that link where a change would be needed to fix this, or is this the function that should be called instead in wgpu-core?

@kvark
Copy link
Member

kvark commented May 26, 2021

This is an example of properly printing out the error chain. wgpu-native need similar logic in order to spew out readable messages.

@almarklein
Copy link
Collaborator Author

I think this is where a change would be needed:

https://github.com/gfx-rs/wgpu/blob/eadaa1b7d8f585761e28445904fe619b180aca0d/wgpu-core/src/device/mod.rs#L1041-L1052

I had a quick try inserting the referenced lines there, but get:

let mut e = err.source();
                ^^^^^^ method not found in `naga::front::wgsl::ParseError

@kvark
Copy link
Member

kvark commented Jun 2, 2021

Do you have std::error::Error in scope? Try adding use std::error::Error.

@almarklein
Copy link
Collaborator Author

Ah, that helps getting the code to compile. But the error reporting is not getting better. I just saw this maybe related comment, looks like someone else is trying to achieve something similar for glsl.

@kvark
Copy link
Member

kvark commented Jun 2, 2021

Hmm. Error reporting is already there for WGSL though, and this is what you are testing.
What does it look like currently with these changes?

@almarklein
Copy link
Collaborator Author

Here's what I got so far: gfx-rs/wgpu#1424

@almarklein
Copy link
Collaborator Author

This has been fixed upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants