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

Outputting integral type from fragment shader causes Vulkan validation error #2270

Closed
Wumpf opened this issue Mar 9, 2023 · 1 comment · Fixed by #2286
Closed

Outputting integral type from fragment shader causes Vulkan validation error #2270

Wumpf opened this issue Mar 9, 2023 · 1 comment · Fixed by #2286
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output

Comments

@Wumpf
Copy link
Member

Wumpf commented Mar 9, 2023

Validation layer trips off since Naga emits flat qualifier for integer outputs of fragment shader.
Note that wgpu correctly forces output to be an integer type when writing to a "true" (non-snorm/unorm) target.

Happens with a shader like this:

@fragment
fn fs_main_outline_mask(in: VertexOut) -> @location(0) vec2<u32> {
    return batch.outline_mask;
}

image
More details in this comment rerun-io/rerun#1532 (comment)

Not familiar with Naga's code, but it looks like there's a check missing here for fragment outputs https://github.com/gfx-rs/naga/blob/master/src/back/spv/writer.rs#L1415

@Wumpf Wumpf changed the title Outputting integral type from fragment shader causes Vulkan validation warning Outputting integral type from fragment shader causes Vulkan validation error Mar 9, 2023
@teoxoy teoxoy added kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output area: back-end Outputs of shader conversion labels Mar 14, 2023
@teoxoy teoxoy added this to the WGSL Specification V1 milestone Mar 14, 2023
@teoxoy
Copy link
Member

teoxoy commented Mar 14, 2023

Thanks for the report!

Not familiar with Naga's code, but it looks like there's a check missing here for fragment outputs https://github.com/gfx-rs/naga/blob/master/src/back/spv/writer.rs#L1415

Indeed, adding the check there should fix it; as we seem to handle VUID-StandaloneSpirv-Flat-06202 but not VUID-StandaloneSpirv-Flat-06201.

A PR would be welcome!

Wumpf added a commit to rerun-io/naga that referenced this issue Mar 19, 2023
Fix adding `Centroid` and `Sample` decorator on vertex inputs.

Furthermore, fix allowing to add `Centroid` and `Sample` decorator to vertex inputs.
Fixes gfx-rs#2270
Wumpf added a commit to rerun-io/naga that referenced this issue Mar 19, 2023
Furthermore, fix allowing to add `Centroid` and `Sample` decorator to vertex inputs.
Fixes gfx-rs#2270
teoxoy pushed a commit that referenced this issue Mar 20, 2023
* [spirv-out] Fix adding illegal decorators on fragment outputs.

Furthermore, fix allowing to add `Centroid` and `Sample` decorator to vertex inputs.
Fixes #2270

* Add test for fragment outputs

* Fix fragment-output.wgsl test using more than 8 outputs in a single shader
Breaks HLSL & MSL validation

* formatting
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