-
Notifications
You must be signed in to change notification settings - Fork 896
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
Non uniform indices are not always properly handled by naga #6270
Comments
The bug is that naga's analyzer considers flat interpolants (which integers are by default) to be uniform, which is just plain wrong. There is nothing that says that something flat across the triangle will be subgroup uniform. wgpu/naga/src/valid/analyzer.rs Lines 604 to 608 in eb18854
|
6 tasks
magcius
added a commit
to magcius/wgpu
that referenced
this issue
Sep 15, 2024
Implementations can absolutely pack multiple triangles per subgroup. Fixes gfx-rs#6270.
magcius
added a commit
to magcius/wgpu
that referenced
this issue
Sep 15, 2024
Implementations can absolutely pack multiple triangles per subgroup. Fixes gfx-rs#6270.
That's a big oops! |
ErichDonGubler
changed the title
Non uniform indexes are not always properly handled by naga
Non uniform indices are not always properly handled by naga
Sep 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
We had an off error that only occured on AMD GPUs (Vega, RDNA1 and RDNA2), where under Vulkan and DX12 textures where rendered with the wrong texel information (see attached screenshot). We use the "SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING" feature to select textures based on non-uniform vertex data inside the fragment shader. We found out, that the AMD devices sometimes used the wrong texture for some texels. We debugged the problem under Vulkan and saw, that sometimes in the SPIRV output the indexes used for indexing the binding array witht the texture where not properly markes as non-uniform indexes.
We traces the problem back to naga, which will not emmit the necessary marker for non-unified indexes when using fragment shader with no wrapper struct for the function parameter. We reproduces the problem using the texture_arrays example.
Repro steps
Use the current trunk branch (eb18854) and remove the wrapper struct for the fragment input:
This will result in SPIRV code which does not have the expected non-uniform index marker in it. It looks like this in HLSL when de-compiled with SPIRV cross:
Normally the indexes should be marked as non-uniform indexes like (using the original texture_arrays code):
It is also possible to skip the wgpu part and directly convert both WGSL shader versions with the help of naga-cli:
Expected vs observed behavior
Non-uniform indexes should properly marked as such in the resulting shader modules.
Extra materials
Platform
WGPU stable (22.1) and WGPU trunk. Nvidia and Intel devices will accept the SPIRV modules and render them without any problem, but AMD devices on either Windows and Linux will render with artifacts (see screenshot).
The text was updated successfully, but these errors were encountered: