Commit 213bbbe4 by Dejan Mircevski

Split loop header from condition testing for for/while loops.

parent 7349eab0
...@@ -1391,12 +1391,22 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn ...@@ -1391,12 +1391,22 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn
{ {
auto blocks = builder.makeNewLoop(); auto blocks = builder.makeNewLoop();
builder.createBranch(&blocks.head); builder.createBranch(&blocks.head);
// Spec requires back edges to target header blocks, and every header block
// must dominate its merge block. Make a header block first to ensure these
// conditions are met. By definition, it will contain OpLoopMerge, followed
// by a block-ending branch. But we don't want to put any other body/test
// instructions in it, since the body/test may have arbitrary instructions,
// including merges of its own.
builder.setBuildPoint(&blocks.head);
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, spv::LoopControlMaskNone);
if (node->testFirst() && node->getTest()) { if (node->testFirst() && node->getTest()) {
builder.setBuildPoint(&blocks.head); spv::Block& test = builder.makeNewBlock();
builder.createBranch(&test);
builder.setBuildPoint(&test);
node->getTest()->traverse(this); node->getTest()->traverse(this);
spv::Id condition = spv::Id condition =
builder.accessChainLoad(convertGlslangToSpvType(node->getTest()->getType())); builder.accessChainLoad(convertGlslangToSpvType(node->getTest()->getType()));
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, spv::LoopControlMaskNone);
builder.createConditionalBranch(condition, &blocks.body, &blocks.merge); builder.createConditionalBranch(condition, &blocks.body, &blocks.merge);
builder.setBuildPoint(&blocks.body); builder.setBuildPoint(&blocks.body);
...@@ -1411,14 +1421,6 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn ...@@ -1411,14 +1421,6 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn
node->getTerminal()->traverse(this); node->getTerminal()->traverse(this);
builder.createBranch(&blocks.head); builder.createBranch(&blocks.head);
} else { } else {
// Spec requires back edges to target header blocks, and every header
// block must dominate its merge block. Make a header block first to
// ensure these conditions are met. By definition, it will contain
// OpLoopMerge, followed by a block-ending branch. But we don't want to
// put any other body instructions in it, since the body may have
// arbitrary instructions, including merges of its own.
builder.setBuildPoint(&blocks.head);
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, spv::LoopControlMaskNone);
builder.createBranch(&blocks.body); builder.createBranch(&blocks.body);
breakForLoop.push(true); breakForLoop.push(true);
......
...@@ -8,66 +8,68 @@ Linked vertex stage: ...@@ -8,66 +8,68 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 39 // Id's are bound by 40
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 24 27 33 38 EntryPoint Vertex 4 "main" 25 28 34 39
Source GLSL 130 Source GLSL 130
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 24 "colorOut" Name 25 "colorOut"
Name 27 "color" Name 28 "color"
Name 33 "gl_Position" Name 34 "gl_Position"
Name 38 "gl_VertexID" Name 39 "gl_VertexID"
Decorate 33(gl_Position) BuiltIn Position Decorate 34(gl_Position) BuiltIn Position
Decorate 38(gl_VertexID) BuiltIn VertexId Decorate 39(gl_VertexID) BuiltIn VertexId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 1 9: 6(int) Constant 1
15: 6(int) Constant 5 16: 6(int) Constant 5
16: TypeBool 17: TypeBool
18: TypeFloat 32 19: TypeFloat 32
19: TypeVector 18(float) 4 20: TypeVector 19(float) 4
20: TypeInt 32 0 21: TypeInt 32 0
21: 20(int) Constant 6 22: 21(int) Constant 6
22: TypeArray 19(fvec4) 21 23: TypeArray 20(fvec4) 22
23: TypePointer Output 22 24: TypePointer Output 23
24(colorOut): 23(ptr) Variable Output 25(colorOut): 24(ptr) Variable Output
26: TypePointer Input 19(fvec4) 27: TypePointer Input 20(fvec4)
27(color): 26(ptr) Variable Input 28(color): 27(ptr) Variable Input
29: TypePointer Output 19(fvec4) 30: TypePointer Output 20(fvec4)
33(gl_Position): 29(ptr) Variable Output 34(gl_Position): 30(ptr) Variable Output
34: 6(int) Constant 2 35: 6(int) Constant 2
37: TypePointer Input 6(int) 38: TypePointer Input 6(int)
38(gl_VertexID): 37(ptr) Variable Input 39(gl_VertexID): 38(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None LoopMerge 12 13 None
BranchConditional 17 11 12 Branch 14
14: Label
15: 6(int) Load 8(i)
18: 17(bool) SLessThan 15 16
BranchConditional 18 11 12
11: Label 11: Label
25: 6(int) Load 8(i) 26: 6(int) Load 8(i)
28: 19(fvec4) Load 27(color) 29: 20(fvec4) Load 28(color)
30: 29(ptr) AccessChain 24(colorOut) 25 31: 30(ptr) AccessChain 25(colorOut) 26
Store 30 28 Store 31 29
Branch 13 Branch 13
13: Label 13: Label
31: 6(int) Load 8(i) 32: 6(int) Load 8(i)
32: 6(int) IAdd 31 9 33: 6(int) IAdd 32 9
Store 8(i) 32 Store 8(i) 33
Branch 10 Branch 10
12: Label 12: Label
35: 29(ptr) AccessChain 24(colorOut) 34 36: 30(ptr) AccessChain 25(colorOut) 35
36: 19(fvec4) Load 35 37: 20(fvec4) Load 36
Store 33(gl_Position) 36 Store 34(gl_Position) 37
Return Return
FunctionEnd FunctionEnd
...@@ -5,86 +5,88 @@ Linked vertex stage: ...@@ -5,86 +5,88 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 47 // Id's are bound by 48
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 45 46 EntryPoint Vertex 4 "main" 46 47
Source ESSL 300 Source ESSL 300
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 18 "A" Name 19 "A"
Name 26 "B" Name 27 "B"
Name 28 "C" Name 29 "C"
Name 35 "D" Name 36 "D"
Name 37 "E" Name 38 "E"
Name 38 "F" Name 39 "F"
Name 42 "G" Name 43 "G"
Name 45 "gl_VertexID" Name 46 "gl_VertexID"
Name 46 "gl_InstanceID" Name 47 "gl_InstanceID"
Decorate 45(gl_VertexID) BuiltIn VertexId Decorate 46(gl_VertexID) BuiltIn VertexId
Decorate 46(gl_InstanceID) BuiltIn InstanceId Decorate 47(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
15: 6(int) Constant 10 16: 6(int) Constant 10
16: TypeBool 17: TypeBool
19: 6(int) Constant 1 20: 6(int) Constant 1
21: 6(int) Constant 2 22: 6(int) Constant 2
30: 6(int) Constant 3 31: 6(int) Constant 3
39: 6(int) Constant 12 40: 6(int) Constant 12
43: 6(int) Constant 99 44: 6(int) Constant 99
44: TypePointer Input 6(int) 45: TypePointer Input 6(int)
45(gl_VertexID): 44(ptr) Variable Input 46(gl_VertexID): 45(ptr) Variable Input
46(gl_InstanceID): 44(ptr) Variable Input 47(gl_InstanceID): 45(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
18(A): 7(ptr) Variable Function 19(A): 7(ptr) Variable Function
26(B): 7(ptr) Variable Function 27(B): 7(ptr) Variable Function
28(C): 7(ptr) Variable Function 29(C): 7(ptr) Variable Function
35(D): 7(ptr) Variable Function 36(D): 7(ptr) Variable Function
37(E): 7(ptr) Variable Function 38(E): 7(ptr) Variable Function
38(F): 7(ptr) Variable Function 39(F): 7(ptr) Variable Function
42(G): 7(ptr) Variable Function 43(G): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None LoopMerge 12 13 None
BranchConditional 17 11 12 Branch 14
14: Label
15: 6(int) Load 8(i)
18: 17(bool) SLessThan 15 16
BranchConditional 18 11 12
11: Label 11: Label
Store 18(A) 19 Store 19(A) 20
20: 6(int) Load 8(i) 21: 6(int) Load 8(i)
22: 6(int) SMod 20 21 23: 6(int) SMod 21 22
23: 16(bool) IEqual 22 9 24: 17(bool) IEqual 23 9
SelectionMerge 25 None SelectionMerge 26 None
BranchConditional 23 24 25 BranchConditional 24 25 26
24: Label 25: Label
Store 26(B) 19 Store 27(B) 20
Branch 13 Branch 13
25: Label 26: Label
29: 6(int) Load 8(i) 30: 6(int) Load 8(i)
31: 6(int) SMod 29 30 32: 6(int) SMod 30 31
32: 16(bool) IEqual 31 9 33: 17(bool) IEqual 32 9
SelectionMerge 34 None SelectionMerge 35 None
BranchConditional 32 33 34 BranchConditional 33 34 35
33: Label 34: Label
Store 35(D) 19 Store 36(D) 20
Branch 12 Branch 12
34: Label 35: Label
Store 38(F) 39 Store 39(F) 40
Branch 13 Branch 13
13: Label 13: Label
40: 6(int) Load 8(i) 41: 6(int) Load 8(i)
41: 6(int) IAdd 40 19 42: 6(int) IAdd 41 20
Store 8(i) 41 Store 8(i) 42
Branch 10 Branch 10
12: Label 12: Label
Store 42(G) 43 Store 43(G) 44
Return Return
FunctionEnd FunctionEnd
...@@ -7,53 +7,55 @@ Linked vertex stage: ...@@ -7,53 +7,55 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 27 // Id's are bound by 28
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 22 25 26 EntryPoint Vertex 4 "main" 23 26 27
Source GLSL 450 Source GLSL 450
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 22 "r" Name 23 "r"
Name 25 "gl_VertexID" Name 26 "gl_VertexID"
Name 26 "gl_InstanceID" Name 27 "gl_InstanceID"
Decorate 22(r) Location 0 Decorate 23(r) Location 0
Decorate 25(gl_VertexID) BuiltIn VertexId Decorate 26(gl_VertexID) BuiltIn VertexId
Decorate 26(gl_InstanceID) BuiltIn InstanceId Decorate 27(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
15: 6(int) Constant 10 16: 6(int) Constant 10
16: TypeBool 17: TypeBool
19: 6(int) Constant 1 20: 6(int) Constant 1
21: TypePointer Output 6(int) 22: TypePointer Output 6(int)
22(r): 21(ptr) Variable Output 23(r): 22(ptr) Variable Output
24: TypePointer Input 6(int) 25: TypePointer Input 6(int)
25(gl_VertexID): 24(ptr) Variable Input 26(gl_VertexID): 25(ptr) Variable Input
26(gl_InstanceID): 24(ptr) Variable Input 27(gl_InstanceID): 25(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None LoopMerge 12 13 None
BranchConditional 17 11 12 Branch 14
14: Label
15: 6(int) Load 8(i)
18: 17(bool) SLessThan 15 16
BranchConditional 18 11 12
11: Label 11: Label
Branch 13 Branch 13
13: Label 13: Label
18: 6(int) Load 8(i) 19: 6(int) Load 8(i)
20: 6(int) IAdd 18 19 21: 6(int) IAdd 19 20
Store 8(i) 20 Store 8(i) 21
Branch 10 Branch 10
12: Label 12: Label
23: 6(int) Load 8(i) 24: 6(int) Load 8(i)
Store 22(r) 23 Store 23(r) 24
Return Return
FunctionEnd FunctionEnd
...@@ -5,50 +5,52 @@ Linked vertex stage: ...@@ -5,50 +5,52 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 26 // Id's are bound by 27
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 24 25 EntryPoint Vertex 4 "main" 25 26
Source ESSL 300 Source ESSL 300
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 18 "j" Name 19 "j"
Name 24 "gl_VertexID" Name 25 "gl_VertexID"
Name 25 "gl_InstanceID" Name 26 "gl_InstanceID"
Decorate 24(gl_VertexID) BuiltIn VertexId Decorate 25(gl_VertexID) BuiltIn VertexId
Decorate 25(gl_InstanceID) BuiltIn InstanceId Decorate 26(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
15: 6(int) Constant 10 16: 6(int) Constant 10
16: TypeBool 17: TypeBool
19: 6(int) Constant 12 20: 6(int) Constant 12
21: 6(int) Constant 1 22: 6(int) Constant 1
23: TypePointer Input 6(int) 24: TypePointer Input 6(int)
24(gl_VertexID): 23(ptr) Variable Input 25(gl_VertexID): 24(ptr) Variable Input
25(gl_InstanceID): 23(ptr) Variable Input 26(gl_InstanceID): 24(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
18(j): 7(ptr) Variable Function 19(j): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None LoopMerge 12 13 None
BranchConditional 17 11 12 Branch 14
14: Label
15: 6(int) Load 8(i)
18: 17(bool) SLessThan 15 16
BranchConditional 18 11 12
11: Label 11: Label
Store 18(j) 19 Store 19(j) 20
Branch 13 Branch 13
13: Label 13: Label
20: 6(int) Load 8(i) 21: 6(int) Load 8(i)
22: 6(int) IAdd 20 21 23: 6(int) IAdd 21 22
Store 8(i) 22 Store 8(i) 23
Branch 10 Branch 10
12: Label 12: Label
Return Return
......
...@@ -8,12 +8,12 @@ Linked fragment stage: ...@@ -8,12 +8,12 @@ Linked fragment stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 137 // Id's are bound by 138
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 40 97 107 EntryPoint Fragment 4 "main" 40 98 108
ExecutionMode 4 OriginLowerLeft ExecutionMode 4 OriginLowerLeft
Source GLSL 130 Source GLSL 130
Name 4 "main" Name 4 "main"
...@@ -38,14 +38,14 @@ Linked fragment stage: ...@@ -38,14 +38,14 @@ Linked fragment stage:
Name 68 "x" Name 68 "x"
Name 70 "localArray" Name 70 "localArray"
Name 75 "i" Name 75 "i"
Name 83 "a" Name 84 "a"
Name 89 "condition" Name 90 "condition"
Name 97 "color" Name 98 "color"
Name 107 "gl_FragColor" Name 108 "gl_FragColor"
Name 127 "samp2D" Name 128 "samp2D"
Name 133 "foo" Name 134 "foo"
Name 134 "foo2" Name 135 "foo2"
Name 136 "uFloatArray" Name 137 "uFloatArray"
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
...@@ -80,26 +80,26 @@ Linked fragment stage: ...@@ -80,26 +80,26 @@ Linked fragment stage:
48: TypePointer Function 47 48: TypePointer Function 47
52: TypePointer Function 6(int) 52: TypePointer Function 6(int)
69: 6(int) Constant 5 69: 6(int) Constant 5
81: 6(int) Constant 16 82: 6(int) Constant 16
85: 7(float) Constant 0 86: 7(float) Constant 0
89(condition): 20(ptr) Variable UniformConstant 90(condition): 20(ptr) Variable UniformConstant
95: 6(int) Constant 3 96: 6(int) Constant 3
96: TypePointer Input 9(fvec4) 97: TypePointer Input 9(fvec4)
97(color): 96(ptr) Variable Input 98(color): 97(ptr) Variable Input
99: TypePointer Function 9(fvec4) 100: TypePointer Function 9(fvec4)
101: 32(int) Constant 1 102: 32(int) Constant 1
104: 32(int) Constant 2 105: 32(int) Constant 2
106: TypePointer Output 9(fvec4) 107: TypePointer Output 9(fvec4)
107(gl_FragColor): 106(ptr) Variable Output 108(gl_FragColor): 107(ptr) Variable Output
124: TypeImage 7(float) 2D sampled format:Unknown 125: TypeImage 7(float) 2D sampled format:Unknown
125: TypeSampledImage 124 126: TypeSampledImage 125
126: TypePointer UniformConstant 125 127: TypePointer UniformConstant 126
127(samp2D): 126(ptr) Variable UniformConstant 128(samp2D): 127(ptr) Variable UniformConstant
132: TypePointer UniformConstant 8(s1) 133: TypePointer UniformConstant 8(s1)
133(foo): 132(ptr) Variable UniformConstant 134(foo): 133(ptr) Variable UniformConstant
134(foo2): 17(ptr) Variable UniformConstant 135(foo2): 17(ptr) Variable UniformConstant
135: TypePointer UniformConstant 34 136: TypePointer UniformConstant 34
136(uFloatArray): 135(ptr) Variable UniformConstant 137(uFloatArray): 136(ptr) Variable UniformConstant
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
12(locals2): 11(ptr) Variable Function 12(locals2): 11(ptr) Variable Function
...@@ -108,7 +108,7 @@ Linked fragment stage: ...@@ -108,7 +108,7 @@ Linked fragment stage:
68(x): 52(ptr) Variable Function 68(x): 52(ptr) Variable Function
70(localArray): 35(ptr) Variable Function 70(localArray): 35(ptr) Variable Function
75(i): 52(ptr) Variable Function 75(i): 52(ptr) Variable Function
83(a): 35(ptr) Variable Function 84(a): 35(ptr) Variable Function
18: 17(ptr) AccessChain 15(foo3) 16 18: 17(ptr) AccessChain 15(foo3) 16
19: 10(s2) Load 18 19: 10(s2) Load 18
Store 12(locals2) 19 Store 12(locals2) 19
...@@ -161,57 +161,59 @@ Linked fragment stage: ...@@ -161,57 +161,59 @@ Linked fragment stage:
Store 75(i) 16 Store 75(i) 16
Branch 76 Branch 76
76: Label 76: Label
80: 6(int) Load 75(i)
82: 23(bool) SLessThan 80 81
LoopMerge 78 79 None LoopMerge 78 79 None
BranchConditional 82 77 78 Branch 80
80: Label
81: 6(int) Load 75(i)
83: 23(bool) SLessThan 81 82
BranchConditional 83 77 78
77: Label 77: Label
84: 6(int) Load 75(i) 85: 6(int) Load 75(i)
86: 30(ptr) AccessChain 83(a) 84 87: 30(ptr) AccessChain 84(a) 85
Store 86 85 Store 87 86
Branch 79 Branch 79
79: Label 79: Label
87: 6(int) Load 75(i) 88: 6(int) Load 75(i)
88: 6(int) IAdd 87 28 89: 6(int) IAdd 88 28
Store 75(i) 88 Store 75(i) 89
Branch 76 Branch 76
78: Label 78: Label
90: 6(int) Load 89(condition) 91: 6(int) Load 90(condition)
91: 23(bool) IEqual 90 28 92: 23(bool) IEqual 91 28
SelectionMerge 93 None SelectionMerge 94 None
BranchConditional 91 92 93 BranchConditional 92 93 94
92: Label 93: Label
94: 34 Load 70(localArray) 95: 34 Load 70(localArray)
Store 83(a) 94 Store 84(a) 95
Branch 93 Branch 94
93: Label 94: Label
98: 9(fvec4) Load 97(color) 99: 9(fvec4) Load 98(color)
100: 99(ptr) AccessChain 12(locals2) 95 101: 100(ptr) AccessChain 12(locals2) 96
Store 100 98 Store 101 99
102: 42(ptr) AccessChain 40(coord) 101 103: 42(ptr) AccessChain 40(coord) 102
103: 7(float) Load 102 104: 7(float) Load 103
105: 30(ptr) AccessChain 12(locals2) 95 104 106: 30(ptr) AccessChain 12(locals2) 96 105
Store 105 103 Store 106 104
108: 99(ptr) AccessChain 12(locals2) 95 109: 100(ptr) AccessChain 12(locals2) 96
109: 9(fvec4) Load 108 110: 9(fvec4) Load 109
110: 30(ptr) AccessChain 36(localFArray) 37 111: 30(ptr) AccessChain 36(localFArray) 37
111: 7(float) Load 110 112: 7(float) Load 111
112: 30(ptr) AccessChain 12(locals2) 27 28 113: 30(ptr) AccessChain 12(locals2) 27 28
113: 7(float) Load 112 114: 7(float) Load 113
114: 7(float) FAdd 111 113 115: 7(float) FAdd 112 114
115: 6(int) Load 68(x) 116: 6(int) Load 68(x)
116: 30(ptr) AccessChain 70(localArray) 115 117: 30(ptr) AccessChain 70(localArray) 116
117: 7(float) Load 116 118: 7(float) Load 117
118: 7(float) FAdd 114 117 119: 7(float) FAdd 115 118
119: 6(int) Load 68(x) 120: 6(int) Load 68(x)
120: 30(ptr) AccessChain 83(a) 119 121: 30(ptr) AccessChain 84(a) 120
121: 7(float) Load 120 122: 7(float) Load 121
122: 7(float) FAdd 118 121 123: 7(float) FAdd 119 122
123: 9(fvec4) VectorTimesScalar 109 122 124: 9(fvec4) VectorTimesScalar 110 123
128: 125 Load 127(samp2D) 129: 126 Load 128(samp2D)
129: 38(fvec2) Load 40(coord) 130: 38(fvec2) Load 40(coord)
130: 9(fvec4) ImageSampleImplicitLod 128 129 131: 9(fvec4) ImageSampleImplicitLod 129 130
131: 9(fvec4) FMul 123 130 132: 9(fvec4) FMul 124 131
Store 107(gl_FragColor) 131 Store 108(gl_FragColor) 132
Return Return
FunctionEnd FunctionEnd
...@@ -5,78 +5,80 @@ Linked vertex stage: ...@@ -5,78 +5,80 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 43 // Id's are bound by 44
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 41 42 EntryPoint Vertex 4 "main" 42 43
Source ESSL 300 Source ESSL 300
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 18 "A" Name 19 "A"
Name 26 "B" Name 27 "B"
Name 28 "C" Name 29 "C"
Name 38 "D" Name 39 "D"
Name 41 "gl_VertexID" Name 42 "gl_VertexID"
Name 42 "gl_InstanceID" Name 43 "gl_InstanceID"
Decorate 41(gl_VertexID) BuiltIn VertexId Decorate 42(gl_VertexID) BuiltIn VertexId
Decorate 42(gl_InstanceID) BuiltIn InstanceId Decorate 43(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
15: 6(int) Constant 10 16: 6(int) Constant 10
16: TypeBool 17: TypeBool
19: 6(int) Constant 1 20: 6(int) Constant 1
21: 6(int) Constant 2 22: 6(int) Constant 2
30: 6(int) Constant 5 31: 6(int) Constant 5
39: 6(int) Constant 3 40: 6(int) Constant 3
40: TypePointer Input 6(int) 41: TypePointer Input 6(int)
41(gl_VertexID): 40(ptr) Variable Input 42(gl_VertexID): 41(ptr) Variable Input
42(gl_InstanceID): 40(ptr) Variable Input 43(gl_InstanceID): 41(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
18(A): 7(ptr) Variable Function 19(A): 7(ptr) Variable Function
26(B): 7(ptr) Variable Function 27(B): 7(ptr) Variable Function
28(C): 7(ptr) Variable Function 29(C): 7(ptr) Variable Function
38(D): 7(ptr) Variable Function 39(D): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None LoopMerge 12 13 None
BranchConditional 17 11 12 Branch 14
14: Label
15: 6(int) Load 8(i)
18: 17(bool) SLessThan 15 16
BranchConditional 18 11 12
11: Label 11: Label
Store 18(A) 19 Store 19(A) 20
20: 6(int) Load 8(i) 21: 6(int) Load 8(i)
22: 6(int) SMod 20 21 23: 6(int) SMod 21 22
23: 16(bool) IEqual 22 9 24: 17(bool) IEqual 23 9
SelectionMerge 25 None SelectionMerge 26 None
BranchConditional 23 24 25 BranchConditional 24 25 26
24: Label 25: Label
Store 26(B) 21 Store 27(B) 22
Branch 13 Branch 13
25: Label 26: Label
29: 6(int) Load 8(i) 30: 6(int) Load 8(i)
31: 6(int) SMod 29 30 32: 6(int) SMod 30 31
32: 16(bool) IEqual 31 9 33: 17(bool) IEqual 32 9
SelectionMerge 34 None SelectionMerge 35 None
BranchConditional 32 33 34 BranchConditional 33 34 35
33: Label 34: Label
Store 26(B) 21 Store 27(B) 22
Branch 12 Branch 12
34: Label 35: Label
36: 6(int) Load 8(i) 37: 6(int) Load 8(i)
37: 6(int) IAdd 36 19 38: 6(int) IAdd 37 20
Store 8(i) 37 Store 8(i) 38
Branch 13 Branch 13
13: Label 13: Label
Branch 10 Branch 10
12: Label 12: Label
Store 38(D) 39 Store 39(D) 40
Return Return
FunctionEnd FunctionEnd
...@@ -5,44 +5,46 @@ Linked vertex stage: ...@@ -5,44 +5,46 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 24 // Id's are bound by 25
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 22 23 EntryPoint Vertex 4 "main" 23 24
Source ESSL 300 Source ESSL 300
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 22 "gl_VertexID" Name 23 "gl_VertexID"
Name 23 "gl_InstanceID" Name 24 "gl_InstanceID"
Decorate 22(gl_VertexID) BuiltIn VertexId Decorate 23(gl_VertexID) BuiltIn VertexId
Decorate 23(gl_InstanceID) BuiltIn InstanceId Decorate 24(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
15: 6(int) Constant 10 16: 6(int) Constant 10
16: TypeBool 17: TypeBool
19: 6(int) Constant 1 20: 6(int) Constant 1
21: TypePointer Input 6(int) 22: TypePointer Input 6(int)
22(gl_VertexID): 21(ptr) Variable Input 23(gl_VertexID): 22(ptr) Variable Input
23(gl_InstanceID): 21(ptr) Variable Input 24(gl_InstanceID): 22(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None LoopMerge 12 13 None
BranchConditional 17 11 12 Branch 14
14: Label
15: 6(int) Load 8(i)
18: 17(bool) SLessThan 15 16
BranchConditional 18 11 12
11: Label 11: Label
18: 6(int) Load 8(i) 19: 6(int) Load 8(i)
20: 6(int) IAdd 18 19 21: 6(int) IAdd 19 20
Store 8(i) 20 Store 8(i) 21
Branch 13 Branch 13
13: Label 13: Label
Branch 10 Branch 10
......
...@@ -5,20 +5,20 @@ Linked fragment stage: ...@@ -5,20 +5,20 @@ Linked fragment stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 35 // Id's are bound by 36
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 11 33 EntryPoint Fragment 4 "main" 11 34
ExecutionMode 4 OriginLowerLeft ExecutionMode 4 OriginLowerLeft
Source GLSL 110 Source GLSL 110
Name 4 "main" Name 4 "main"
Name 9 "color" Name 9 "color"
Name 11 "BaseColor" Name 11 "BaseColor"
Name 23 "d" Name 24 "d"
Name 28 "bigColor" Name 29 "bigColor"
Name 33 "gl_FragColor" Name 34 "gl_FragColor"
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
...@@ -26,16 +26,16 @@ Linked fragment stage: ...@@ -26,16 +26,16 @@ Linked fragment stage:
8: TypePointer Function 7(fvec4) 8: TypePointer Function 7(fvec4)
10: TypePointer Input 7(fvec4) 10: TypePointer Input 7(fvec4)
11(BaseColor): 10(ptr) Variable Input 11(BaseColor): 10(ptr) Variable Input
17: TypeInt 32 0 18: TypeInt 32 0
18: 17(int) Constant 0 19: 18(int) Constant 0
19: TypePointer Function 6(float) 20: TypePointer Function 6(float)
22: TypePointer UniformConstant 6(float) 23: TypePointer UniformConstant 6(float)
23(d): 22(ptr) Variable UniformConstant 24(d): 23(ptr) Variable UniformConstant
25: TypeBool 26: TypeBool
27: TypePointer UniformConstant 7(fvec4) 28: TypePointer UniformConstant 7(fvec4)
28(bigColor): 27(ptr) Variable UniformConstant 29(bigColor): 28(ptr) Variable UniformConstant
32: TypePointer Output 7(fvec4) 33: TypePointer Output 7(fvec4)
33(gl_FragColor): 32(ptr) Variable Output 34(gl_FragColor): 33(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
9(color): 8(ptr) Variable Function 9(color): 8(ptr) Variable Function
...@@ -43,22 +43,24 @@ Linked fragment stage: ...@@ -43,22 +43,24 @@ Linked fragment stage:
Store 9(color) 12 Store 9(color) 12
Branch 13 Branch 13
13: Label 13: Label
20: 19(ptr) AccessChain 9(color) 18
21: 6(float) Load 20
24: 6(float) Load 23(d)
26: 25(bool) FOrdLessThan 21 24
LoopMerge 15 16 None LoopMerge 15 16 None
BranchConditional 26 14 15 Branch 17
17: Label
21: 20(ptr) AccessChain 9(color) 19
22: 6(float) Load 21
25: 6(float) Load 24(d)
27: 26(bool) FOrdLessThan 22 25
BranchConditional 27 14 15
14: Label 14: Label
29: 7(fvec4) Load 28(bigColor) 30: 7(fvec4) Load 29(bigColor)
30: 7(fvec4) Load 9(color) 31: 7(fvec4) Load 9(color)
31: 7(fvec4) FAdd 30 29 32: 7(fvec4) FAdd 31 30
Store 9(color) 31 Store 9(color) 32
Branch 16 Branch 16
16: Label 16: Label
Branch 13 Branch 13
15: Label 15: Label
34: 7(fvec4) Load 9(color) 35: 7(fvec4) Load 9(color)
Store 33(gl_FragColor) 34 Store 34(gl_FragColor) 35
Return Return
FunctionEnd FunctionEnd
...@@ -2,8 +2,5 @@ ...@@ -2,8 +2,5 @@
layout(location=0) out highp int r; layout(location=0) out highp int r;
void main() { void main() {
int i; int i;
// This infinite loop results in bad SPIR-V generated, since the merge block
// is dropped as unreachable. It is still useful for testing the rest of the
// code generation.
for (i=0; ; i++) { r = i; } for (i=0; ; i++) { r = i; }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment