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 97
// Id's are bound by 96
Source GLSL 140
Capability Shader
@ -14,139 +14,137 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 9 "index"
Name 15 "s"
MemberName 15(s) 0 "y"
Name 17 "str"
Name 23 "t"
Name 51 "x"
Name 62 "y"
Name 67 "z"
Name 74 "v"
Name 93 "gl_FragColor"
Decorate 93(gl_FragColor) BuiltIn FragColor
Name 8 "index"
Name 14 "s"
MemberName 14(s) 0 "y"
Name 16 "str"
Name 22 "t"
Name 50 "x"
Name 61 "y"
Name 66 "z"
Name 73 "v"
Name 92 "gl_FragColor"
Decorate 92(gl_FragColor) BuiltIn FragColor
2: TypeVoid
3: TypeFunction 2
7: TypeInt 32 1
8: TypePointer Function 7(int)
10: 7(int) Constant 5
11: TypeFloat 32
12: TypeInt 32 0
13: 12(int) Constant 5
14: TypeArray 11(float) 13
15(s): TypeStruct 14
16: TypePointer Function 15(s)
18: 7(int) Constant 0
19: 7(int) Constant 4
20: 11(float) Constant 1073741824
21: TypePointer Function 11(float)
25: 7(int) Constant 1
29: 11(float) Constant 1065353216
72: TypeVector 11(float) 4
73: TypePointer Function 72(fvec4)
75: 11(float) Constant 1077936128
76: 11(float) Constant 1082130432
77: 72(fvec4) ConstantComposite 29 20 75 76
92: TypePointer Output 72(fvec4)
93(gl_FragColor): 92(ptr) Variable Output
6: TypeInt 32 1
7: TypePointer Function 6(int)
9: 6(int) Constant 5
10: TypeFloat 32
11: TypeInt 32 0
12: 11(int) Constant 5
13: TypeArray 10(float) 12
14(s): TypeStruct 13
15: TypePointer Function 14(s)
17: 6(int) Constant 0
18: 6(int) Constant 4
19: 10(float) Constant 1073741824
20: TypePointer Function 10(float)
24: 6(int) Constant 1
28: 10(float) Constant 1065353216
71: TypeVector 10(float) 4
72: TypePointer Function 71(fvec4)
74: 10(float) Constant 1077936128
75: 10(float) Constant 1082130432
76: 71(fvec4) ConstantComposite 28 19 74 75
91: TypePointer Output 71(fvec4)
92(gl_FragColor): 91(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(index): 8(ptr) Variable Function
17(str): 16(ptr) Variable Function
23(t): 21(ptr) Variable Function
51(x): 21(ptr) Variable Function
62(y): 21(ptr) Variable Function
67(z): 21(ptr) Variable Function
74(v): 73(ptr) Variable Function
Store 9(index) 10
22: 21(ptr) AccessChain 17(str) 18 19
Store 22 20
24: 7(int) Load 9(index)
26: 7(int) ISub 24 25
Store 9(index) 26
27: 21(ptr) AccessChain 17(str) 18 26
28: 11(float) Load 27
30: 11(float) FAdd 28 29
Store 27 30
Store 23(t) 30
31: 11(float) Load 23(t)
32: 21(ptr) AccessChain 17(str) 18 19
33: 11(float) Load 32
34: 11(float) FAdd 33 31
35: 21(ptr) AccessChain 17(str) 18 19
Store 35 34
36: 21(ptr) AccessChain 17(str) 18 19
37: 11(float) Load 36
38: 11(float) FSub 37 29
Store 36 38
Store 23(t) 37
39: 7(int) Load 9(index)
40: 7(int) IAdd 39 25
Store 9(index) 40
41: 11(float) Load 23(t)
42: 21(ptr) AccessChain 17(str) 18 39
43: 11(float) Load 42
44: 11(float) FAdd 43 41
45: 21(ptr) AccessChain 17(str) 18 39
Store 45 44
46: 7(int) Load 9(index)
47: 7(int) ISub 46 25
Store 9(index) 47
48: 21(ptr) AccessChain 17(str) 18 47
49: 11(float) Load 48
50: 11(float) FSub 49 29
Store 48 50
52: 21(ptr) AccessChain 17(str) 18 19
53: 11(float) Load 52
Store 51(x) 53
54: 11(float) Load 51(x)
55: 11(float) FAdd 54 29
Store 51(x) 55
56: 11(float) Load 51(x)
57: 11(float) FSub 56 29
Store 51(x) 57
58: 11(float) Load 51(x)
59: 11(float) FAdd 58 29
Store 51(x) 59
60: 11(float) Load 51(x)
61: 11(float) FSub 60 29
Store 51(x) 61
63: 11(float) Load 51(x)
64: 11(float) Load 51(x)
65: 11(float) FAdd 64 29
Store 51(x) 65
66: 11(float) FMul 63 65
Store 62(y) 66
68: 11(float) Load 62(y)
69: 11(float) Load 51(x)
70: 11(float) FSub 69 29
Store 51(x) 70
71: 11(float) FMul 68 69
Store 67(z) 71
Store 74(v) 77
78: 72(fvec4) Load 74(v)
79: 11(float) CompositeExtract 78 2
80: 11(float) FSub 79 29
81: 72(fvec4) Load 74(v)
82: 72(fvec4) CompositeInsert 80 81 2
Store 74(v) 82
83: 72(fvec4) Load 74(v)
84: 72(fvec4) CompositeInsert 79 83 1
Store 74(v) 84
85: 72(fvec4) Load 74(v)
86: 11(float) CompositeExtract 85 3
87: 11(float) FSub 86 29
88: 72(fvec4) Load 74(v)
89: 72(fvec4) CompositeInsert 87 88 3
Store 74(v) 89
90: 72(fvec4) Load 74(v)
91: 72(fvec4) CompositeInsert 87 90 0
Store 74(v) 91
94: 11(float) Load 67(z)
95: 72(fvec4) Load 74(v)
96: 72(fvec4) VectorTimesScalar 95 94
Store 93(gl_FragColor) 96
Branch 6
6: Label
8(index): 7(ptr) Variable Function
16(str): 15(ptr) Variable Function
22(t): 20(ptr) Variable Function
50(x): 20(ptr) Variable Function
61(y): 20(ptr) Variable Function
66(z): 20(ptr) Variable Function
73(v): 72(ptr) Variable Function
Store 8(index) 9
21: 20(ptr) AccessChain 16(str) 17 18
Store 21 19
23: 6(int) Load 8(index)
25: 6(int) ISub 23 24
Store 8(index) 25
26: 20(ptr) AccessChain 16(str) 17 25
27: 10(float) Load 26
29: 10(float) FAdd 27 28
Store 26 29
Store 22(t) 29
30: 10(float) Load 22(t)
31: 20(ptr) AccessChain 16(str) 17 18
32: 10(float) Load 31
33: 10(float) FAdd 32 30
34: 20(ptr) AccessChain 16(str) 17 18
Store 34 33
35: 20(ptr) AccessChain 16(str) 17 18
36: 10(float) Load 35
37: 10(float) FSub 36 28
Store 35 37
Store 22(t) 36
38: 6(int) Load 8(index)
39: 6(int) IAdd 38 24
Store 8(index) 39
40: 10(float) Load 22(t)
41: 20(ptr) AccessChain 16(str) 17 38
42: 10(float) Load 41
43: 10(float) FAdd 42 40
44: 20(ptr) AccessChain 16(str) 17 38
Store 44 43
45: 6(int) Load 8(index)
46: 6(int) ISub 45 24
Store 8(index) 46
47: 20(ptr) AccessChain 16(str) 17 46
48: 10(float) Load 47
49: 10(float) FSub 48 28
Store 47 49
51: 20(ptr) AccessChain 16(str) 17 18
52: 10(float) Load 51
Store 50(x) 52
53: 10(float) Load 50(x)
54: 10(float) FAdd 53 28
Store 50(x) 54
55: 10(float) Load 50(x)
56: 10(float) FSub 55 28
Store 50(x) 56
57: 10(float) Load 50(x)
58: 10(float) FAdd 57 28
Store 50(x) 58
59: 10(float) Load 50(x)
60: 10(float) FSub 59 28
Store 50(x) 60
62: 10(float) Load 50(x)
63: 10(float) Load 50(x)
64: 10(float) FAdd 63 28
Store 50(x) 64
65: 10(float) FMul 62 64
Store 61(y) 65
67: 10(float) Load 61(y)
68: 10(float) Load 50(x)
69: 10(float) FSub 68 28
Store 50(x) 69
70: 10(float) FMul 67 68
Store 66(z) 70
Store 73(v) 76
77: 71(fvec4) Load 73(v)
78: 10(float) CompositeExtract 77 2
79: 10(float) FSub 78 28
80: 71(fvec4) Load 73(v)
81: 71(fvec4) CompositeInsert 79 80 2
Store 73(v) 81
82: 71(fvec4) Load 73(v)
83: 71(fvec4) CompositeInsert 78 82 1
Store 73(v) 83
84: 71(fvec4) Load 73(v)
85: 10(float) CompositeExtract 84 3
86: 10(float) FSub 85 28
87: 71(fvec4) Load 73(v)
88: 71(fvec4) CompositeInsert 86 87 3
Store 73(v) 88
89: 71(fvec4) Load 73(v)
90: 71(fvec4) CompositeInsert 86 89 0
Store 73(v) 90
93: 10(float) Load 66(z)
94: 71(fvec4) Load 73(v)
95: 71(fvec4) VectorTimesScalar 94 93
Store 92(gl_FragColor) 95
Return
FunctionEnd