-
Notifications
You must be signed in to change notification settings - Fork 194
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
make validate-spv
fails with newest SPIRV-Tools
#2034
Comments
See also #2032. |
Okay, so the WGSL declarations in
This results in the SPIR-V:
WGSL's rules say that the Vulkan's shader resource interface offset and stride assignment rules say,
where the "extended alignment" of a matrix member of a struct is
So it seems like WGSL's requirements are less stringent than Vulkan's. |
In Matrix chat, Alan Baker says:
so our SPIR-V generation will need to explode that mat3x2 into individual vec2 members or something. |
I was hoping we don't have to do this for the SPIR-V backend as well since you could specify a lower stride and validation didn't complain, but it seems we have to... It's unfortunate that we now have to do this complex translation in 3 backends (GLSL, SPIR-V, and HLSL) we might want to somehow consolidate this. |
So I guess this is what we need to generate now:
and then loads look like this:
We can no longer assume that Naga IR struct member indices are the same as SPIR-V struct member indices. |
Yeah, although there are a bunch of edge-cases (as we've seen in the HLSL PRs that were related to matCx2's). IIRC main one being that wrapping vec2's in a struct might not work in cases where the original matCx2 was already part of a struct since the resulting struct wrapper will have a min alignment requirement of 16 (in uniforms/extended layout) but matCx2's should have an alignment of 8. It might be helpful to track the HLSL implementation of this while implementing it for the SPIR-V backend. |
Right - looking at the table in the spec, it seems like putting the vec2's in any kind of container causes them to acquire the 16-byte alignment requirement. So the only way to make it work is to just inline them. |
One problem with the instruction sequence I proposed earlier is that SPIR-V has no instructions for using a dynamic index into a matrix by value. If you have a pointer to the matrix, then That's pretty gross. |
Confirmed with Tint team that this is what Tint does, and no better solution is known. |
For better searchability, here's the full validation error one gets from wgpu apps with Vulkan validation turned on:
|
Closing this one as we already have the more descriptive gfx-rs/wgpu#4371. |
Using
spirv-val
from KhronosGroup/SPIRV-Tools@a98f05d0, Naga'smake validate-spv
target fails:This is a new change;
spirv-val
from, say,sdk-1.3.204.1
has no complaints.The text was updated successfully, but these errors were encountered: