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 123
// Id's are bound by 122
Source GLSL 130
Capability Shader
@ -14,186 +14,184 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 10 "color"
Name 12 "BaseColor"
Name 16 "i"
Name 23 "Count"
Name 28 "bigColor"
Name 36 "gl_FragColor"
Name 39 "sum"
Name 41 "i"
Name 51 "v4"
Name 60 "i"
Name 66 "tv4"
Name 84 "r"
Name 90 "i"
Name 98 "f"
Name 111 "i"
Decorate 12(BaseColor) Smooth
Decorate 36(gl_FragColor) BuiltIn FragColor
Decorate 98(f) Smooth
Name 9 "color"
Name 11 "BaseColor"
Name 15 "i"
Name 22 "Count"
Name 27 "bigColor"
Name 35 "gl_FragColor"
Name 38 "sum"
Name 40 "i"
Name 50 "v4"
Name 59 "i"
Name 65 "tv4"
Name 83 "r"
Name 89 "i"
Name 97 "f"
Name 110 "i"
Decorate 11(BaseColor) Smooth
Decorate 35(gl_FragColor) BuiltIn FragColor
Decorate 97(f) Smooth
2: TypeVoid
3: TypeFunction 2
7: TypeFloat 32
8: TypeVector 7(float) 4
9: TypePointer Function 8(fvec4)
11: TypePointer Input 8(fvec4)
12(BaseColor): 11(ptr) Variable Input
14: TypeInt 32 1
15: TypePointer Function 14(int)
17: 14(int) Constant 0
22: TypePointer UniformConstant 14(int)
23(Count): 22(ptr) Variable UniformConstant
25: TypeBool
27: TypePointer UniformConstant 8(fvec4)
28(bigColor): 27(ptr) Variable UniformConstant
33: 14(int) Constant 1
35: TypePointer Output 8(fvec4)
36(gl_FragColor): 35(ptr) Variable Output
38: TypePointer Function 7(float)
40: 7(float) Constant 0
46: 14(int) Constant 4
48: TypeInt 32 0
49: TypeVector 48(int) 4
50: TypePointer UniformConstant 49(ivec4)
51(v4): 50(ptr) Variable UniformConstant
71: 48(int) Constant 4
85: TypeVector 7(float) 3
97: TypePointer Input 7(float)
98(f): 97(ptr) Variable Input
116: 14(int) Constant 16
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: TypePointer Input 7(fvec4)
11(BaseColor): 10(ptr) Variable Input
13: TypeInt 32 1
14: TypePointer Function 13(int)
16: 13(int) Constant 0
21: TypePointer UniformConstant 13(int)
22(Count): 21(ptr) Variable UniformConstant
24: TypeBool
26: TypePointer UniformConstant 7(fvec4)
27(bigColor): 26(ptr) Variable UniformConstant
32: 13(int) Constant 1
34: TypePointer Output 7(fvec4)
35(gl_FragColor): 34(ptr) Variable Output
37: TypePointer Function 6(float)
39: 6(float) Constant 0
45: 13(int) Constant 4
47: TypeInt 32 0
48: TypeVector 47(int) 4
49: TypePointer UniformConstant 48(ivec4)
50(v4): 49(ptr) Variable UniformConstant
70: 47(int) Constant 4
84: TypeVector 6(float) 3
96: TypePointer Input 6(float)
97(f): 96(ptr) Variable Input
115: 13(int) Constant 16
4(main): 2 Function None 3
5: Label
10(color): 9(ptr) Variable Function
16(i): 15(ptr) Variable Function
39(sum): 38(ptr) Variable Function
41(i): 15(ptr) Variable Function
60(i): 15(ptr) Variable Function
66(tv4): 9(ptr) Variable Function
84(r): 9(ptr) Variable Function
90(i): 15(ptr) Variable Function
111(i): 15(ptr) Variable Function
13: 8(fvec4) Load 12(BaseColor)
Store 10(color) 13
Store 16(i) 17
Branch 18
9(color): 8(ptr) Variable Function
15(i): 14(ptr) Variable Function
38(sum): 37(ptr) Variable Function
40(i): 14(ptr) Variable Function
59(i): 14(ptr) Variable Function
65(tv4): 8(ptr) Variable Function
83(r): 8(ptr) Variable Function
89(i): 14(ptr) Variable Function
110(i): 14(ptr) Variable Function
12: 7(fvec4) Load 11(BaseColor)
Store 9(color) 12
Store 15(i) 16
Branch 17
17: Label
20: 13(int) Load 15(i)
23: 13(int) Load 22(Count)
25: 24(bool) SLessThan 20 23
LoopMerge 18 None
BranchConditional 25 19 18
19: Label
28: 7(fvec4) Load 27(bigColor)
29: 7(fvec4) Load 9(color)
30: 7(fvec4) FAdd 29 28
Store 9(color) 30
31: 13(int) Load 15(i)
33: 13(int) IAdd 31 32
Store 15(i) 33
Branch 17
18: Label
21: 14(int) Load 16(i)
24: 14(int) Load 23(Count)
26: 25(bool) SLessThan 21 24
LoopMerge 19 None
BranchConditional 26 20 19
20: Label
29: 8(fvec4) Load 28(bigColor)
30: 8(fvec4) Load 10(color)
31: 8(fvec4) FAdd 30 29
Store 10(color) 31
32: 14(int) Load 16(i)
34: 14(int) IAdd 32 33
Store 16(i) 34
Branch 18
19: Label
37: 8(fvec4) Load 10(color)
Store 36(gl_FragColor) 37
Store 39(sum) 40
Store 41(i) 17
Branch 42
36: 7(fvec4) Load 9(color)
Store 35(gl_FragColor) 36
Store 38(sum) 39
Store 40(i) 16
Branch 41
41: Label
44: 13(int) Load 40(i)
46: 24(bool) SLessThan 44 45
LoopMerge 42 None
BranchConditional 46 43 42
43: Label
51: 13(int) Load 40(i)
52: 48(ivec4) Load 50(v4)
53: 47(int) VectorExtractDynamic 52 51
54: 6(float) ConvertUToF 53
55: 6(float) Load 38(sum)
56: 6(float) FAdd 55 54
Store 38(sum) 56
57: 13(int) Load 40(i)
58: 13(int) IAdd 57 32
Store 40(i) 58
Branch 41
42: Label
45: 14(int) Load 41(i)
47: 25(bool) SLessThan 45 46
LoopMerge 43 None
BranchConditional 47 44 43
44: Label
52: 14(int) Load 41(i)
53: 49(ivec4) Load 51(v4)
54: 48(int) VectorExtractDynamic 53 52
55: 7(float) ConvertUToF 54
56: 7(float) Load 39(sum)
57: 7(float) FAdd 56 55
Store 39(sum) 57
58: 14(int) Load 41(i)
59: 14(int) IAdd 58 33
Store 41(i) 59
Branch 42
43: Label
Store 60(i) 17
Branch 61
Store 59(i) 16
Branch 60
60: Label
63: 13(int) Load 59(i)
64: 24(bool) SLessThan 63 45
LoopMerge 61 None
BranchConditional 64 62 61
62: Label
66: 13(int) Load 59(i)
67: 13(int) Load 59(i)
68: 48(ivec4) Load 50(v4)
69: 47(int) VectorExtractDynamic 68 67
71: 47(int) IMul 69 70
72: 6(float) ConvertUToF 71
73: 7(fvec4) Load 65(tv4)
74: 7(fvec4) VectorInsertDynamic 73 72 66
Store 65(tv4) 74
75: 13(int) Load 59(i)
76: 13(int) IAdd 75 32
Store 59(i) 76
Branch 60
61: Label
64: 14(int) Load 60(i)
65: 25(bool) SLessThan 64 46
LoopMerge 62 None
BranchConditional 65 63 62
63: Label
67: 14(int) Load 60(i)
68: 14(int) Load 60(i)
69: 49(ivec4) Load 51(v4)
70: 48(int) VectorExtractDynamic 69 68
72: 48(int) IMul 70 71
73: 7(float) ConvertUToF 72
74: 8(fvec4) Load 66(tv4)
75: 8(fvec4) VectorInsertDynamic 74 73 67
Store 66(tv4) 75
76: 14(int) Load 60(i)
77: 14(int) IAdd 76 33
Store 60(i) 77
Branch 61
62: Label
78: 7(float) Load 39(sum)
79: 8(fvec4) CompositeConstruct 78 78 78 78
80: 8(fvec4) Load 66(tv4)
81: 8(fvec4) FAdd 79 80
82: 8(fvec4) Load 36(gl_FragColor)
83: 8(fvec4) FAdd 82 81
Store 36(gl_FragColor) 83
86: 8(fvec4) Load 12(BaseColor)
87: 85(fvec3) VectorShuffle 86 86 0 1 2
88: 8(fvec4) Load 84(r)
89: 8(fvec4) VectorShuffle 88 87 4 5 6 3
Store 84(r) 89
Store 90(i) 17
Branch 91
77: 6(float) Load 38(sum)
78: 7(fvec4) CompositeConstruct 77 77 77 77
79: 7(fvec4) Load 65(tv4)
80: 7(fvec4) FAdd 78 79
81: 7(fvec4) Load 35(gl_FragColor)
82: 7(fvec4) FAdd 81 80
Store 35(gl_FragColor) 82
85: 7(fvec4) Load 11(BaseColor)
86: 84(fvec3) VectorShuffle 85 85 0 1 2
87: 7(fvec4) Load 83(r)
88: 7(fvec4) VectorShuffle 87 86 4 5 6 3
Store 83(r) 88
Store 89(i) 16
Branch 90
90: Label
93: 13(int) Load 89(i)
94: 13(int) Load 22(Count)
95: 24(bool) SLessThan 93 94
LoopMerge 91 None
BranchConditional 95 92 91
92: Label
98: 6(float) Load 97(f)
99: 7(fvec4) Load 83(r)
100: 7(fvec4) CompositeInsert 98 99 3
Store 83(r) 100
101: 13(int) Load 89(i)
102: 13(int) IAdd 101 32
Store 89(i) 102
Branch 90
91: Label
94: 14(int) Load 90(i)
95: 14(int) Load 23(Count)
96: 25(bool) SLessThan 94 95
LoopMerge 92 None
BranchConditional 96 93 92
93: Label
99: 7(float) Load 98(f)
100: 8(fvec4) Load 84(r)
101: 8(fvec4) CompositeInsert 99 100 3
Store 84(r) 101
102: 14(int) Load 90(i)
103: 14(int) IAdd 102 33
Store 90(i) 103
Branch 91
92: Label
104: 8(fvec4) Load 84(r)
105: 85(fvec3) VectorShuffle 104 104 0 1 2
106: 8(fvec4) Load 36(gl_FragColor)
107: 85(fvec3) VectorShuffle 106 106 0 1 2
108: 85(fvec3) FAdd 107 105
109: 8(fvec4) Load 36(gl_FragColor)
110: 8(fvec4) VectorShuffle 109 108 4 5 6 3
Store 36(gl_FragColor) 110
Store 111(i) 17
Branch 112
103: 7(fvec4) Load 83(r)
104: 84(fvec3) VectorShuffle 103 103 0 1 2
105: 7(fvec4) Load 35(gl_FragColor)
106: 84(fvec3) VectorShuffle 105 105 0 1 2
107: 84(fvec3) FAdd 106 104
108: 7(fvec4) Load 35(gl_FragColor)
109: 7(fvec4) VectorShuffle 108 107 4 5 6 3
Store 35(gl_FragColor) 109
Store 110(i) 16
Branch 111
111: Label
114: 13(int) Load 110(i)
116: 24(bool) SLessThan 114 115
LoopMerge 112 None
BranchConditional 116 113 112
113: Label
117: 6(float) Load 97(f)
118: 7(fvec4) Load 35(gl_FragColor)
119: 7(fvec4) VectorTimesScalar 118 117
Store 35(gl_FragColor) 119
120: 13(int) Load 110(i)
121: 13(int) IAdd 120 45
Store 110(i) 121
Branch 111
112: Label
115: 14(int) Load 111(i)
117: 25(bool) SLessThan 115 116
LoopMerge 113 None
BranchConditional 117 114 113
114: Label
118: 7(float) Load 98(f)
119: 8(fvec4) Load 36(gl_FragColor)
120: 8(fvec4) VectorTimesScalar 119 118
Store 36(gl_FragColor) 120
121: 14(int) Load 111(i)
122: 14(int) IAdd 121 46
Store 111(i) 122
Branch 112
113: Label
Branch 6
6: Label
Return
FunctionEnd