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:
@@ -7,7 +7,7 @@ Linked fragment stage:
|
||||
|
||||
// Module Version 99
|
||||
// Generated by (magic number): 51a00bb
|
||||
// Id's are bound by 159
|
||||
// Id's are bound by 158
|
||||
|
||||
Source GLSL 400
|
||||
Capability Shader
|
||||
@@ -16,225 +16,223 @@ Linked fragment stage:
|
||||
EntryPoint Fragment 4 "main"
|
||||
ExecutionMode 4 OriginLowerLeft
|
||||
Name 4 "main"
|
||||
Name 16 "foo(i1;i1;i1;i1;i1;i1;"
|
||||
Name 10 "a"
|
||||
Name 11 "b"
|
||||
Name 12 "c"
|
||||
Name 13 "d"
|
||||
Name 14 "e"
|
||||
Name 15 "f"
|
||||
Name 26 "foo2(f1;vf3;i1;"
|
||||
Name 23 "a"
|
||||
Name 24 "b"
|
||||
Name 25 "r"
|
||||
Name 29 "foo3("
|
||||
Name 31 "sum"
|
||||
Name 73 "u"
|
||||
Name 85 "t"
|
||||
Name 88 "s"
|
||||
MemberName 88(s) 0 "t"
|
||||
Name 90 "f"
|
||||
Name 97 "color"
|
||||
Name 103 "e"
|
||||
Name 15 "foo(i1;i1;i1;i1;i1;i1;"
|
||||
Name 9 "a"
|
||||
Name 10 "b"
|
||||
Name 11 "c"
|
||||
Name 12 "d"
|
||||
Name 13 "e"
|
||||
Name 14 "f"
|
||||
Name 25 "foo2(f1;vf3;i1;"
|
||||
Name 22 "a"
|
||||
Name 23 "b"
|
||||
Name 24 "r"
|
||||
Name 28 "foo3("
|
||||
Name 30 "sum"
|
||||
Name 72 "u"
|
||||
Name 84 "t"
|
||||
Name 87 "s"
|
||||
MemberName 87(s) 0 "t"
|
||||
Name 89 "f"
|
||||
Name 96 "color"
|
||||
Name 102 "e"
|
||||
Name 103 "param"
|
||||
Name 104 "param"
|
||||
Name 105 "param"
|
||||
Name 106 "param"
|
||||
Name 107 "param"
|
||||
Name 126 "ret"
|
||||
Name 128 "tempReturn"
|
||||
Name 133 "tempArg"
|
||||
Name 125 "ret"
|
||||
Name 127 "tempReturn"
|
||||
Name 132 "tempArg"
|
||||
Name 133 "param"
|
||||
Name 134 "param"
|
||||
Name 135 "param"
|
||||
Name 136 "param"
|
||||
Name 139 "arg"
|
||||
Name 155 "gl_FragColor"
|
||||
Decorate 155(gl_FragColor) BuiltIn FragColor
|
||||
Name 138 "arg"
|
||||
Name 154 "gl_FragColor"
|
||||
Decorate 154(gl_FragColor) BuiltIn FragColor
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
7: TypeInt 32 1
|
||||
8: TypePointer Function 7(int)
|
||||
9: TypeFunction 7(int) 8(ptr) 7(int) 8(ptr) 7(int) 8(ptr) 8(ptr)
|
||||
18: TypeFloat 32
|
||||
19: TypePointer Function 18(float)
|
||||
20: TypeVector 18(float) 3
|
||||
21: TypePointer Function 20(fvec3)
|
||||
22: TypeFunction 7(int) 19(ptr) 21(ptr) 8(ptr)
|
||||
28: TypeFunction 7(int)
|
||||
39: 7(int) Constant 64
|
||||
44: 7(int) Constant 1024
|
||||
62: 18(float) Constant 1077936128
|
||||
66: 18(float) Constant 1084227584
|
||||
72: TypePointer UniformConstant 18(float)
|
||||
73(u): 72(ptr) Variable UniformConstant
|
||||
75: 18(float) Constant 1078774989
|
||||
76: TypeBool
|
||||
81: 7(int) Constant 1000000
|
||||
83: 7(int) Constant 2000000
|
||||
86: 7(int) Constant 2
|
||||
87: TypeVector 7(int) 4
|
||||
88(s): TypeStruct 87(ivec4)
|
||||
89: TypePointer Function 88(s)
|
||||
91: 7(int) Constant 0
|
||||
92: 7(int) Constant 32
|
||||
93: TypePointer Function 87(ivec4)
|
||||
98: 7(int) Constant 1
|
||||
102: 7(int) Constant 8
|
||||
117: 7(int) Constant 128
|
||||
127: TypePointer PrivateGlobal 7(int)
|
||||
128(tempReturn): 127(ptr) Variable PrivateGlobal
|
||||
129: 18(float) Constant 1082130432
|
||||
130: 18(float) Constant 1065353216
|
||||
131: 18(float) Constant 1073741824
|
||||
132: 20(fvec3) ConstantComposite 130 131 62
|
||||
153: TypeVector 18(float) 4
|
||||
154: TypePointer Output 153(fvec4)
|
||||
155(gl_FragColor): 154(ptr) Variable Output
|
||||
6: TypeInt 32 1
|
||||
7: TypePointer Function 6(int)
|
||||
8: TypeFunction 6(int) 7(ptr) 6(int) 7(ptr) 6(int) 7(ptr) 7(ptr)
|
||||
17: TypeFloat 32
|
||||
18: TypePointer Function 17(float)
|
||||
19: TypeVector 17(float) 3
|
||||
20: TypePointer Function 19(fvec3)
|
||||
21: TypeFunction 6(int) 18(ptr) 20(ptr) 7(ptr)
|
||||
27: TypeFunction 6(int)
|
||||
38: 6(int) Constant 64
|
||||
43: 6(int) Constant 1024
|
||||
61: 17(float) Constant 1077936128
|
||||
65: 17(float) Constant 1084227584
|
||||
71: TypePointer UniformConstant 17(float)
|
||||
72(u): 71(ptr) Variable UniformConstant
|
||||
74: 17(float) Constant 1078774989
|
||||
75: TypeBool
|
||||
80: 6(int) Constant 1000000
|
||||
82: 6(int) Constant 2000000
|
||||
85: 6(int) Constant 2
|
||||
86: TypeVector 6(int) 4
|
||||
87(s): TypeStruct 86(ivec4)
|
||||
88: TypePointer Function 87(s)
|
||||
90: 6(int) Constant 0
|
||||
91: 6(int) Constant 32
|
||||
92: TypePointer Function 86(ivec4)
|
||||
97: 6(int) Constant 1
|
||||
101: 6(int) Constant 8
|
||||
116: 6(int) Constant 128
|
||||
126: TypePointer PrivateGlobal 6(int)
|
||||
127(tempReturn): 126(ptr) Variable PrivateGlobal
|
||||
128: 17(float) Constant 1082130432
|
||||
129: 17(float) Constant 1065353216
|
||||
130: 17(float) Constant 1073741824
|
||||
131: 19(fvec3) ConstantComposite 129 130 61
|
||||
152: TypeVector 17(float) 4
|
||||
153: TypePointer Output 152(fvec4)
|
||||
154(gl_FragColor): 153(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
85(t): 8(ptr) Variable Function
|
||||
90(f): 89(ptr) Variable Function
|
||||
97(color): 8(ptr) Variable Function
|
||||
103(e): 8(ptr) Variable Function
|
||||
104(param): 8(ptr) Variable Function
|
||||
105(param): 8(ptr) Variable Function
|
||||
106(param): 8(ptr) Variable Function
|
||||
107(param): 8(ptr) Variable Function
|
||||
126(ret): 19(ptr) Variable Function
|
||||
133(tempArg): 8(ptr) Variable Function
|
||||
134(param): 19(ptr) Variable Function
|
||||
135(param): 21(ptr) Variable Function
|
||||
136(param): 8(ptr) Variable Function
|
||||
139(arg): 19(ptr) Variable Function
|
||||
Store 85(t) 86
|
||||
94: 93(ptr) AccessChain 90(f) 91
|
||||
95: 87(ivec4) Load 94
|
||||
96: 87(ivec4) CompositeInsert 92 95 1
|
||||
Store 94 96
|
||||
99: 7(int) Load 85(t)
|
||||
100: 7(int) Load 85(t)
|
||||
101: 7(int) IAdd 99 100
|
||||
Store 104(param) 98
|
||||
Store 105(param) 101
|
||||
108: 93(ptr) AccessChain 90(f) 91
|
||||
109: 87(ivec4) Load 108
|
||||
110: 7(int) CompositeExtract 109 1
|
||||
Store 107(param) 110
|
||||
111: 7(int) FunctionCall 16(foo(i1;i1;i1;i1;i1;i1;) 104(param) 86 105(param) 102 106(param) 107(param)
|
||||
112: 7(int) Load 106(param)
|
||||
Store 103(e) 112
|
||||
113: 7(int) Load 107(param)
|
||||
114: 93(ptr) AccessChain 90(f) 91
|
||||
115: 87(ivec4) Load 114
|
||||
116: 87(ivec4) CompositeInsert 113 115 1
|
||||
Store 114 116
|
||||
Store 97(color) 111
|
||||
118: 7(int) Load 103(e)
|
||||
119: 93(ptr) AccessChain 90(f) 91
|
||||
120: 87(ivec4) Load 119
|
||||
121: 7(int) CompositeExtract 120 1
|
||||
122: 7(int) IAdd 118 121
|
||||
123: 7(int) IMul 117 122
|
||||
124: 7(int) Load 97(color)
|
||||
125: 7(int) IAdd 124 123
|
||||
Store 97(color) 125
|
||||
Store 134(param) 129
|
||||
Store 135(param) 132
|
||||
137: 7(int) FunctionCall 26(foo2(f1;vf3;i1;) 134(param) 135(param) 136(param)
|
||||
138: 7(int) Load 136(param)
|
||||
Store 133(tempArg) 138
|
||||
Store 128(tempReturn) 137
|
||||
140: 7(int) Load 133(tempArg)
|
||||
141: 18(float) ConvertSToF 140
|
||||
Store 139(arg) 141
|
||||
142: 7(int) Load 128(tempReturn)
|
||||
143: 18(float) ConvertSToF 142
|
||||
Store 126(ret) 143
|
||||
144: 18(float) Load 126(ret)
|
||||
145: 18(float) Load 139(arg)
|
||||
146: 18(float) FAdd 144 145
|
||||
147: 7(int) ConvertFToS 146
|
||||
148: 7(int) Load 97(color)
|
||||
149: 7(int) IAdd 148 147
|
||||
Store 97(color) 149
|
||||
150: 7(int) FunctionCall 29(foo3()
|
||||
151: 7(int) Load 97(color)
|
||||
152: 7(int) IAdd 151 150
|
||||
Store 97(color) 152
|
||||
156: 7(int) Load 97(color)
|
||||
157: 18(float) ConvertSToF 156
|
||||
158: 153(fvec4) CompositeConstruct 157 157 157 157
|
||||
Store 155(gl_FragColor) 158
|
||||
Branch 6
|
||||
6: Label
|
||||
84(t): 7(ptr) Variable Function
|
||||
89(f): 88(ptr) Variable Function
|
||||
96(color): 7(ptr) Variable Function
|
||||
102(e): 7(ptr) Variable Function
|
||||
103(param): 7(ptr) Variable Function
|
||||
104(param): 7(ptr) Variable Function
|
||||
105(param): 7(ptr) Variable Function
|
||||
106(param): 7(ptr) Variable Function
|
||||
125(ret): 18(ptr) Variable Function
|
||||
132(tempArg): 7(ptr) Variable Function
|
||||
133(param): 18(ptr) Variable Function
|
||||
134(param): 20(ptr) Variable Function
|
||||
135(param): 7(ptr) Variable Function
|
||||
138(arg): 18(ptr) Variable Function
|
||||
Store 84(t) 85
|
||||
93: 92(ptr) AccessChain 89(f) 90
|
||||
94: 86(ivec4) Load 93
|
||||
95: 86(ivec4) CompositeInsert 91 94 1
|
||||
Store 93 95
|
||||
98: 6(int) Load 84(t)
|
||||
99: 6(int) Load 84(t)
|
||||
100: 6(int) IAdd 98 99
|
||||
Store 103(param) 97
|
||||
Store 104(param) 100
|
||||
107: 92(ptr) AccessChain 89(f) 90
|
||||
108: 86(ivec4) Load 107
|
||||
109: 6(int) CompositeExtract 108 1
|
||||
Store 106(param) 109
|
||||
110: 6(int) FunctionCall 15(foo(i1;i1;i1;i1;i1;i1;) 103(param) 85 104(param) 101 105(param) 106(param)
|
||||
111: 6(int) Load 105(param)
|
||||
Store 102(e) 111
|
||||
112: 6(int) Load 106(param)
|
||||
113: 92(ptr) AccessChain 89(f) 90
|
||||
114: 86(ivec4) Load 113
|
||||
115: 86(ivec4) CompositeInsert 112 114 1
|
||||
Store 113 115
|
||||
Store 96(color) 110
|
||||
117: 6(int) Load 102(e)
|
||||
118: 92(ptr) AccessChain 89(f) 90
|
||||
119: 86(ivec4) Load 118
|
||||
120: 6(int) CompositeExtract 119 1
|
||||
121: 6(int) IAdd 117 120
|
||||
122: 6(int) IMul 116 121
|
||||
123: 6(int) Load 96(color)
|
||||
124: 6(int) IAdd 123 122
|
||||
Store 96(color) 124
|
||||
Store 133(param) 128
|
||||
Store 134(param) 131
|
||||
136: 6(int) FunctionCall 25(foo2(f1;vf3;i1;) 133(param) 134(param) 135(param)
|
||||
137: 6(int) Load 135(param)
|
||||
Store 132(tempArg) 137
|
||||
Store 127(tempReturn) 136
|
||||
139: 6(int) Load 132(tempArg)
|
||||
140: 17(float) ConvertSToF 139
|
||||
Store 138(arg) 140
|
||||
141: 6(int) Load 127(tempReturn)
|
||||
142: 17(float) ConvertSToF 141
|
||||
Store 125(ret) 142
|
||||
143: 17(float) Load 125(ret)
|
||||
144: 17(float) Load 138(arg)
|
||||
145: 17(float) FAdd 143 144
|
||||
146: 6(int) ConvertFToS 145
|
||||
147: 6(int) Load 96(color)
|
||||
148: 6(int) IAdd 147 146
|
||||
Store 96(color) 148
|
||||
149: 6(int) FunctionCall 28(foo3()
|
||||
150: 6(int) Load 96(color)
|
||||
151: 6(int) IAdd 150 149
|
||||
Store 96(color) 151
|
||||
155: 6(int) Load 96(color)
|
||||
156: 17(float) ConvertSToF 155
|
||||
157: 152(fvec4) CompositeConstruct 156 156 156 156
|
||||
Store 154(gl_FragColor) 157
|
||||
Return
|
||||
FunctionEnd
|
||||
16(foo(i1;i1;i1;i1;i1;i1;): 7(int) Function None 9
|
||||
10(a): 8(ptr) FunctionParameter
|
||||
11(b): 7(int) FunctionParameter
|
||||
12(c): 8(ptr) FunctionParameter
|
||||
13(d): 7(int) FunctionParameter
|
||||
14(e): 8(ptr) FunctionParameter
|
||||
15(f): 8(ptr) FunctionParameter
|
||||
17: Label
|
||||
31(sum): 8(ptr) Variable Function
|
||||
32: 7(int) Load 10(a)
|
||||
33: 7(int) IAdd 32 11(b)
|
||||
34: 7(int) Load 12(c)
|
||||
35: 7(int) IAdd 33 34
|
||||
36: 7(int) IAdd 35 13(d)
|
||||
37: 7(int) Load 15(f)
|
||||
38: 7(int) IAdd 36 37
|
||||
Store 31(sum) 38
|
||||
40: 7(int) Load 10(a)
|
||||
41: 7(int) IMul 40 39
|
||||
Store 10(a) 41
|
||||
42: 7(int) Load 12(c)
|
||||
43: 7(int) IMul 42 39
|
||||
Store 12(c) 43
|
||||
Store 14(e) 44
|
||||
45: 7(int) Load 15(f)
|
||||
46: 7(int) IMul 45 39
|
||||
Store 15(f) 46
|
||||
47: 7(int) Load 10(a)
|
||||
48: 7(int) IMul 39 11(b)
|
||||
49: 7(int) IAdd 47 48
|
||||
50: 7(int) Load 12(c)
|
||||
51: 7(int) IAdd 49 50
|
||||
52: 7(int) IMul 39 13(d)
|
||||
53: 7(int) IAdd 51 52
|
||||
54: 7(int) Load 14(e)
|
||||
55: 7(int) IAdd 53 54
|
||||
56: 7(int) Load 15(f)
|
||||
57: 7(int) IAdd 55 56
|
||||
58: 7(int) Load 31(sum)
|
||||
59: 7(int) IAdd 58 57
|
||||
Store 31(sum) 59
|
||||
60: 7(int) Load 31(sum)
|
||||
ReturnValue 60
|
||||
15(foo(i1;i1;i1;i1;i1;i1;): 6(int) Function None 8
|
||||
9(a): 7(ptr) FunctionParameter
|
||||
10(b): 6(int) FunctionParameter
|
||||
11(c): 7(ptr) FunctionParameter
|
||||
12(d): 6(int) FunctionParameter
|
||||
13(e): 7(ptr) FunctionParameter
|
||||
14(f): 7(ptr) FunctionParameter
|
||||
16: Label
|
||||
30(sum): 7(ptr) Variable Function
|
||||
31: 6(int) Load 9(a)
|
||||
32: 6(int) IAdd 31 10(b)
|
||||
33: 6(int) Load 11(c)
|
||||
34: 6(int) IAdd 32 33
|
||||
35: 6(int) IAdd 34 12(d)
|
||||
36: 6(int) Load 14(f)
|
||||
37: 6(int) IAdd 35 36
|
||||
Store 30(sum) 37
|
||||
39: 6(int) Load 9(a)
|
||||
40: 6(int) IMul 39 38
|
||||
Store 9(a) 40
|
||||
41: 6(int) Load 11(c)
|
||||
42: 6(int) IMul 41 38
|
||||
Store 11(c) 42
|
||||
Store 13(e) 43
|
||||
44: 6(int) Load 14(f)
|
||||
45: 6(int) IMul 44 38
|
||||
Store 14(f) 45
|
||||
46: 6(int) Load 9(a)
|
||||
47: 6(int) IMul 38 10(b)
|
||||
48: 6(int) IAdd 46 47
|
||||
49: 6(int) Load 11(c)
|
||||
50: 6(int) IAdd 48 49
|
||||
51: 6(int) IMul 38 12(d)
|
||||
52: 6(int) IAdd 50 51
|
||||
53: 6(int) Load 13(e)
|
||||
54: 6(int) IAdd 52 53
|
||||
55: 6(int) Load 14(f)
|
||||
56: 6(int) IAdd 54 55
|
||||
57: 6(int) Load 30(sum)
|
||||
58: 6(int) IAdd 57 56
|
||||
Store 30(sum) 58
|
||||
59: 6(int) Load 30(sum)
|
||||
ReturnValue 59
|
||||
FunctionEnd
|
||||
26(foo2(f1;vf3;i1;): 7(int) Function None 22
|
||||
23(a): 19(ptr) FunctionParameter
|
||||
24(b): 21(ptr) FunctionParameter
|
||||
25(r): 8(ptr) FunctionParameter
|
||||
27: Label
|
||||
63: 18(float) Load 23(a)
|
||||
64: 18(float) FMul 62 63
|
||||
65: 7(int) ConvertFToS 64
|
||||
Store 25(r) 65
|
||||
67: 20(fvec3) Load 24(b)
|
||||
68: 18(float) CompositeExtract 67 1
|
||||
69: 18(float) FMul 66 68
|
||||
70: 7(int) ConvertFToS 69
|
||||
ReturnValue 70
|
||||
25(foo2(f1;vf3;i1;): 6(int) Function None 21
|
||||
22(a): 18(ptr) FunctionParameter
|
||||
23(b): 20(ptr) FunctionParameter
|
||||
24(r): 7(ptr) FunctionParameter
|
||||
26: Label
|
||||
62: 17(float) Load 22(a)
|
||||
63: 17(float) FMul 61 62
|
||||
64: 6(int) ConvertFToS 63
|
||||
Store 24(r) 64
|
||||
66: 19(fvec3) Load 23(b)
|
||||
67: 17(float) CompositeExtract 66 1
|
||||
68: 17(float) FMul 65 67
|
||||
69: 6(int) ConvertFToS 68
|
||||
ReturnValue 69
|
||||
FunctionEnd
|
||||
29(foo3(): 7(int) Function None 28
|
||||
30: Label
|
||||
74: 18(float) Load 73(u)
|
||||
77: 76(bool) FOrdGreaterThan 74 75
|
||||
SelectionMerge 79 None
|
||||
BranchConditional 77 78 79
|
||||
78: Label
|
||||
28(foo3(): 6(int) Function None 27
|
||||
29: Label
|
||||
73: 17(float) Load 72(u)
|
||||
76: 75(bool) FOrdGreaterThan 73 74
|
||||
SelectionMerge 78 None
|
||||
BranchConditional 76 77 78
|
||||
77: Label
|
||||
Kill
|
||||
79: Label
|
||||
ReturnValue 83
|
||||
78: Label
|
||||
ReturnValue 82
|
||||
FunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user