-
Notifications
You must be signed in to change notification settings - Fork 965
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
Introspect the shader requirements for validation #269
Comments
I've never used it, but this spirq-rs crate was posted on r/rust_gamedev not long ago, and looks like it might be well suited for doing the necessary shader introspection. |
Right, I believe @swiftcoder is looking into it. |
Is @swiftcoder still working on this, or is it up for contributing? |
Doesn't look like @swiftcoder is doing this, consider it available for contribution! The situation has changed though. We don't want to invest into SPIR-Q, instead we'd want to integrate naga and dog-food it. The first stage is having |
Now that we no longer have Would adding a test that directly calls |
The tests you are considering is more than just a shader, it's the whole pipeline. We could just defer this to the point where we could run wgpu-native against WebGPU CTS, which covers the validation purposes. Alternatively, once #289 is implemented, we'll be able to have small internal tests based on the deserialization of the work. |
I've looked into this, but I don't know exactly where the introspection & validation would take place. We are given the raw SPIR-V code in Should we store the SPIR-V code somewhere? Or do we expose this validation functionality as helper functions? |
The natural spot for validation is Edit: yes, feel free to add more metadata on our |
I've put our plan up in the body of the issue. The last bit here is not required, but I think it makes sense, because it's fairly easy to build on top of the other steps, and our WGSL front-end is pretty mature, unlike the SPIR-V front-end. The only blocker here is that SPIR-V backend is still not merged - gfx-rs/naga#46 (cc @Napokue ). So for now, we can't do (4), but we can do the other 3 points in preparation to it. But most importantly, we can start having that validation code based on |
641: Add optional SPIR-V shader validation r=kvark a=GabrielMajeri This PR adds some basic validation for SPIR-V shaders when creating pipelines. Starts work towards #269. Currently, I'm marking this as a draft because `naga` isn't mature enough to be able to parse shaders from the `wgpu-rs` examples. For example: - Trying to run `hello-triangle` from `wgpu-rs` results in the following error: `Failed to parse shader SPIR-V code: UnsupportedInstruction(Function, Variable)` - For `hello-compute` it is: `Failed to parse shader SPIR-V code: UnsupportedInstruction(Type, TypeBool)` Co-authored-by: Gabriel Majeri <[email protected]>
Is validating if a buffer has the right BufferStage setting a part of this issue or should I create a new one? |
@Yamakaky buffer having the right usage flags is unrelated to this issue. It's about shader requirements only. |
704: Pipeline layout validation r=cwfitzgerald a=kvark **Connections** Implements a solid part of #269 Starts converting the function to return results, related to #638 cc @GabrielMajeri **Description** This change matches shader bindings against the pipeline layout. It's *mostly* complete, minus some bugs and not handling the `storage_texture_format` properly. The risk here is that Naga reflection may have bugs, or our validation may have bugs, and we don't want to break the user content while this is in flux. So the PR introduces an internal `WGPU_SHADER_VALIDATION` environment variable. Switching it to "0" skips Naga shader parsing completely and allows the users to unsafely use the API. Another aspect of the PR is that some of the functions now return `Result`. The way I see us proceeding is that any errors that we don't expect users to handle should result in panics when `wgpu` is used natively (i.e. not from a browser). These panics would happen in the "direct" backend of wgpu-rs (as well as in wgpu-native), but the `Result` would not be exposed to wgpu-rs, so that it matches the Web behavior. At the same time, browser implementations (Gecko and Servo) will check the result on their GPU process and implement the WebGPU error model accordingly. This means `wgpu-core` can be super Rusty and safe. **Testing** Running on wgpu-rs examples. Most of them fail to get parsed by Naga, but `boids` succeeds and passes validation 🎉 Co-authored-by: Dzmitry Malyshau <[email protected]>
We need some way to ask the shader modules for what their expected bindings are, vertex attributes, etc. Currently, it's easy to get the shader mismatched with the pipeline layout, and we aren't validating it.
Edit: here is a tentative plan, and it involves Naga:
ShaderModel
contains anOption<naga::Module>
. The goal is to make it a no-option at some pointFollow-up plan:
The text was updated successfully, but these errors were encountered: