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

Make naga validation errors easier to debug #204

Open
LegNeato opened this issue Jan 11, 2025 · 5 comments
Open

Make naga validation errors easier to debug #204

LegNeato opened this issue Jan 11, 2025 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@LegNeato
Copy link
Collaborator

Currently when naga fails validation (when using wgpu +rust-gpu for the web) it can be really confusing and really hard to debug:

We should make it better so it is obvious what naga-generated code is causing the failure and how it maps to the rust-gpu input

@LegNeato LegNeato added enhancement New feature or request help wanted Extra attention is needed labels Jan 11, 2025
@schell
Copy link
Contributor

schell commented Jan 12, 2025

I don't have the slightest idea how difficult it would be provide source mapping, but that would be amazing. Of course, there's multiple translations here:

  • Rust -> SPIR-V
  • SPIR-V -> WGSL

And naga doesn't support this currently.

@LegNeato
Copy link
Collaborator Author

LegNeato commented Jan 13, 2025

With zero knowledge of the details, I can't imagine it would be too hard on the rustc-> spirv side, as rustc likely already has the plumbing because you need to do similar stuff mapping debug symbols back to source code. We'd need to patch naga at least though, yeah.

@LegNeato
Copy link
Collaborator Author

@LegNeato
Copy link
Collaborator Author

On the web side, webgpu supports it: https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createShaderModule

But wgpu does not use it (doesn't even generate the API in -sys).

It looks like the Microsoft shader compiler stuff supports embedded pdb and metal supports dwarf debug info.

So much of the plumbing appears to be there.

@wingertge
Copy link

I'd like to chime in here and offer help if needed, since I already wrote a debug info implementation for the SPIR-V backend in CubeCL. The extended debug info API (NonSemantic.Shader.DebugInfo.100) can be temperamental but is extremely useful for profiling and debugging shaders, so it would be great to have access to it in rust-gpu. I believe it should be relatively easy to map to the rustc debug symbol plumbing, and it can also be hooked up to dwarf symbols to allow for even more advanced debugging.

I'm not familiar enough with the codebase atm to do my own PR, but if there are any questions I'd be happy to help out. There are some quirks you do need to keep track of (like OpSource directives being ignored unless there's a corresponding OpLine that references it at the start of the function body).

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

No branches or pull requests

3 participants