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

[spv-out] wrapping struct types for globals lack required decorations #1810

Closed
jimblandy opened this issue Apr 8, 2022 · 2 comments · Fixed by #1815
Closed

[spv-out] wrapping struct types for globals lack required decorations #1810

jimblandy opened this issue Apr 8, 2022 · 2 comments · Fixed by #1815
Assignees
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output

Comments

@jimblandy
Copy link
Member

Naga IR permits globals to have non-struct types, but Vulkan requires that globals in the Uniform and Storage storage classes be struct types. Our SPIR-V backend accommodates this by synthesizing SPIR-V struct types wrapping the contents of Naga globals as needed, but it fails to apply decorations required on members that are matrices or arrays of matrices.

For example, the following WGSL input generates SPIR-V that fails to validate:

@group(0)
@binding(0)
var<uniform> transform: mat4x4<f32>;

@stage(vertex)
fn vs_main(
    @location(0) position: vec4<f32>,
) -> @builtin(position) vec4<f32> {
    return transform * position;
}

This fails validation in the vulkan1.0 target environment:

error: line 19: Structure id 7 decorated as Block must be explicitly laid out with MatrixStride decorations.
  %_struct_7 = OpTypeStruct %mat4v4float
@jimblandy jimblandy added kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output area: back-end Outputs of shader conversion labels Apr 8, 2022
@jimblandy jimblandy self-assigned this Apr 8, 2022
jimblandy added a commit to jimblandy/naga that referenced this issue Apr 10, 2022
@kvark
Copy link
Member

kvark commented Apr 11, 2022

Hmm now I feel strange. Wouldn't we see this on CI? Our CI runs spirv-val on produced code, and tests use non-structured uniform/storage buffers.

@jimblandy
Copy link
Member Author

jimblandy commented Apr 12, 2022

Hmm now I feel strange. Wouldn't we see this on CI? Our CI runs spirv-val on produced code, and tests use non-structured uniform/storage buffers.

We don't have any tests that use straight (i.e., not wrapped in a struct) matrix types in uniform or storage buffers. I tried to introduce one in the tests for #1815, but discovered #1811.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants