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 48
// Id's are bound by 47
Source ESSL 100
Capability Shader
@@ -14,75 +14,73 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 9 "foo("
Name 12 "face1"
Name 14 "face2"
Name 18 "z"
Name 22 "low"
Name 27 "high"
Name 37 "gl_FragColor"
Decorate 12(face1) RelaxedPrecision
Decorate 14(face2) RelaxedPrecision
Decorate 18(z) RelaxedPrecision
Decorate 22(low) RelaxedPrecision
Decorate 27(high) RelaxedPrecision
Decorate 37(gl_FragColor) RelaxedPrecision
Decorate 37(gl_FragColor) BuiltIn FragColor
Name 8 "foo("
Name 11 "face1"
Name 13 "face2"
Name 17 "z"
Name 21 "low"
Name 26 "high"
Name 36 "gl_FragColor"
Decorate 11(face1) RelaxedPrecision
Decorate 13(face2) RelaxedPrecision
Decorate 17(z) RelaxedPrecision
Decorate 21(low) RelaxedPrecision
Decorate 26(high) RelaxedPrecision
Decorate 36(gl_FragColor) RelaxedPrecision
Decorate 36(gl_FragColor) BuiltIn FragColor
2: TypeVoid
3: TypeFunction 2
7: TypeFloat 32
8: TypeFunction 7(float)
11: TypePointer PrivateGlobal 7(float)
12(face1): 11(ptr) Variable PrivateGlobal
13: 7(float) Constant 1093664768
14(face2): 11(ptr) Variable PrivateGlobal
15: 7(float) Constant 3221225472
16: TypeInt 32 1
17: TypePointer Function 16(int)
19: 16(int) Constant 3
20: 16(int) Constant 2
21: TypePointer UniformConstant 16(int)
22(low): 21(ptr) Variable UniformConstant
25: 16(int) Constant 1
27(high): 21(ptr) Variable UniformConstant
29: TypeBool
35: TypeVector 7(float) 4
36: TypePointer Output 35(fvec4)
37(gl_FragColor): 36(ptr) Variable Output
6: TypeFloat 32
7: TypeFunction 6(float)
10: TypePointer PrivateGlobal 6(float)
11(face1): 10(ptr) Variable PrivateGlobal
12: 6(float) Constant 1093664768
13(face2): 10(ptr) Variable PrivateGlobal
14: 6(float) Constant 3221225472
15: TypeInt 32 1
16: TypePointer Function 15(int)
18: 15(int) Constant 3
19: 15(int) Constant 2
20: TypePointer UniformConstant 15(int)
21(low): 20(ptr) Variable UniformConstant
24: 15(int) Constant 1
26(high): 20(ptr) Variable UniformConstant
28: TypeBool
34: TypeVector 6(float) 4
35: TypePointer Output 34(fvec4)
36(gl_FragColor): 35(ptr) Variable Output
4(main): 2 Function None 3
5: Label
18(z): 17(ptr) Variable Function
Store 12(face1) 13
Store 14(face2) 15
Store 18(z) 19
23: 16(int) Load 22(low)
24: 16(int) IMul 20 23
26: 16(int) IAdd 24 25
28: 16(int) Load 27(high)
30: 29(bool) SLessThan 26 28
SelectionMerge 32 None
BranchConditional 30 31 32
31: Label
33: 16(int) Load 18(z)
34: 16(int) IAdd 33 25
Store 18(z) 34
Branch 32
32: Label
38: 7(float) Load 12(face1)
39: 16(int) Load 18(z)
40: 7(float) ConvertSToF 39
41: 35(fvec4) CompositeConstruct 40 40 40 40
42: 35(fvec4) VectorTimesScalar 41 38
43: 7(float) FunctionCall 9(foo()
44: 35(fvec4) CompositeConstruct 43 43 43 43
45: 35(fvec4) FAdd 42 44
Store 37(gl_FragColor) 45
Branch 6
6: Label
17(z): 16(ptr) Variable Function
Store 11(face1) 12
Store 13(face2) 14
Store 17(z) 18
22: 15(int) Load 21(low)
23: 15(int) IMul 19 22
25: 15(int) IAdd 23 24
27: 15(int) Load 26(high)
29: 28(bool) SLessThan 25 27
SelectionMerge 31 None
BranchConditional 29 30 31
30: Label
32: 15(int) Load 17(z)
33: 15(int) IAdd 32 24
Store 17(z) 33
Branch 31
31: Label
37: 6(float) Load 11(face1)
38: 15(int) Load 17(z)
39: 6(float) ConvertSToF 38
40: 34(fvec4) CompositeConstruct 39 39 39 39
41: 34(fvec4) VectorTimesScalar 40 37
42: 6(float) FunctionCall 8(foo()
43: 34(fvec4) CompositeConstruct 42 42 42 42
44: 34(fvec4) FAdd 41 43
Store 36(gl_FragColor) 44
Return
FunctionEnd
9(foo(): 7(float) Function None 8
10: Label
46: 7(float) Load 14(face2)
ReturnValue 46
8(foo(): 6(float) Function None 7
9: Label
45: 6(float) Load 13(face2)
ReturnValue 45
FunctionEnd