KhronosGroup / KhronosGroup/glslang
SPIR-V: DecorationNonUniformEXT is not propagated into OpSampledImage
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
I have this test shader:
```
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(binding = 0) uniform texture2D uSamplers[];
layout(binding = 4) uniform sampler2D uCombinedSamplers[];
layout(binding = 1) uniform sampler uSamps[];
layout(location = 0) flat in int vIndex;
layout(location = 1) in vec2 vUV;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform UBO
{
vec4 v[64];
} ubos[];
layout(set = 0, binding = 3) readonly buffer SSBO
{
vec4 v[];
} ssbos[];
void main()
{
int i = vIndex;
FragColor = texture(sampler2D(uSamplers[nonuniformEXT(i + 10)], uSamps[nonuniformEXT(i + 40)]), vUV);
FragColor = texture(uCombinedSamplers[nonuniformEXT(i + 10)], vUV);
FragColor += ubos[nonuniformEXT(i + 20)].v[nonuniformEXT(i + 40)];
FragColor += ssbos[nonuniformEXT(i + 50)].v[nonuniformEXT(i + 60)];
}
```
Commit: 4b4b41a63499d34c527ee4f714dde8072f60c900.
The SPIR-V spec says that the parameter passed to sampling instructions must be marked NonUniformEXT, but only the image and samplers are marked as such here.
```
Decorate 26 DecorationNonUniformEXT
Decorate 34 DecorationNonUniformEXT
Decorate 37 DecorationNonUniformEXT
25: 24(ptr) AccessChain 19(uSamplers) 23
26: 16 Load 25
31: 6(int) Load 8(i)
33: 6(int) IAdd 31 32
34: 6(int) CopyObject 33
36: 35(ptr) AccessChain 30(uSamps) 34
37: 27 Load 36
39: 38 SampledImage 26 37
43: 40(fvec2) Load 42(vUV)
44: 13(fvec4) ImageSampleImplicitLod 39 43
```
Contributor guide
Research direction
Compile the provided GLSL shader with glslang at commit 4b4b41a63499d34c527ee4f714dde8072f60c900 and inspect the generated SPIR-V decorations around SampledImage and sampling instructions. Trace the compiler path that propagates nonuniform qualifiers, then verify that the sampling instruction parameters receive DecorationNonUniformEXT for the reported cases.
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
- Clearly specified
- Newbie friendliness
- 38/100