-
Notifications
You must be signed in to change notification settings - Fork 722
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
[SPIR-V] Invalid SPIR-V generated where OpStore
is being used to store to an object with OpTypeImage
.
#4444
[SPIR-V] Invalid SPIR-V generated where OpStore
is being used to store to an object with OpTypeImage
.
#4444
Comments
@manon-traverse Thank you for reporting this issue. We will take a look. |
@jaebaek Is there something I could do to help out with tracking down and solving this? I can imagine you are pretty busy with many more issues than this one, so if I could help out in any way with this issue, let me know! Cheers, |
I took a quick look. It seems like spirv-opt is not optimizing away the function scope variable like it should, but I'm not sure which pass needs to be updated. The address of the variable is passed to an OpImageTexelPointer. We need to replace the address in the instruction with the UniformConstant address that contains the same value. |
Hi @manon-traverse, Thanks for bumping this issue. I tried reproducing this using the current top-of-trunk and did not see any
|
I can see the two |
I believe I've managed to reduce this to a minimal reproducible example: RWTexture3D<uint> g_rwTexture3d[100000];
[numthreads(256, 1, 1)] void main() {
RWTexture3D<uint> voxels = g_rwTexture3d[0];
uint bucketOffset;
InterlockedAdd(voxels[uint3(1,2,3)], 1, bucketOffset);
} Which when compiled with
@s-perron could you confirm whether this has the error? I believe it's |
Yes, this contains the invalid code. The spir-v is the code that I would expect the FE to generate. There is a pass is spir-v tools that is suppose to replace the We can discuss the next step, but I would change |
I ran into a case where I attempted to use atomics on a 3D texture that is loaded in a bindless manner. When compiling to DXIL there seems to be no issue in the generated code. However, when compiling to SPIR-V I found that it generates invalid SPIR-V.
To illustrate the issue I have attached an example shader that produces the issue, as well as the generated SPIR-V.
HLSL: bin_lines.cs.hlsl.txt
SPIR-V: bin_lines.cs.hlsl#main#SPIR-V#cs_6_6.txt
The interesting bits of SPIR-V are the following:
This contradicts Vulkan's spec, https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-StandaloneSpirv-OpTypeImage-04661 :
"Objects of types OpTypeImage, OpTypeSampler, OpTypeSampledImage, and arrays of these types must not be stored to or modified"
I have also filed an issue on
SPIRV-Tools
, sincespirv-val
does not catch this issue either. KhronosGroup/SPIRV-Tools#4796The text was updated successfully, but these errors were encountered: