-
Notifications
You must be signed in to change notification settings - Fork 596
[spirv-opt] ssa-rewrite producing invalid spir-v for shader #5968
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
Comments
The validator isn't catching it, but the input SPIR-V is invalid. VUID-StandaloneSpirv-OpTypeImage-06924
In this case there are function scope variables of OpTypeImage. I expect the input shader needs more legalization. Unfortunately in SPIR-V, the code pattern used is invalid, e.g. (pseudo code):
Because SPIR-V cannot select between images (nor are variable pointers usable in UniformConstant storage class) I think the only valid code would be to sink the sampling into the if. Works here since it's a grad operation. In other cases it would need to be converted to a grad to avoid non-uniform derivatives. I'm not sure any legalization does this currently. |
Ah, thank you. The pattern you identified is similar to what the shader is doing, yes. This spir-v was generated by slang and I presumed it was correct because it was passing spirv-val. Do I understand correctly that we have the following bugs:
|
Yes, I think that's right. |
Actually that VUID is checked under the Vulkan environment. So you validate with
|
We'll leave this open in case someone wants to write the pass to replicate the code. Some of the building block might already exist in the |
Uh oh!
There was an error while loading. Please reload this page.
Given the attached shader
ssa_rewrite_bug.spv
using spirv-optSPIRV-Tools v2024.4 v2024.4.rc2-0-g4d2f0b40
(Vulkan SDK 1.4.304.0) and running:spirv-val on the output shader gives the following error:
I hit this as part of running our shaders through
-Os
and narrowed it down to the ssa-rewrite pass.ssa_rewrite_bug.zip
The text was updated successfully, but these errors were encountered: