KhronosGroup / KhronosGroup/glslang
SPIR-V dynamic indexing capabilities not generated in all cases
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
There is a set of tests in VK-GL-CTS that use dynamically uniform indexes when accessing arrays of descriptors of different types, like uniform buffers, storage buffers, storage texel buffers, etc.
These tests check for the corresponding feature to be available and enabled in the device, as you can see here:
https://github.com/KhronosGroup/VK-GL-CTS/blob/d99a765d38d35deeb3f27cf30d9d6fe4f183510e/external/vulkancts/modules/vulkan/binding_model/vktBindingDescriptorSetRandomTests.cpp#L218
If dynamic indexing is supported and the index type is "DEPENDENT", for example, these tests generate code like the following one:
```
#version 450 core
#extension GL_EXT_nonuniform_qualifier : enable
layout(r32i, set = 0, binding = 0) uniform iimage2D simage0_0;
layout(set = 1, binding = 0) uniform ubodef1_0 { int val; } ubo1_0[5];
layout(set = 1, binding = 2) uniform ubodef1_2 { int val; } ubo1_2[3];
layout(set = 3, binding = 6) uniform ubodef3_6 { int val; } ubo3_6[1];
layout(set = 7, binding = 2) uniform ubodef7_2 { int val; } ubo7_2[2];
layout(set = 7, binding = 7) uniform ubodef7_7 { int val; } ubo7_7[1];
layout(local_size_x = 1, local_size_y = 1) in;
void main()
{
int accum = 0, temp;
temp = ubo1_0[accum + 0].val;
accum = temp - 1;
temp = ubo1_0[accum + 1].val;
accum = temp - 2;
temp = ubo1_0[accum + 2].val;
accum = temp - 3;
temp = ubo1_0[accum + 4].val;
accum = temp - 5;
temp = ubo1_2[accum + 0].val;
accum = temp - 6;
temp = ubo1_2[accum + 1].val;
accum = temp - 7;
temp = ubo1_2[accum + 2].val;
accum = temp - 8;
temp = ubo3_6[accum + 0].val;
accum = temp - 9;
temp = ubo7_2[accum + 0].val;
accum = temp - 10;
temp = ubo7_2[accum + 1].val;
accum = temp - 11;
temp = ubo7_7[accum + 0].val;
accum = temp - 12;
ivec4 color = (accum != 0) ? ivec4(0,0,0,0) : ivec4(1,0,0,1);
imageStore(simage0_0, ivec2(gl_GlobalInvocationID.xy), color);
}
```
However, when this specific GLSL shader is compiled to SPIR-V, the output does not declare the UniformBufferArrayDynamicIndexing capability, which I believe needs to be declared for the generated code to work (NB: vendors are still passing these tests, so it's probably not critical). The same problem is also happening with other DynamicIndexing capabilities.
Contributor guide
Research direction
Start with the shader example in the issue and the VK-GL-CTS case at vktBindingDescriptorSetRandomTests.cpp:218, then inspect how glslang emits SPIR-V capabilities for dynamic descriptor indexing. Compare the generated output across descriptor types; done means the required dynamic-indexing capabilities are emitted consistently and the reported cases are covered by a regression check.
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