SPV return from main: Simplify a legacy design such returns are not jumps to exit block.

Structured control-flow rules allow leaving the middle of a construct through
a return, but not through a jump to a block that does a return.

Addresses issue #58.
This commit is contained in:
John Kessenich 2015-09-14 20:58:02 -06:00
parent 5f5b205ce9
commit e770b3e6cf
74 changed files with 9648 additions and 9816 deletions

View file

@ -5,7 +5,7 @@ Linked fragment stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 207
// Id's are bound by 206
Source ESSL 300
Capability Shader
@ -14,344 +14,342 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 9 "count"
Name 13 "u"
Name 16 "t"
Name 54 "shiftedii"
Name 56 "shiftedui"
Name 58 "shiftediu"
Name 59 "shifteduu"
Name 67 "c"
Name 71 "usampler"
Name 76 "tc"
Name 109 "af"
Name 113 "ab"
Name 117 "ai"
Name 152 "mask1"
Name 154 "mask2"
Name 156 "mask3"
Name 160 "mask4"
Name 200 "f"
Name 202 "v"
Name 204 "i"
Name 206 "b"
Decorate 9(count) RelaxedPrecision
Decorate 13(u) RelaxedPrecision
Decorate 16(t) RelaxedPrecision
Decorate 16(t) Flat
Decorate 54(shiftedii) RelaxedPrecision
Decorate 56(shiftedui) RelaxedPrecision
Decorate 58(shiftediu) RelaxedPrecision
Decorate 59(shifteduu) RelaxedPrecision
Decorate 67(c) RelaxedPrecision
Decorate 71(usampler) RelaxedPrecision
Decorate 76(tc) RelaxedPrecision
Decorate 76(tc) Smooth
Decorate 109(af) RelaxedPrecision
Decorate 117(ai) RelaxedPrecision
Decorate 152(mask1) RelaxedPrecision
Decorate 154(mask2) RelaxedPrecision
Decorate 156(mask3) RelaxedPrecision
Decorate 160(mask4) RelaxedPrecision
Decorate 200(f) RelaxedPrecision
Decorate 200(f) Smooth
Decorate 200(f) NoStaticUse
Decorate 202(v) RelaxedPrecision
Decorate 202(v) NoStaticUse
Decorate 204(i) RelaxedPrecision
Decorate 204(i) NoStaticUse
Decorate 206(b) NoStaticUse
Name 8 "count"
Name 12 "u"
Name 15 "t"
Name 53 "shiftedii"
Name 55 "shiftedui"
Name 57 "shiftediu"
Name 58 "shifteduu"
Name 66 "c"
Name 70 "usampler"
Name 75 "tc"
Name 108 "af"
Name 112 "ab"
Name 116 "ai"
Name 151 "mask1"
Name 153 "mask2"
Name 155 "mask3"
Name 159 "mask4"
Name 199 "f"
Name 201 "v"
Name 203 "i"
Name 205 "b"
Decorate 8(count) RelaxedPrecision
Decorate 12(u) RelaxedPrecision
Decorate 15(t) RelaxedPrecision
Decorate 15(t) Flat
Decorate 53(shiftedii) RelaxedPrecision
Decorate 55(shiftedui) RelaxedPrecision
Decorate 57(shiftediu) RelaxedPrecision
Decorate 58(shifteduu) RelaxedPrecision
Decorate 66(c) RelaxedPrecision
Decorate 70(usampler) RelaxedPrecision
Decorate 75(tc) RelaxedPrecision
Decorate 75(tc) Smooth
Decorate 108(af) RelaxedPrecision
Decorate 116(ai) RelaxedPrecision
Decorate 151(mask1) RelaxedPrecision
Decorate 153(mask2) RelaxedPrecision
Decorate 155(mask3) RelaxedPrecision
Decorate 159(mask4) RelaxedPrecision
Decorate 199(f) RelaxedPrecision
Decorate 199(f) Smooth
Decorate 199(f) NoStaticUse
Decorate 201(v) RelaxedPrecision
Decorate 201(v) NoStaticUse
Decorate 203(i) RelaxedPrecision
Decorate 203(i) NoStaticUse
Decorate 205(b) NoStaticUse
2: TypeVoid
3: TypeFunction 2
7: TypeInt 32 1
8: TypePointer Function 7(int)
10: 7(int) Constant 1
11: TypeInt 32 0
12: TypePointer Function 11(int)
14: TypeVector 11(int) 2
15: TypePointer Input 14(ivec2)
16(t): 15(ptr) Variable Input
19: 11(int) Constant 3
21: TypeBool
22: 21(bool) ConstantTrue
25: 7(int) Constant 2
30: 7(int) Constant 3
33: 21(bool) ConstantFalse
36: 7(int) Constant 5
41: 7(int) Constant 7
46: 7(int) Constant 11
51: 7(int) Constant 13
55: 7(int) Constant 4294967295
57: 11(int) Constant 4194303
65: TypeVector 11(int) 4
66: TypePointer Output 65(ivec4)
67(c): 66(ptr) Variable Output
68: TypeImage 11(int) 2D sampled format:Unknown
69: TypeSampledImage 68
70: TypePointer UniformConstant 69
71(usampler): 70(ptr) Variable UniformConstant
73: TypeFloat 32
74: TypeVector 73(float) 2
75: TypePointer Input 74(fvec2)
76(tc): 75(ptr) Variable Input
86: 73(float) Constant 1065353216
98: 73(float) Constant 1073741824
99: 74(fvec2) ConstantComposite 98 98
104: 11(int) Constant 4
108: TypePointer Function 73(float)
112: TypePointer Function 21(bool)
115: 11(int) Constant 0
123: 11(int) Constant 1
134: 7(int) Constant 17
139: 7(int) Constant 19
144: 7(int) Constant 23
149: 7(int) Constant 27
153: 11(int) Constant 161
155: 11(int) Constant 2576
158: 7(int) Constant 4
161: 11(int) Constant 2737
199: TypePointer Input 73(float)
200(f): 199(ptr) Variable Input
201: TypePointer UniformConstant 65(ivec4)
202(v): 201(ptr) Variable UniformConstant
203: TypePointer UniformConstant 7(int)
204(i): 203(ptr) Variable UniformConstant
205: TypePointer UniformConstant 21(bool)
206(b): 205(ptr) Variable UniformConstant
6: TypeInt 32 1
7: TypePointer Function 6(int)
9: 6(int) Constant 1
10: TypeInt 32 0
11: TypePointer Function 10(int)
13: TypeVector 10(int) 2
14: TypePointer Input 13(ivec2)
15(t): 14(ptr) Variable Input
18: 10(int) Constant 3
20: TypeBool
21: 20(bool) ConstantTrue
24: 6(int) Constant 2
29: 6(int) Constant 3
32: 20(bool) ConstantFalse
35: 6(int) Constant 5
40: 6(int) Constant 7
45: 6(int) Constant 11
50: 6(int) Constant 13
54: 6(int) Constant 4294967295
56: 10(int) Constant 4194303
64: TypeVector 10(int) 4
65: TypePointer Output 64(ivec4)
66(c): 65(ptr) Variable Output
67: TypeImage 10(int) 2D sampled format:Unknown
68: TypeSampledImage 67
69: TypePointer UniformConstant 68
70(usampler): 69(ptr) Variable UniformConstant
72: TypeFloat 32
73: TypeVector 72(float) 2
74: TypePointer Input 73(fvec2)
75(tc): 74(ptr) Variable Input
85: 72(float) Constant 1065353216
97: 72(float) Constant 1073741824
98: 73(fvec2) ConstantComposite 97 97
103: 10(int) Constant 4
107: TypePointer Function 72(float)
111: TypePointer Function 20(bool)
114: 10(int) Constant 0
122: 10(int) Constant 1
133: 6(int) Constant 17
138: 6(int) Constant 19
143: 6(int) Constant 23
148: 6(int) Constant 27
152: 10(int) Constant 161
154: 10(int) Constant 2576
157: 6(int) Constant 4
160: 10(int) Constant 2737
198: TypePointer Input 72(float)
199(f): 198(ptr) Variable Input
200: TypePointer UniformConstant 64(ivec4)
201(v): 200(ptr) Variable UniformConstant
202: TypePointer UniformConstant 6(int)
203(i): 202(ptr) Variable UniformConstant
204: TypePointer UniformConstant 20(bool)
205(b): 204(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
9(count): 8(ptr) Variable Function
13(u): 12(ptr) Variable Function
54(shiftedii): 8(ptr) Variable Function
56(shiftedui): 12(ptr) Variable Function
58(shiftediu): 8(ptr) Variable Function
59(shifteduu): 12(ptr) Variable Function
109(af): 108(ptr) Variable Function
113(ab): 112(ptr) Variable Function
117(ai): 8(ptr) Variable Function
152(mask1): 12(ptr) Variable Function
154(mask2): 12(ptr) Variable Function
156(mask3): 12(ptr) Variable Function
160(mask4): 12(ptr) Variable Function
Store 9(count) 10
17: 14(ivec2) Load 16(t)
18: 11(int) CompositeExtract 17 1
20: 11(int) IAdd 18 19
Store 13(u) 20
SelectionMerge 24 None
BranchConditional 22 23 24
23: Label
26: 7(int) Load 9(count)
27: 7(int) IMul 26 25
Store 9(count) 27
Branch 24
24: Label
SelectionMerge 29 None
BranchConditional 22 28 29
28: Label
31: 7(int) Load 9(count)
32: 7(int) IMul 31 30
Store 9(count) 32
Branch 29
29: Label
SelectionMerge 35 None
BranchConditional 33 34 35
34: Label
37: 7(int) Load 9(count)
38: 7(int) IMul 37 36
Store 9(count) 38
Branch 35
35: Label
SelectionMerge 40 None
BranchConditional 22 39 40
39: Label
42: 7(int) Load 9(count)
43: 7(int) IMul 42 41
Store 9(count) 43
Branch 40
40: Label
SelectionMerge 45 None
BranchConditional 22 44 45
44: Label
47: 7(int) Load 9(count)
48: 7(int) IMul 47 46
Store 9(count) 48
Branch 45
45: Label
SelectionMerge 50 None
BranchConditional 33 49 50
49: Label
52: 7(int) Load 9(count)
53: 7(int) IMul 52 51
Store 9(count) 53
Branch 50
50: Label
Store 54(shiftedii) 55
Store 56(shiftedui) 57
Store 58(shiftediu) 55
Store 59(shifteduu) 57
60: 7(int) Load 54(shiftedii)
61: 7(int) Load 58(shiftediu)
62: 21(bool) IEqual 60 61
SelectionMerge 64 None
BranchConditional 62 63 64
63: Label
72: 69 Load 71(usampler)
77: 74(fvec2) Load 76(tc)
78: 65(ivec4) ImageSampleImplicitLod 72 77
Store 67(c) 78
Branch 64
64: Label
79: 11(int) Load 56(shiftedui)
80: 11(int) Load 59(shifteduu)
81: 21(bool) IEqual 79 80
SelectionMerge 83 None
BranchConditional 81 82 83
82: Label
84: 69 Load 71(usampler)
85: 74(fvec2) Load 76(tc)
87: 74(fvec2) CompositeConstruct 86 86
88: 74(fvec2) FAdd 85 87
89: 65(ivec4) ImageSampleImplicitLod 84 88
Store 67(c) 89
Branch 83
83: Label
90: 7(int) Load 54(shiftedii)
91: 11(int) Load 56(shiftedui)
92: 7(int) Bitcast 91
93: 21(bool) IEqual 90 92
SelectionMerge 95 None
BranchConditional 93 94 95
94: Label
96: 69 Load 71(usampler)
97: 74(fvec2) Load 76(tc)
100: 74(fvec2) FSub 97 99
101: 65(ivec4) ImageSampleImplicitLod 96 100
Store 67(c) 101
Branch 95
95: Label
102: 14(ivec2) Load 16(t)
103: 11(int) CompositeExtract 102 0
105: 21(bool) UGreaterThan 103 104
SelectionMerge 107 None
BranchConditional 105 106 107
106: Label
110: 11(int) Load 13(u)
111: 73(float) ConvertUToF 110
Store 109(af) 111
114: 11(int) Load 13(u)
116: 21(bool) INotEqual 114 115
Store 113(ab) 116
118: 11(int) Load 13(u)
119: 7(int) Bitcast 118
Store 117(ai) 119
120: 73(float) Load 109(af)
121: 11(int) ConvertFToU 120
122: 21(bool) Load 113(ab)
124: 11(int) Select 122 123 115
125: 7(int) Load 117(ai)
126: 11(int) Bitcast 125
127: 7(int) Load 9(count)
128: 11(int) Bitcast 127
129: 65(ivec4) CompositeConstruct 121 124 126 128
130: 65(ivec4) Load 67(c)
131: 65(ivec4) IAdd 130 129
Store 67(c) 131
Branch 107
107: Label
SelectionMerge 133 None
BranchConditional 22 132 133
132: Label
135: 7(int) Load 9(count)
136: 7(int) IMul 135 134
Store 9(count) 136
Branch 133
133: Label
SelectionMerge 138 None
BranchConditional 33 137 138
137: Label
140: 7(int) Load 9(count)
141: 7(int) IMul 140 139
Store 9(count) 141
Branch 138
138: Label
SelectionMerge 143 None
BranchConditional 22 142 143
142: Label
145: 7(int) Load 9(count)
146: 7(int) IMul 145 144
Store 9(count) 146
Branch 143
143: Label
SelectionMerge 148 None
BranchConditional 22 147 148
147: Label
150: 7(int) Load 9(count)
151: 7(int) IMul 150 149
Store 9(count) 151
Branch 148
148: Label
Store 152(mask1) 153
Store 154(mask2) 155
157: 11(int) Load 152(mask1)
159: 11(int) ShiftLeftLogical 157 158
Store 156(mask3) 159
Store 160(mask4) 161
162: 11(int) Load 156(mask3)
163: 11(int) Load 154(mask2)
164: 21(bool) IEqual 162 163
SelectionMerge 166 None
BranchConditional 164 165 166
165: Label
167: 7(int) Load 9(count)
168: 7(int) IMul 167 25
Store 9(count) 168
Branch 166
166: Label
169: 11(int) Load 156(mask3)
170: 11(int) Load 152(mask1)
171: 11(int) BitwiseAnd 169 170
172: 21(bool) INotEqual 171 115
SelectionMerge 174 None
BranchConditional 172 173 174
173: Label
175: 7(int) Load 9(count)
176: 7(int) IMul 175 30
Store 9(count) 176
Branch 174
174: Label
177: 11(int) Load 152(mask1)
178: 11(int) Load 156(mask3)
179: 11(int) BitwiseOr 177 178
180: 11(int) Load 160(mask4)
181: 21(bool) IEqual 179 180
SelectionMerge 183 None
BranchConditional 181 182 183
182: Label
184: 7(int) Load 9(count)
185: 7(int) IMul 184 36
Store 9(count) 185
Branch 183
183: Label
186: 11(int) Load 152(mask1)
187: 11(int) Load 160(mask4)
188: 11(int) BitwiseXor 186 187
189: 21(bool) IEqual 188 155
SelectionMerge 191 None
BranchConditional 189 190 191
190: Label
192: 7(int) Load 9(count)
193: 7(int) IMul 192 41
Store 9(count) 193
Branch 191
191: Label
194: 7(int) Load 9(count)
195: 11(int) Bitcast 194
196: 65(ivec4) CompositeConstruct 195 195 195 195
197: 65(ivec4) Load 67(c)
198: 65(ivec4) IAdd 197 196
Store 67(c) 198
Branch 6
6: Label
8(count): 7(ptr) Variable Function
12(u): 11(ptr) Variable Function
53(shiftedii): 7(ptr) Variable Function
55(shiftedui): 11(ptr) Variable Function
57(shiftediu): 7(ptr) Variable Function
58(shifteduu): 11(ptr) Variable Function
108(af): 107(ptr) Variable Function
112(ab): 111(ptr) Variable Function
116(ai): 7(ptr) Variable Function
151(mask1): 11(ptr) Variable Function
153(mask2): 11(ptr) Variable Function
155(mask3): 11(ptr) Variable Function
159(mask4): 11(ptr) Variable Function
Store 8(count) 9
16: 13(ivec2) Load 15(t)
17: 10(int) CompositeExtract 16 1
19: 10(int) IAdd 17 18
Store 12(u) 19
SelectionMerge 23 None
BranchConditional 21 22 23
22: Label
25: 6(int) Load 8(count)
26: 6(int) IMul 25 24
Store 8(count) 26
Branch 23
23: Label
SelectionMerge 28 None
BranchConditional 21 27 28
27: Label
30: 6(int) Load 8(count)
31: 6(int) IMul 30 29
Store 8(count) 31
Branch 28
28: Label
SelectionMerge 34 None
BranchConditional 32 33 34
33: Label
36: 6(int) Load 8(count)
37: 6(int) IMul 36 35
Store 8(count) 37
Branch 34
34: Label
SelectionMerge 39 None
BranchConditional 21 38 39
38: Label
41: 6(int) Load 8(count)
42: 6(int) IMul 41 40
Store 8(count) 42
Branch 39
39: Label
SelectionMerge 44 None
BranchConditional 21 43 44
43: Label
46: 6(int) Load 8(count)
47: 6(int) IMul 46 45
Store 8(count) 47
Branch 44
44: Label
SelectionMerge 49 None
BranchConditional 32 48 49
48: Label
51: 6(int) Load 8(count)
52: 6(int) IMul 51 50
Store 8(count) 52
Branch 49
49: Label
Store 53(shiftedii) 54
Store 55(shiftedui) 56
Store 57(shiftediu) 54
Store 58(shifteduu) 56
59: 6(int) Load 53(shiftedii)
60: 6(int) Load 57(shiftediu)
61: 20(bool) IEqual 59 60
SelectionMerge 63 None
BranchConditional 61 62 63
62: Label
71: 68 Load 70(usampler)
76: 73(fvec2) Load 75(tc)
77: 64(ivec4) ImageSampleImplicitLod 71 76
Store 66(c) 77
Branch 63
63: Label
78: 10(int) Load 55(shiftedui)
79: 10(int) Load 58(shifteduu)
80: 20(bool) IEqual 78 79
SelectionMerge 82 None
BranchConditional 80 81 82
81: Label
83: 68 Load 70(usampler)
84: 73(fvec2) Load 75(tc)
86: 73(fvec2) CompositeConstruct 85 85
87: 73(fvec2) FAdd 84 86
88: 64(ivec4) ImageSampleImplicitLod 83 87
Store 66(c) 88
Branch 82
82: Label
89: 6(int) Load 53(shiftedii)
90: 10(int) Load 55(shiftedui)
91: 6(int) Bitcast 90
92: 20(bool) IEqual 89 91
SelectionMerge 94 None
BranchConditional 92 93 94
93: Label
95: 68 Load 70(usampler)
96: 73(fvec2) Load 75(tc)
99: 73(fvec2) FSub 96 98
100: 64(ivec4) ImageSampleImplicitLod 95 99
Store 66(c) 100
Branch 94
94: Label
101: 13(ivec2) Load 15(t)
102: 10(int) CompositeExtract 101 0
104: 20(bool) UGreaterThan 102 103
SelectionMerge 106 None
BranchConditional 104 105 106
105: Label
109: 10(int) Load 12(u)
110: 72(float) ConvertUToF 109
Store 108(af) 110
113: 10(int) Load 12(u)
115: 20(bool) INotEqual 113 114
Store 112(ab) 115
117: 10(int) Load 12(u)
118: 6(int) Bitcast 117
Store 116(ai) 118
119: 72(float) Load 108(af)
120: 10(int) ConvertFToU 119
121: 20(bool) Load 112(ab)
123: 10(int) Select 121 122 114
124: 6(int) Load 116(ai)
125: 10(int) Bitcast 124
126: 6(int) Load 8(count)
127: 10(int) Bitcast 126
128: 64(ivec4) CompositeConstruct 120 123 125 127
129: 64(ivec4) Load 66(c)
130: 64(ivec4) IAdd 129 128
Store 66(c) 130
Branch 106
106: Label
SelectionMerge 132 None
BranchConditional 21 131 132
131: Label
134: 6(int) Load 8(count)
135: 6(int) IMul 134 133
Store 8(count) 135
Branch 132
132: Label
SelectionMerge 137 None
BranchConditional 32 136 137
136: Label
139: 6(int) Load 8(count)
140: 6(int) IMul 139 138
Store 8(count) 140
Branch 137
137: Label
SelectionMerge 142 None
BranchConditional 21 141 142
141: Label
144: 6(int) Load 8(count)
145: 6(int) IMul 144 143
Store 8(count) 145
Branch 142
142: Label
SelectionMerge 147 None
BranchConditional 21 146 147
146: Label
149: 6(int) Load 8(count)
150: 6(int) IMul 149 148
Store 8(count) 150
Branch 147
147: Label
Store 151(mask1) 152
Store 153(mask2) 154
156: 10(int) Load 151(mask1)
158: 10(int) ShiftLeftLogical 156 157
Store 155(mask3) 158
Store 159(mask4) 160
161: 10(int) Load 155(mask3)
162: 10(int) Load 153(mask2)
163: 20(bool) IEqual 161 162
SelectionMerge 165 None
BranchConditional 163 164 165
164: Label
166: 6(int) Load 8(count)
167: 6(int) IMul 166 24
Store 8(count) 167
Branch 165
165: Label
168: 10(int) Load 155(mask3)
169: 10(int) Load 151(mask1)
170: 10(int) BitwiseAnd 168 169
171: 20(bool) INotEqual 170 114
SelectionMerge 173 None
BranchConditional 171 172 173
172: Label
174: 6(int) Load 8(count)
175: 6(int) IMul 174 29
Store 8(count) 175
Branch 173
173: Label
176: 10(int) Load 151(mask1)
177: 10(int) Load 155(mask3)
178: 10(int) BitwiseOr 176 177
179: 10(int) Load 159(mask4)
180: 20(bool) IEqual 178 179
SelectionMerge 182 None
BranchConditional 180 181 182
181: Label
183: 6(int) Load 8(count)
184: 6(int) IMul 183 35
Store 8(count) 184
Branch 182
182: Label
185: 10(int) Load 151(mask1)
186: 10(int) Load 159(mask4)
187: 10(int) BitwiseXor 185 186
188: 20(bool) IEqual 187 154
SelectionMerge 190 None
BranchConditional 188 189 190
189: Label
191: 6(int) Load 8(count)
192: 6(int) IMul 191 40
Store 8(count) 192
Branch 190
190: Label
193: 6(int) Load 8(count)
194: 10(int) Bitcast 193
195: 64(ivec4) CompositeConstruct 194 194 194 194
196: 64(ivec4) Load 66(c)
197: 64(ivec4) IAdd 196 195
Store 66(c) 197
Return
FunctionEnd