-
Notifications
You must be signed in to change notification settings - Fork 195
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
Spirv output fails with [VUID-StandaloneSpirv-Flat-06202] (wgpu water example) #2036
Comments
Reduced the failing shader down to: @vertex
fn vs_main(
@location(0) position: vec2<i32>,
) -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
}
|
For reference I used shader-playground to compile a somewhat similar glsl shader: #version 330
in ivec2 position;
void main() {
gl_Position = vec4(float(position.x), 0.0, 0.0, 1.0);
} Giving the following spirv:
There is a similar structure around the declaration of the input, the first difference that stands out is that the vertex attribute is not decorated as flat. |
... and removing |
This could be fixed either:
(1) might be tricky to depending on whether non-entry-point functions are allowed to take argments with locations, because we don't know for non-entry-point functions which stage will call them. I filed gpuweb/gpuweb#3399 to clarify. That said, there is the same problem for vertex attribute bindings that are specified in a struct instead of directly in the parameters of the vertex shader entry point, the parser wouldn't be able to tell whether the struct refers to inputs of the vertex shader. |
I think we should generally ignore interpolation on vertex inputs and fragment outputs (in the backends). This is somewhat related to gpuweb/gpuweb#2760 |
That's how I see it as well however it's not 100% clear to me that the spirv backend has enough context. In function parameters we can see what stages the function can be used in and we get to only care about entry points, however it looks like for structs we don't necessarily know what stage a struct with @location members will be used for (and whether as input or output). |
EDIT: This is incorrect. Struct arguments to fragment shaders are broken out into individual variables, and the struct is reconstituted as part of the entry point's prelude. Regarding structs: the actual language in the Vukan spec refers to "variables":
I think this implies that if there are such decorations on struct members, even if the struct serves as the type of an If that is correct, then fixing this is simply a matter of changing the way we emit entry point parameters. |
Structs already have to be deconstructed into per-stage input/output variables (function parameters and structs are just pretend for SPIR-V, which uses stage variables back and forth), and when making these per-stage variables, you should know what shader stage and direction they're part of, and thus, what interpolation attributes to use for them. |
In So it's simply a matter of |
… end of the pipeline. Fixes gfx-rs#2036.
… end of the pipeline. Fixes gfx-rs#2036.
Originally filed as #2032
I'm filing a new issue since a fix for the first part of that issue doesn't appear to fix this part.
The text was updated successfully, but these errors were encountered: