KhronosGroup / KhronosGroup/glslang
Specialization constant not considered constant for subgroupBroadcast (again?)
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
I think this is the same issues as in #2919
I am using the `glslangValidator` that is distributed with VulkanSDK 1.3.243.0
Specialization constant derived value should be considered constant for its use in `subgroupBroadcast`
```glsl
#version 450
#extension GL_KHR_shader_subgroup_ballot: enable
layout(local_size_x_id = 0, local_size_y = 1, local_size_z = 1) in;
layout(constant_id = 0) const uint SUBGROUP_SIZE = 32;
layout(set = 0, binding = 0) writeonly buffer OutputBuffer {
uint outputBuffer[];
};
void main() {
uint value = gl_LocalInvocationID.x;
uint result = subgroupBroadcast(value, SUBGROUP_SIZE - 1);
outputBuffer[gl_WorkGroupID.x * SUBGROUP_SIZE + gl_LocalInvocationID.x] = result;
}
```
Here is the command used to compile and the output:
```shell
> glslangValidator.exe -g --target-env vulkan1.1 app/shaders/repro.comp.glsl -o test.spv
app/shaders/repro.comp.glsl
ERROR: app/shaders/repro.comp.glsl:13: 'id' : argument must be compile-time constant
ERROR: app/shaders/repro.comp.glsl:13: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link
```
Contributor guide
Research direction
Start by running glslangValidator with the command shown on app/shaders/repro.comp.glsl and compare the behavior with issue #2919. Trace how the compiler handles SUBGROUP_SIZE - 1 as the subgroupBroadcast id argument; done means the shader compiles and SPIR-V is generated without the reported errors.
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
- 38/100