KhronosGroup / KhronosGroup/glslang
Debug layer error for some Built-in Variables in SPV_KHR_shader_ballot/GL_ARB_shader_ballot
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Hello, thanks for maintaining this software! It has worked flawlessly for me until I ran into the following issue while implementing a cross-platform stream compaction algorithm with the extension GL_ARB_shader_ballot:
The following shader compiles just fine in using glslangValidator.exe:
```
#version 450
#extension GL_ARB_gpu_shader_int64 : require
#extension GL_ARB_shader_ballot : require
layout (local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
void main()
{
uint64_t A = ballotARB(true); // Works
uint64_t B = gl_SubGroupEqMaskARB; // Works
uint C = readFirstInvocationARB(0); // Works
uint D = readInvocationARB(0, 0); // Works
uint E = gl_SubGroupInvocationARB; // Debug layer error
uint F = gl_SubGroupSizeARB; // Debug layer error
}
```
However, at runtime vkCreateShaderModule reports the following error upon consuming the SPIR-V code: _VK_DEBUG_REPORT_ERROR_BIT_EXT [SC] SPIR-V module not valid: Operand 3 of Decorate requires one of these capabilities: Kernel (5)_
The error only appears when using gl_SubGroupInvocationARB or gl_SubGroupSizeARB, and not for the other variables and functions in the extension.
The device is created with the extension VK_EXT_shader_subgroup_ballot and with the shaderInt64 device feature.
Relevant system info: Geforce GTX 1070 - latest drivers. glslang is the latest version, and so is the SDK.
Here is the generated SPIR-V code in human readable format:
```
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 44
Capability Shader
Capability Int64
Capability SubgroupBallotKHR
Extension "SPV_KHR_shader_ballot"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main" 21 35 38
ExecutionMode 4 LocalSize 128 1 1
Source GLSL 450
SourceExtension "GL_ARB_gpu_shader_int64"
SourceExtension "GL_ARB_shader_ballot"
Name 4 "main"
Name 8 "A"
Name 19 "B"
Name 21 "gl_SubGroupEqMaskARB"
Name 24 "C"
Name 29 "D"
Name 33 "E"
Name 35 "gl_SubGroupInvocationARB"
Name 37 "F"
Name 38 "gl_SubGroupSizeARB"
Decorate 21(gl_SubGroupEqMaskARB) BuiltIn SubgroupEqMaskKHR
Decorate 35(gl_SubGroupInvocationARB) BuiltIn SubgroupLocalInvocationId
Decorate 38(gl_SubGroupSizeARB) BuiltIn SubgroupSize
Decorate 43 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 64 0
7: TypePointer Function 6(int)
9: TypeBool
10: 9(bool) ConstantTrue
11: TypeInt 32 0
12: TypeVector 11(int) 4
16: TypeVector 11(int) 2
20: TypePointer Input 6(int)
21(gl_SubGroupEqMaskARB): 20(ptr) Variable Input
23: TypePointer Function 11(int)
25: TypeInt 32 1
26: 25(int) Constant 0
30: 11(int) Constant 0
34: TypePointer Input 11(int)
35(gl_SubGroupInvocationARB): 34(ptr) Variable Input
38(gl_SubGroupSizeARB): 34(ptr) Variable Input
40: TypeVector 11(int) 3
41: 11(int) Constant 128
42: 11(int) Constant 1
43: 40(ivec3) ConstantComposite 41 42 42
4(main): 2 Function None 3
5: Label
8(A): 7(ptr) Variable Function
19(B): 7(ptr) Variable Function
24(C): 23(ptr) Variable Function
29(D): 23(ptr) Variable Function
33(E): 23(ptr) Variable Function
37(F): 23(ptr) Variable Function
13: 12(ivec4) SubgroupBallotKHR 10
14: 11(int) CompositeExtract 13 0
15: 11(int) CompositeExtract 13 1
17: 16(ivec2) CompositeConstruct 14 15
18: 6(int) Bitcast 17
Store 8(A) 18
22: 6(int) Load 21(gl_SubGroupEqMaskARB)
Store 19(B) 22
27: 25(int) SubgroupFirstInvocationKHR 26
28: 11(int) Bitcast 27
Store 24(C) 28
31: 25(int) SubgroupReadInvocationKHR 26 30
32: 11(int) Bitcast 31
Store 29(D) 32
36: 11(int) Load 35(gl_SubGroupInvocationARB)
Store 33(E) 36
39: 11(int) Load 38(gl_SubGroupSizeARB)
Store 37(F) 39
Return
FunctionEnd
```
Contributor guide
Research direction
Start with the glslangValidator input shader and the generated SPIR-V around gl_SubGroupInvocationARB and gl_SubGroupSizeARB, then compare the module consumed by vkCreateShaderModule with the stated Vulkan subgroup extensions. Reproduce the validation error and verify that the corrected generated module is accepted without the Kernel capability complaint.
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