Open unvestigate opened 1 year ago
I was wondering. Why is it inserting those phony assignments into the code? Is it to make sure something isn't optimized away or what is the deal?
The SPIR-V front-end might be doing some transformations (looking at those transpose
calls) and not cleaning up after itself.
The WGSL back-end might also be misbehaving and trying to "take the address of a vector component".
Could you share your SPIR-V input file?
Sure. I uploaded the file here: https://drive.proton.me/urls/JQ577Y7N8R#Wn1D9KWe5t1v
Thanks!
The phony assignments should be harmless and are indeed some leftovers of a transformation in the frontend (row major matrix -> column major).
We need to disallow taking the address of a vector component https://github.com/gpuweb/gpuweb/pull/2225.
I added a small hack to my shader compilation pipeline for this. It basically looks for lines that look like these and removes them. The rest of the code is left as-is and does work how I expect it to.
And yes, I do use row-major matrices due to the source language being HLSL, and I appreciate Naga doing the conversion here so that the shaders work with WebGPU.
naga
already knows that those expressions are not actually used but still writes them to improve the debugging experience in some cases, also some of our snapshot tests make use of this behavior. We should add a flag to make this behavior configurable.
I have a shader which I run through Naga to convert it from SPIR-V to WGSL. As part of it the following struct is generated:
Then later Naga generates code like this:
When trying to load the generated code using the Dawn WebGPU backend I get the following errors:
I was wondering. Why is it inserting those phony assignments into the code? Is it to make sure something isn't optimized away or what is the deal?