KhronosGroup / KhronosGroup/SPIRV-Tools
spirv-val: OpImageTexelPointer with OpFunctionParameter will validate error.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
I use glslang compile my HLSL source code to SPIRV. the following function use a opaque type "rwTex" as a parameter.
```
void AtomicAdd(uniform RWTexture2D rwTex, in uint2 coord, in float value)
{
uint2 max_coord = uint2(TextureSize.xy) - 1;
if (all(coord < max_coord) && all(coord > uint2(1, 1)))
{
InterlockedAdd(rwTex[coord], (int) (value * FXDPT_SIZE));
}
}
```
It will translate to this:
```
%7 = OpTypeImage %int 3D 0 0 0 2 R32i
// ... other code
%AtomicAdd_iI311_vu3_f1_ = OpFunction %void None %13
%rwTex = OpFunctionParameter %7
%coord = OpFunctionParameter %_ptr_Function_v3uint
%value = OpFunctionParameter %_ptr_Function_float
// ... other code
%71 = OpImageTexelPointer %_ptr_Image_int %rwTex %64 %uint_0
%72 = OpAtomicIAdd %int %71 %uint_1 %uint_0 %68
```
%71 instruction will validate failed, because %rwTex is excepted to a OpTypePointer with OpTypeImage. but here it is a OpFunctionParameter with OpTypeImage.
Contributor guide
Research direction
Start at the SPIR-V validator's handling of OpImageTexelPointer and compare its operand requirements with the reproduced instruction using an OpFunctionParameter of OpTypeImage. Reproduce the glslang-generated SPIR-V and validation failure, then determine whether the validator or the generated module is incorrect and add or update a focused validation test if the payload's behavior is confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100