-
Notifications
You must be signed in to change notification settings - Fork 2
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
Linting shaders #5
Comments
naga-cli can validate and translate shaders. This will give you errors (sometimes panics without an error) but not necessarily give you feedback about style or unused names etc. |
I'm thinking this would mean building a separate pip installable CLI tool that uses naga-cli to validate .wgsl and .glsl files. |
wgpu uses naga already to validate shaders. And errors do get passed all the way to Python. I use a simple try/except for my project. And this does work, apart from edge cases where the called process panics (it doesn't have any exit code). Some of these are already addressed and next wgpu-core release is targeting 17th January, which I hope includes all the naga fixes of the past 2 months. So using |
I'm mostly thinking about having a CLI tool available that can be run on CI to validate all .glsl and .wgsl files. I think with what you're saying, it means we could build something like that on wgpu-py instead of on naga-cli. |
yes, adding a cli tool for the functionality of the shadetoy util is also something I wanted to consider. But that requires features like file I/O for example. |
https://github.com/PolyMeilex/vscode-wgsl Looks like this has both syntax highlighting and a CLI linting functionality |
I hacked together a VSCode extension to syntax-highlight shaders in Python strings: https://github.com/pygfx/python-string-shaders (using a similar extension for sql as inspiration). The workflow is not as nice as when the shader is in its own file, because it only does highlighting, the language server does not kick in, so there is no autocompletion and code analysis. But perhaps a nice middle ground. |
Can naga be used as a cli tool to lint shader files? Or are there other tools that can be used?
The text was updated successfully, but these errors were encountered: