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

Texture sampling issues when using a texture binding_array on Windows+AMD gpu with wgpu 0.18 #4762

Closed
Elabajaba opened this issue Nov 23, 2023 · 3 comments · Fixed by #4766
Closed
Labels
area: naga back-end Outputs of naga shader conversion lang: SPIR-V Vulkan's Shading Language naga Shader Translator type: bug Something isn't working

Comments

@Elabajaba
Copy link
Contributor

Elabajaba commented Nov 23, 2023

Description
Textures look borked when sampling from a binding_array<texture_2d<f32>> on Windows+AMD gpu+wgpu 0.18+vulkan.

Repro steps
Run bevy's texture_binding_array (shader code) example on Windows with an AMD gpu.

Expected vs observed behavior

broken sampling

Extra materials

The wgsl: https://gist.github.com/Elabajaba/783e298cff814526a4e9e17031a7346f

A similar bug happened on Linux+AMD (RADV) with wgpu 0.17, but is fixed with wgpu 0.18.
This bug only appeared for me on windows+amd with wgpu 0.18 + vulkan.

Platform
Windows 11, AMD 6800xt with the 23.11.1 driver.

@nical
Copy link
Contributor

nical commented Nov 24, 2023

Which backend(s) are you seeing this issue with?

@teoxoy
Copy link
Member

teoxoy commented Nov 24, 2023

It seems my interpretation of where the decoration should go was not 100% accurate gfx-rs/naga#2421 (comment).

VUID-RuntimeSpirv-NonUniform-06274
If an instruction loads from or stores to a resource (including atomics and image instructions) and the resource descriptor being accessed is not dynamically uniform, then the operand corresponding to that resource (e.g. the pointer or sampled image operand) must be decorated with NonUniform

from https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/RuntimeSpirv.html

On a second read of the VUID, I think we should decorate both the access chain and the result of the load; glslang seems to be doing this as well (ref).

Which would explain why this previously worked in 0.17 (where we were only decorating the access chain) but not in 0.18 (where we are only decorating the load). It seems drivers care about one or the other.

@teoxoy teoxoy added type: bug Something isn't working area: naga back-end Outputs of naga shader conversion naga Shader Translator lang: SPIR-V Vulkan's Shading Language labels Nov 24, 2023
@teoxoy
Copy link
Member

teoxoy commented Nov 24, 2023

Which backend(s) are you seeing this issue with?

Vulkan/SPIR-V - it was reported over on matrix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion lang: SPIR-V Vulkan's Shading Language naga Shader Translator type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants