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 112
// Id's are bound by 111
Source GLSL 110
Capability Shader
@ -14,167 +14,165 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 10 "color"
Name 12 "BaseColor"
Name 14 "color2"
Name 16 "otherColor"
Name 19 "c"
Name 22 "d"
Name 28 "bigColor"
Name 33 "smallColor"
Name 39 "minimum"
Name 53 "threshhold"
Name 64 "threshhold2"
Name 78 "b"
Name 107 "gl_FragColor"
Name 111 "threshhold3"
Decorate 12(BaseColor) Smooth
Decorate 19(c) Smooth
Decorate 107(gl_FragColor) BuiltIn FragColor
Decorate 111(threshhold3) NoStaticUse
Name 9 "color"
Name 11 "BaseColor"
Name 13 "color2"
Name 15 "otherColor"
Name 18 "c"
Name 21 "d"
Name 27 "bigColor"
Name 32 "smallColor"
Name 38 "minimum"
Name 52 "threshhold"
Name 63 "threshhold2"
Name 77 "b"
Name 106 "gl_FragColor"
Name 110 "threshhold3"
Decorate 11(BaseColor) Smooth
Decorate 18(c) Smooth
Decorate 106(gl_FragColor) BuiltIn FragColor
Decorate 110(threshhold3) NoStaticUse
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
15: TypePointer UniformConstant 8(fvec4)
16(otherColor): 15(ptr) Variable UniformConstant
18: TypePointer Input 7(float)
19(c): 18(ptr) Variable Input
21: TypePointer UniformConstant 7(float)
22(d): 21(ptr) Variable UniformConstant
24: TypeBool
28(bigColor): 15(ptr) Variable UniformConstant
33(smallColor): 15(ptr) Variable UniformConstant
39(minimum): 21(ptr) Variable UniformConstant
47: 7(float) Constant 1065353216
53(threshhold): 21(ptr) Variable UniformConstant
64(threshhold2): 21(ptr) Variable UniformConstant
77: TypePointer UniformConstant 24(bool)
78(b): 77(ptr) Variable UniformConstant
106: TypePointer Output 8(fvec4)
107(gl_FragColor): 106(ptr) Variable Output
111(threshhold3): 21(ptr) Variable UniformConstant
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: TypePointer Input 7(fvec4)
11(BaseColor): 10(ptr) Variable Input
14: TypePointer UniformConstant 7(fvec4)
15(otherColor): 14(ptr) Variable UniformConstant
17: TypePointer Input 6(float)
18(c): 17(ptr) Variable Input
20: TypePointer UniformConstant 6(float)
21(d): 20(ptr) Variable UniformConstant
23: TypeBool
27(bigColor): 14(ptr) Variable UniformConstant
32(smallColor): 14(ptr) Variable UniformConstant
38(minimum): 20(ptr) Variable UniformConstant
46: 6(float) Constant 1065353216
52(threshhold): 20(ptr) Variable UniformConstant
63(threshhold2): 20(ptr) Variable UniformConstant
76: TypePointer UniformConstant 23(bool)
77(b): 76(ptr) Variable UniformConstant
105: TypePointer Output 7(fvec4)
106(gl_FragColor): 105(ptr) Variable Output
110(threshhold3): 20(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
10(color): 9(ptr) Variable Function
14(color2): 9(ptr) Variable Function
13: 8(fvec4) Load 12(BaseColor)
Store 10(color) 13
17: 8(fvec4) Load 16(otherColor)
Store 14(color2) 17
20: 7(float) Load 19(c)
23: 7(float) Load 22(d)
25: 24(bool) FOrdGreaterThan 20 23
SelectionMerge 27 None
BranchConditional 25 26 32
26: Label
29: 8(fvec4) Load 28(bigColor)
30: 8(fvec4) Load 10(color)
31: 8(fvec4) FAdd 30 29
Store 10(color) 31
Branch 27
32: Label
34: 8(fvec4) Load 33(smallColor)
35: 8(fvec4) Load 10(color)
36: 8(fvec4) FAdd 35 34
Store 10(color) 36
Branch 27
27: Label
37: 8(fvec4) Load 10(color)
38: 7(float) CompositeExtract 37 2
40: 7(float) Load 39(minimum)
41: 24(bool) FOrdLessThan 38 40
SelectionMerge 43 None
BranchConditional 41 42 43
42: Label
Branch 6
43: Label
45: 8(fvec4) Load 10(color)
46: 7(float) CompositeExtract 45 2
48: 7(float) FAdd 46 47
49: 8(fvec4) Load 10(color)
50: 8(fvec4) CompositeInsert 48 49 2
Store 10(color) 50
51: 8(fvec4) Load 10(color)
52: 7(float) CompositeExtract 51 2
54: 7(float) Load 53(threshhold)
55: 24(bool) FOrdGreaterThan 52 54
SelectionMerge 57 None
BranchConditional 55 56 57
56: Label
9(color): 8(ptr) Variable Function
13(color2): 8(ptr) Variable Function
12: 7(fvec4) Load 11(BaseColor)
Store 9(color) 12
16: 7(fvec4) Load 15(otherColor)
Store 13(color2) 16
19: 6(float) Load 18(c)
22: 6(float) Load 21(d)
24: 23(bool) FOrdGreaterThan 19 22
SelectionMerge 26 None
BranchConditional 24 25 31
25: Label
28: 7(fvec4) Load 27(bigColor)
29: 7(fvec4) Load 9(color)
30: 7(fvec4) FAdd 29 28
Store 9(color) 30
Branch 26
31: Label
33: 7(fvec4) Load 32(smallColor)
34: 7(fvec4) Load 9(color)
35: 7(fvec4) FAdd 34 33
Store 9(color) 35
Branch 26
26: Label
36: 7(fvec4) Load 9(color)
37: 6(float) CompositeExtract 36 2
39: 6(float) Load 38(minimum)
40: 23(bool) FOrdLessThan 37 39
SelectionMerge 42 None
BranchConditional 40 41 42
41: Label
Return
42: Label
44: 7(fvec4) Load 9(color)
45: 6(float) CompositeExtract 44 2
47: 6(float) FAdd 45 46
48: 7(fvec4) Load 9(color)
49: 7(fvec4) CompositeInsert 47 48 2
Store 9(color) 49
50: 7(fvec4) Load 9(color)
51: 6(float) CompositeExtract 50 2
53: 6(float) Load 52(threshhold)
54: 23(bool) FOrdGreaterThan 51 53
SelectionMerge 56 None
BranchConditional 54 55 56
55: Label
Kill
57: Label
59: 8(fvec4) Load 10(color)
60: 8(fvec4) CompositeConstruct 47 47 47 47
61: 8(fvec4) FAdd 59 60
Store 10(color) 61
62: 8(fvec4) Load 10(color)
63: 7(float) CompositeExtract 62 3
65: 7(float) Load 64(threshhold2)
66: 24(bool) FOrdGreaterThan 63 65
SelectionMerge 68 None
BranchConditional 66 67 99
67: Label
69: 8(fvec4) Load 10(color)
70: 7(float) CompositeExtract 69 2
71: 7(float) Load 64(threshhold2)
72: 24(bool) FOrdGreaterThan 70 71
SelectionMerge 74 None
BranchConditional 72 73 76
73: Label
Branch 6
76: Label
79: 24(bool) Load 78(b)
SelectionMerge 81 None
BranchConditional 79 80 87
80: Label
82: 8(fvec4) Load 10(color)
83: 7(float) CompositeExtract 82 2
84: 7(float) FAdd 83 47
85: 8(fvec4) Load 10(color)
86: 8(fvec4) CompositeInsert 84 85 2
Store 10(color) 86
Branch 81
87: Label
88: 8(fvec4) Load 10(color)
89: 7(float) CompositeExtract 88 0
90: 7(float) Load 39(minimum)
91: 24(bool) FOrdLessThan 89 90
SelectionMerge 93 None
BranchConditional 91 92 95
92: Label
56: Label
58: 7(fvec4) Load 9(color)
59: 7(fvec4) CompositeConstruct 46 46 46 46
60: 7(fvec4) FAdd 58 59
Store 9(color) 60
61: 7(fvec4) Load 9(color)
62: 6(float) CompositeExtract 61 3
64: 6(float) Load 63(threshhold2)
65: 23(bool) FOrdGreaterThan 62 64
SelectionMerge 67 None
BranchConditional 65 66 98
66: Label
68: 7(fvec4) Load 9(color)
69: 6(float) CompositeExtract 68 2
70: 6(float) Load 63(threshhold2)
71: 23(bool) FOrdGreaterThan 69 70
SelectionMerge 73 None
BranchConditional 71 72 75
72: Label
Return
75: Label
78: 23(bool) Load 77(b)
SelectionMerge 80 None
BranchConditional 78 79 86
79: Label
81: 7(fvec4) Load 9(color)
82: 6(float) CompositeExtract 81 2
83: 6(float) FAdd 82 46
84: 7(fvec4) Load 9(color)
85: 7(fvec4) CompositeInsert 83 84 2
Store 9(color) 85
Branch 80
86: Label
87: 7(fvec4) Load 9(color)
88: 6(float) CompositeExtract 87 0
89: 6(float) Load 38(minimum)
90: 23(bool) FOrdLessThan 88 89
SelectionMerge 92 None
BranchConditional 90 91 94
91: Label
Kill
95: Label
96: 8(fvec4) Load 10(color)
97: 8(fvec4) CompositeConstruct 47 47 47 47
98: 8(fvec4) FAdd 96 97
Store 10(color) 98
Branch 93
93: Label
Branch 81
81: Label
Branch 74
74: Label
Branch 68
99: Label
100: 24(bool) Load 78(b)
SelectionMerge 102 None
BranchConditional 100 101 104
101: Label
94: Label
95: 7(fvec4) Load 9(color)
96: 7(fvec4) CompositeConstruct 46 46 46 46
97: 7(fvec4) FAdd 95 96
Store 9(color) 97
Branch 92
92: Label
Branch 80
80: Label
Branch 73
73: Label
Branch 67
98: Label
99: 23(bool) Load 77(b)
SelectionMerge 101 None
BranchConditional 99 100 103
100: Label
Kill
104: Label
Branch 6
102: Label
Branch 68
68: Label
108: 8(fvec4) Load 10(color)
109: 8(fvec4) Load 14(color2)
110: 8(fvec4) FMul 108 109
Store 107(gl_FragColor) 110
Branch 6
6: Label
103: Label
Return
101: Label
Branch 67
67: Label
107: 7(fvec4) Load 9(color)
108: 7(fvec4) Load 13(color2)
109: 7(fvec4) FMul 107 108
Store 106(gl_FragColor) 109
Return
FunctionEnd