Support extension EXT_shader_quad_control

This commit is contained in:
laddoc 2024-01-29 13:53:18 +08:00 committed by arcady-lunarg
parent f6f9840eab
commit 725017a588
15 changed files with 232 additions and 3 deletions

View file

@ -0,0 +1,76 @@
spv.1.6.quad.frag
// Module Version 10600
// Generated by (magic number): 8000b
// Id's are bound by 39
Capability Shader
Capability GroupNonUniform
Capability GroupNonUniformVote
Capability QuadControlKHR
Extension "SPV_KHR_quad_control"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 16 33
ExecutionMode 4 QuadDerivativesKHR
ExecutionMode 4 RequireFullQuadsKHR
ExecutionMode 4 OriginUpperLeft
Source GLSL 460
SourceExtension "GL_EXT_shader_quad_control"
SourceExtension "GL_KHR_shader_subgroup_basic"
SourceExtension "GL_KHR_shader_subgroup_vote"
Name 4 "main"
Name 8 "bTemp"
Name 16 "iInput"
Name 33 "bOut"
Decorate 16(iInput) Flat
Decorate 16(iInput) Location 0
Decorate 33(bOut) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeBool
7: TypePointer Function 6(bool)
9: 6(bool) ConstantFalse
14: TypeInt 32 1
15: TypePointer Input 14(int)
16(iInput): 15(ptr) Variable Input
18: 14(int) Constant 0
20: TypeInt 32 0
21: 20(int) Constant 3
32: TypePointer Output 14(int)
33(bOut): 32(ptr) Variable Output
35: 6(bool) ConstantTrue
37: 14(int) Constant 1
4(main): 2 Function None 3
5: Label
8(bTemp): 7(ptr) Variable Function
Store 8(bTemp) 9
10: 6(bool) Load 8(bTemp)
11: 6(bool) LogicalNot 10
SelectionMerge 13 None
BranchConditional 11 12 13
12: Label
17: 14(int) Load 16(iInput)
19: 6(bool) SGreaterThan 17 18
22: 6(bool) GroupNonUniformQuadAllKHR 19
Branch 13
13: Label
23: 6(bool) Phi 10 5 22 12
Store 8(bTemp) 23
24: 6(bool) Load 8(bTemp)
25: 6(bool) LogicalNot 24
SelectionMerge 27 None
BranchConditional 25 26 27
26: Label
28: 14(int) Load 16(iInput)
29: 6(bool) SGreaterThan 28 18
30: 6(bool) GroupNonUniformQuadAnyKHR 29
Branch 27
27: Label
31: 6(bool) Phi 24 13 30 26
Store 8(bTemp) 31
34: 6(bool) Load 8(bTemp)
36: 6(bool) LogicalEqual 34 35
38: 14(int) Select 36 37 18
Store 33(bOut) 38
Return
FunctionEnd

21
Test/spv.1.6.quad.frag Normal file
View file

@ -0,0 +1,21 @@
#version 460 core
#extension GL_KHR_shader_subgroup_basic: require
#extension GL_EXT_shader_quad_control: require
#extension GL_KHR_shader_subgroup_vote: require
layout (full_quads) in;
layout (quad_derivatives) in;
flat in int iInput;
out int bOut;
void main(){
bool bTemp = false;
// EXT_shader_quad_control required begin
bTemp = bTemp || subgroupQuadAll(iInput > 0); // GL_KHR_shader_subgroup_vote
bTemp = bTemp || subgroupQuadAny(iInput > 0); // GL_KHR_shader_subgroup_vote
bOut = bTemp == true ? 1 : 0;
}