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

@ -8,7 +8,7 @@ Linked fragment stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 135
// Id's are bound by 134
Source GLSL 130
Capability Shader
@ -17,205 +17,203 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 9 "s1"
MemberName 9(s1) 0 "i"
MemberName 9(s1) 1 "f"
Name 11 "s2"
MemberName 11(s2) 0 "i"
MemberName 11(s2) 1 "f"
MemberName 11(s2) 2 "s1_1"
MemberName 11(s2) 3 "bleh"
Name 13 "locals2"
Name 14 "s3"
MemberName 14(s3) 0 "s2_1"
MemberName 14(s3) 1 "i"
MemberName 14(s3) 2 "f"
MemberName 14(s3) 3 "s1_1"
Name 16 "foo3"
Name 37 "localFArray"
Name 41 "coord"
Name 48 "localIArray"
Name 67 "x"
Name 69 "localArray"
Name 74 "i"
Name 81 "a"
Name 87 "condition"
Name 95 "color"
Name 105 "gl_FragColor"
Name 125 "sampler"
Name 131 "foo"
Name 132 "foo2"
Name 134 "uFloatArray"
Decorate 41(coord) Smooth
Decorate 95(color) Smooth
Decorate 105(gl_FragColor) BuiltIn FragColor
Decorate 131(foo) NoStaticUse
Decorate 132(foo2) NoStaticUse
Decorate 134(uFloatArray) NoStaticUse
Name 8 "s1"
MemberName 8(s1) 0 "i"
MemberName 8(s1) 1 "f"
Name 10 "s2"
MemberName 10(s2) 0 "i"
MemberName 10(s2) 1 "f"
MemberName 10(s2) 2 "s1_1"
MemberName 10(s2) 3 "bleh"
Name 12 "locals2"
Name 13 "s3"
MemberName 13(s3) 0 "s2_1"
MemberName 13(s3) 1 "i"
MemberName 13(s3) 2 "f"
MemberName 13(s3) 3 "s1_1"
Name 15 "foo3"
Name 36 "localFArray"
Name 40 "coord"
Name 47 "localIArray"
Name 66 "x"
Name 68 "localArray"
Name 73 "i"
Name 80 "a"
Name 86 "condition"
Name 94 "color"
Name 104 "gl_FragColor"
Name 124 "sampler"
Name 130 "foo"
Name 131 "foo2"
Name 133 "uFloatArray"
Decorate 40(coord) Smooth
Decorate 94(color) Smooth
Decorate 104(gl_FragColor) BuiltIn FragColor
Decorate 130(foo) NoStaticUse
Decorate 131(foo2) NoStaticUse
Decorate 133(uFloatArray) NoStaticUse
2: TypeVoid
3: TypeFunction 2
7: TypeInt 32 1
8: TypeFloat 32
9(s1): TypeStruct 7(int) 8(float)
10: TypeVector 8(float) 4
11(s2): TypeStruct 7(int) 8(float) 9(s1) 10(fvec4)
12: TypePointer Function 11(s2)
14(s3): TypeStruct 11(s2) 7(int) 8(float) 9(s1)
15: TypePointer UniformConstant 14(s3)
16(foo3): 15(ptr) Variable UniformConstant
17: 7(int) Constant 0
18: TypePointer UniformConstant 11(s2)
21: TypePointer UniformConstant 7(int)
24: TypeBool
28: 7(int) Constant 2
29: 7(int) Constant 1
30: 8(float) Constant 1065353216
31: TypePointer Function 8(float)
33: TypeInt 32 0
34: 33(int) Constant 16
35: TypeArray 8(float) 34
36: TypePointer Function 35
38: 7(int) Constant 4
39: TypeVector 8(float) 2
40: TypePointer Input 39(fvec2)
41(coord): 40(ptr) Variable Input
45: 33(int) Constant 8
46: TypeArray 7(int) 45
47: TypePointer Function 46
51: TypePointer Function 7(int)
68: 7(int) Constant 5
79: 7(int) Constant 16
83: 8(float) Constant 0
87(condition): 21(ptr) Variable UniformConstant
93: 7(int) Constant 3
94: TypePointer Input 10(fvec4)
95(color): 94(ptr) Variable Input
97: TypePointer Function 10(fvec4)
104: TypePointer Output 10(fvec4)
105(gl_FragColor): 104(ptr) Variable Output
122: TypeImage 8(float) 2D sampled format:Unknown
123: TypeSampledImage 122
124: TypePointer UniformConstant 123
125(sampler): 124(ptr) Variable UniformConstant
130: TypePointer UniformConstant 9(s1)
131(foo): 130(ptr) Variable UniformConstant
132(foo2): 18(ptr) Variable UniformConstant
133: TypePointer UniformConstant 35
134(uFloatArray): 133(ptr) Variable UniformConstant
6: TypeInt 32 1
7: TypeFloat 32
8(s1): TypeStruct 6(int) 7(float)
9: TypeVector 7(float) 4
10(s2): TypeStruct 6(int) 7(float) 8(s1) 9(fvec4)
11: TypePointer Function 10(s2)
13(s3): TypeStruct 10(s2) 6(int) 7(float) 8(s1)
14: TypePointer UniformConstant 13(s3)
15(foo3): 14(ptr) Variable UniformConstant
16: 6(int) Constant 0
17: TypePointer UniformConstant 10(s2)
20: TypePointer UniformConstant 6(int)
23: TypeBool
27: 6(int) Constant 2
28: 6(int) Constant 1
29: 7(float) Constant 1065353216
30: TypePointer Function 7(float)
32: TypeInt 32 0
33: 32(int) Constant 16
34: TypeArray 7(float) 33
35: TypePointer Function 34
37: 6(int) Constant 4
38: TypeVector 7(float) 2
39: TypePointer Input 38(fvec2)
40(coord): 39(ptr) Variable Input
44: 32(int) Constant 8
45: TypeArray 6(int) 44
46: TypePointer Function 45
50: TypePointer Function 6(int)
67: 6(int) Constant 5
78: 6(int) Constant 16
82: 7(float) Constant 0
86(condition): 20(ptr) Variable UniformConstant
92: 6(int) Constant 3
93: TypePointer Input 9(fvec4)
94(color): 93(ptr) Variable Input
96: TypePointer Function 9(fvec4)
103: TypePointer Output 9(fvec4)
104(gl_FragColor): 103(ptr) Variable Output
121: TypeImage 7(float) 2D sampled format:Unknown
122: TypeSampledImage 121
123: TypePointer UniformConstant 122
124(sampler): 123(ptr) Variable UniformConstant
129: TypePointer UniformConstant 8(s1)
130(foo): 129(ptr) Variable UniformConstant
131(foo2): 17(ptr) Variable UniformConstant
132: TypePointer UniformConstant 34
133(uFloatArray): 132(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
13(locals2): 12(ptr) Variable Function
37(localFArray): 36(ptr) Variable Function
48(localIArray): 47(ptr) Variable Function
67(x): 51(ptr) Variable Function
69(localArray): 36(ptr) Variable Function
74(i): 51(ptr) Variable Function
81(a): 36(ptr) Variable Function
19: 18(ptr) AccessChain 16(foo3) 17
20: 11(s2) Load 19
Store 13(locals2) 20
22: 21(ptr) AccessChain 16(foo3) 17 17
23: 7(int) Load 22
25: 24(bool) SGreaterThan 23 17
SelectionMerge 27 None
BranchConditional 25 26 53
26: Label
32: 31(ptr) AccessChain 13(locals2) 28 29
Store 32 30
42: 39(fvec2) Load 41(coord)
43: 8(float) CompositeExtract 42 0
44: 31(ptr) AccessChain 37(localFArray) 38
Store 44 43
49: 21(ptr) AccessChain 16(foo3) 17 17
50: 7(int) Load 49
52: 51(ptr) AccessChain 48(localIArray) 28
Store 52 50
Branch 27
53: Label
54: 39(fvec2) Load 41(coord)
55: 8(float) CompositeExtract 54 0
56: 31(ptr) AccessChain 13(locals2) 28 29
Store 56 55
57: 31(ptr) AccessChain 37(localFArray) 38
Store 57 30
58: 51(ptr) AccessChain 48(localIArray) 28
Store 58 17
Branch 27
27: Label
59: 51(ptr) AccessChain 48(localIArray) 28
60: 7(int) Load 59
61: 24(bool) IEqual 60 17
SelectionMerge 63 None
BranchConditional 61 62 63
62: Label
64: 31(ptr) AccessChain 37(localFArray) 38
65: 8(float) Load 64
66: 8(float) FAdd 65 30
Store 64 66
Branch 63
63: Label
Store 67(x) 68
70: 7(int) Load 67(x)
71: 39(fvec2) Load 41(coord)
72: 8(float) CompositeExtract 71 0
73: 31(ptr) AccessChain 69(localArray) 70
Store 73 72
Store 74(i) 17
Branch 75
12(locals2): 11(ptr) Variable Function
36(localFArray): 35(ptr) Variable Function
47(localIArray): 46(ptr) Variable Function
66(x): 50(ptr) Variable Function
68(localArray): 35(ptr) Variable Function
73(i): 50(ptr) Variable Function
80(a): 35(ptr) Variable Function
18: 17(ptr) AccessChain 15(foo3) 16
19: 10(s2) Load 18
Store 12(locals2) 19
21: 20(ptr) AccessChain 15(foo3) 16 16
22: 6(int) Load 21
24: 23(bool) SGreaterThan 22 16
SelectionMerge 26 None
BranchConditional 24 25 52
25: Label
31: 30(ptr) AccessChain 12(locals2) 27 28
Store 31 29
41: 38(fvec2) Load 40(coord)
42: 7(float) CompositeExtract 41 0
43: 30(ptr) AccessChain 36(localFArray) 37
Store 43 42
48: 20(ptr) AccessChain 15(foo3) 16 16
49: 6(int) Load 48
51: 50(ptr) AccessChain 47(localIArray) 27
Store 51 49
Branch 26
52: Label
53: 38(fvec2) Load 40(coord)
54: 7(float) CompositeExtract 53 0
55: 30(ptr) AccessChain 12(locals2) 27 28
Store 55 54
56: 30(ptr) AccessChain 36(localFArray) 37
Store 56 29
57: 50(ptr) AccessChain 47(localIArray) 27
Store 57 16
Branch 26
26: Label
58: 50(ptr) AccessChain 47(localIArray) 27
59: 6(int) Load 58
60: 23(bool) IEqual 59 16
SelectionMerge 62 None
BranchConditional 60 61 62
61: Label
63: 30(ptr) AccessChain 36(localFArray) 37
64: 7(float) Load 63
65: 7(float) FAdd 64 29
Store 63 65
Branch 62
62: Label
Store 66(x) 67
69: 6(int) Load 66(x)
70: 38(fvec2) Load 40(coord)
71: 7(float) CompositeExtract 70 0
72: 30(ptr) AccessChain 68(localArray) 69
Store 72 71
Store 73(i) 16
Branch 74
74: Label
77: 6(int) Load 73(i)
79: 23(bool) SLessThan 77 78
LoopMerge 75 None
BranchConditional 79 76 75
76: Label
81: 6(int) Load 73(i)
83: 30(ptr) AccessChain 80(a) 81
Store 83 82
84: 6(int) Load 73(i)
85: 6(int) IAdd 84 28
Store 73(i) 85
Branch 74
75: Label
78: 7(int) Load 74(i)
80: 24(bool) SLessThan 78 79
LoopMerge 76 None
BranchConditional 80 77 76
77: Label
82: 7(int) Load 74(i)
84: 31(ptr) AccessChain 81(a) 82
Store 84 83
85: 7(int) Load 74(i)
86: 7(int) IAdd 85 29
Store 74(i) 86
Branch 75
76: Label
88: 7(int) Load 87(condition)
89: 24(bool) IEqual 88 29
SelectionMerge 91 None
BranchConditional 89 90 91
90: Label
92: 35 Load 69(localArray)
Store 81(a) 92
Branch 91
91: Label
96: 10(fvec4) Load 95(color)
98: 97(ptr) AccessChain 13(locals2) 93
Store 98 96
99: 39(fvec2) Load 41(coord)
100: 8(float) CompositeExtract 99 1
101: 97(ptr) AccessChain 13(locals2) 93
102: 10(fvec4) Load 101
103: 10(fvec4) CompositeInsert 100 102 2
Store 101 103
106: 97(ptr) AccessChain 13(locals2) 93
107: 10(fvec4) Load 106
108: 31(ptr) AccessChain 37(localFArray) 38
109: 8(float) Load 108
110: 31(ptr) AccessChain 13(locals2) 28 29
111: 8(float) Load 110
112: 8(float) FAdd 109 111
113: 7(int) Load 67(x)
114: 31(ptr) AccessChain 69(localArray) 113
115: 8(float) Load 114
116: 8(float) FAdd 112 115
117: 7(int) Load 67(x)
118: 31(ptr) AccessChain 81(a) 117
119: 8(float) Load 118
120: 8(float) FAdd 116 119
121: 10(fvec4) VectorTimesScalar 107 120
126: 123 Load 125(sampler)
127: 39(fvec2) Load 41(coord)
128: 10(fvec4) ImageSampleImplicitLod 126 127
129: 10(fvec4) FMul 121 128
Store 105(gl_FragColor) 129
Branch 6
6: Label
87: 6(int) Load 86(condition)
88: 23(bool) IEqual 87 28
SelectionMerge 90 None
BranchConditional 88 89 90
89: Label
91: 34 Load 68(localArray)
Store 80(a) 91
Branch 90
90: Label
95: 9(fvec4) Load 94(color)
97: 96(ptr) AccessChain 12(locals2) 92
Store 97 95
98: 38(fvec2) Load 40(coord)
99: 7(float) CompositeExtract 98 1
100: 96(ptr) AccessChain 12(locals2) 92
101: 9(fvec4) Load 100
102: 9(fvec4) CompositeInsert 99 101 2
Store 100 102
105: 96(ptr) AccessChain 12(locals2) 92
106: 9(fvec4) Load 105
107: 30(ptr) AccessChain 36(localFArray) 37
108: 7(float) Load 107
109: 30(ptr) AccessChain 12(locals2) 27 28
110: 7(float) Load 109
111: 7(float) FAdd 108 110
112: 6(int) Load 66(x)
113: 30(ptr) AccessChain 68(localArray) 112
114: 7(float) Load 113
115: 7(float) FAdd 111 114
116: 6(int) Load 66(x)
117: 30(ptr) AccessChain 80(a) 116
118: 7(float) Load 117
119: 7(float) FAdd 115 118
120: 9(fvec4) VectorTimesScalar 106 119
125: 122 Load 124(sampler)
126: 38(fvec2) Load 40(coord)
127: 9(fvec4) ImageSampleImplicitLod 125 126
128: 9(fvec4) FMul 120 127
Store 104(gl_FragColor) 128
Return
FunctionEnd