Skip to content

[SPIR-V] Invalid SPIR-V generated where OpStore is being used to store to an object with OpTypeImage. #4444

Closed
KhronosGroup/SPIRV-Tools
#4890
@manon-traverse

Description

@manon-traverse

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:

%type_3d_image = OpTypeImage %uint 3D 2 0 0 2 R32ui
...
%_ptr_Function_type_3d_image = OpTypePointer Function %type_3d_image
...
%131 = OpAccessChain %_ptr_UniformConstant_type_3d_image %g_rwTexture3d %130
%132 = OpLoad %type_3d_image %131
...
`%69 = OpVariable %_ptr_Function_type_3d_image Function`
...
OpStore %69 %132

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, since spirv-val does not catch this issue either. KhronosGroup/SPIRV-Tools#4796

Metadata

Metadata

Assignees

Labels

spirvWork related to SPIR-V

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions