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:
@@ -7,7 +7,7 @@ Linked fragment stage:
|
||||
|
||||
// Module Version 99
|
||||
// Generated by (magic number): 51a00bb
|
||||
// Id's are bound by 74
|
||||
// Id's are bound by 73
|
||||
|
||||
Source GLSL 130
|
||||
Capability Shader
|
||||
@@ -16,113 +16,111 @@ Linked fragment stage:
|
||||
EntryPoint Fragment 4 "main"
|
||||
ExecutionMode 4 OriginLowerLeft
|
||||
Name 4 "main"
|
||||
Name 12 "foo(vf4;"
|
||||
Name 11 "bar"
|
||||
Name 14 "bar("
|
||||
Name 17 "unreachableReturn("
|
||||
Name 19 "missingReturn("
|
||||
Name 22 "h"
|
||||
Name 31 "d"
|
||||
Name 52 "color"
|
||||
Name 54 "BaseColor"
|
||||
Name 55 "param"
|
||||
Name 61 "f"
|
||||
Name 63 "g"
|
||||
Name 66 "gl_FragColor"
|
||||
Name 73 "bigColor"
|
||||
Decorate 54(BaseColor) Smooth
|
||||
Decorate 66(gl_FragColor) BuiltIn FragColor
|
||||
Decorate 73(bigColor) NoStaticUse
|
||||
Name 11 "foo(vf4;"
|
||||
Name 10 "bar"
|
||||
Name 13 "bar("
|
||||
Name 16 "unreachableReturn("
|
||||
Name 18 "missingReturn("
|
||||
Name 21 "h"
|
||||
Name 30 "d"
|
||||
Name 51 "color"
|
||||
Name 53 "BaseColor"
|
||||
Name 54 "param"
|
||||
Name 60 "f"
|
||||
Name 62 "g"
|
||||
Name 65 "gl_FragColor"
|
||||
Name 72 "bigColor"
|
||||
Decorate 53(BaseColor) Smooth
|
||||
Decorate 65(gl_FragColor) BuiltIn FragColor
|
||||
Decorate 72(bigColor) NoStaticUse
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
7: TypeFloat 32
|
||||
8: TypeVector 7(float) 4
|
||||
9: TypePointer Function 8(fvec4)
|
||||
10: TypeFunction 7(float) 9(ptr)
|
||||
16: TypeFunction 7(float)
|
||||
21: TypePointer PrivateGlobal 7(float)
|
||||
22(h): 21(ptr) Variable PrivateGlobal
|
||||
23: 7(float) Constant 0
|
||||
30: TypePointer UniformConstant 7(float)
|
||||
31(d): 30(ptr) Variable UniformConstant
|
||||
33: 7(float) Constant 1082549862
|
||||
34: TypeBool
|
||||
38: 7(float) Constant 1067030938
|
||||
41: 7(float) Constant 1083179008
|
||||
49: 7(float) Constant 1081711002
|
||||
53: TypePointer Input 8(fvec4)
|
||||
54(BaseColor): 53(ptr) Variable Input
|
||||
60: TypePointer Function 7(float)
|
||||
65: TypePointer Output 8(fvec4)
|
||||
66(gl_FragColor): 65(ptr) Variable Output
|
||||
72: TypePointer UniformConstant 8(fvec4)
|
||||
73(bigColor): 72(ptr) Variable UniformConstant
|
||||
6: TypeFloat 32
|
||||
7: TypeVector 6(float) 4
|
||||
8: TypePointer Function 7(fvec4)
|
||||
9: TypeFunction 6(float) 8(ptr)
|
||||
15: TypeFunction 6(float)
|
||||
20: TypePointer PrivateGlobal 6(float)
|
||||
21(h): 20(ptr) Variable PrivateGlobal
|
||||
22: 6(float) Constant 0
|
||||
29: TypePointer UniformConstant 6(float)
|
||||
30(d): 29(ptr) Variable UniformConstant
|
||||
32: 6(float) Constant 1082549862
|
||||
33: TypeBool
|
||||
37: 6(float) Constant 1067030938
|
||||
40: 6(float) Constant 1083179008
|
||||
48: 6(float) Constant 1081711002
|
||||
52: TypePointer Input 7(fvec4)
|
||||
53(BaseColor): 52(ptr) Variable Input
|
||||
59: TypePointer Function 6(float)
|
||||
64: TypePointer Output 7(fvec4)
|
||||
65(gl_FragColor): 64(ptr) Variable Output
|
||||
71: TypePointer UniformConstant 7(fvec4)
|
||||
72(bigColor): 71(ptr) Variable UniformConstant
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
52(color): 9(ptr) Variable Function
|
||||
55(param): 9(ptr) Variable Function
|
||||
61(f): 60(ptr) Variable Function
|
||||
63(g): 60(ptr) Variable Function
|
||||
Store 22(h) 23
|
||||
56: 8(fvec4) Load 54(BaseColor)
|
||||
Store 55(param) 56
|
||||
57: 7(float) FunctionCall 12(foo(vf4;) 55(param)
|
||||
58: 8(fvec4) CompositeConstruct 57 57 57 57
|
||||
Store 52(color) 58
|
||||
59: 2 FunctionCall 14(bar()
|
||||
62: 7(float) FunctionCall 17(unreachableReturn()
|
||||
Store 61(f) 62
|
||||
64: 7(float) FunctionCall 19(missingReturn()
|
||||
Store 63(g) 64
|
||||
67: 8(fvec4) Load 52(color)
|
||||
68: 7(float) Load 61(f)
|
||||
69: 8(fvec4) VectorTimesScalar 67 68
|
||||
70: 7(float) Load 22(h)
|
||||
71: 8(fvec4) VectorTimesScalar 69 70
|
||||
Store 66(gl_FragColor) 71
|
||||
Branch 6
|
||||
6: Label
|
||||
51(color): 8(ptr) Variable Function
|
||||
54(param): 8(ptr) Variable Function
|
||||
60(f): 59(ptr) Variable Function
|
||||
62(g): 59(ptr) Variable Function
|
||||
Store 21(h) 22
|
||||
55: 7(fvec4) Load 53(BaseColor)
|
||||
Store 54(param) 55
|
||||
56: 6(float) FunctionCall 11(foo(vf4;) 54(param)
|
||||
57: 7(fvec4) CompositeConstruct 56 56 56 56
|
||||
Store 51(color) 57
|
||||
58: 2 FunctionCall 13(bar()
|
||||
61: 6(float) FunctionCall 16(unreachableReturn()
|
||||
Store 60(f) 61
|
||||
63: 6(float) FunctionCall 18(missingReturn()
|
||||
Store 62(g) 63
|
||||
66: 7(fvec4) Load 51(color)
|
||||
67: 6(float) Load 60(f)
|
||||
68: 7(fvec4) VectorTimesScalar 66 67
|
||||
69: 6(float) Load 21(h)
|
||||
70: 7(fvec4) VectorTimesScalar 68 69
|
||||
Store 65(gl_FragColor) 70
|
||||
Return
|
||||
FunctionEnd
|
||||
12(foo(vf4;): 7(float) Function None 10
|
||||
11(bar): 9(ptr) FunctionParameter
|
||||
13: Label
|
||||
24: 8(fvec4) Load 11(bar)
|
||||
25: 7(float) CompositeExtract 24 0
|
||||
26: 8(fvec4) Load 11(bar)
|
||||
27: 7(float) CompositeExtract 26 1
|
||||
28: 7(float) FAdd 25 27
|
||||
ReturnValue 28
|
||||
11(foo(vf4;): 6(float) Function None 9
|
||||
10(bar): 8(ptr) FunctionParameter
|
||||
12: Label
|
||||
23: 7(fvec4) Load 10(bar)
|
||||
24: 6(float) CompositeExtract 23 0
|
||||
25: 7(fvec4) Load 10(bar)
|
||||
26: 6(float) CompositeExtract 25 1
|
||||
27: 6(float) FAdd 24 26
|
||||
ReturnValue 27
|
||||
FunctionEnd
|
||||
14(bar(): 2 Function None 3
|
||||
15: Label
|
||||
13(bar(): 2 Function None 3
|
||||
14: Label
|
||||
Return
|
||||
FunctionEnd
|
||||
17(unreachableReturn(): 7(float) Function None 16
|
||||
18: Label
|
||||
32: 7(float) Load 31(d)
|
||||
35: 34(bool) FOrdLessThan 32 33
|
||||
SelectionMerge 37 None
|
||||
BranchConditional 35 36 40
|
||||
36: Label
|
||||
ReturnValue 38
|
||||
40: Label
|
||||
ReturnValue 41
|
||||
37: Label
|
||||
43: 7(float) Undef
|
||||
ReturnValue 43
|
||||
16(unreachableReturn(): 6(float) Function None 15
|
||||
17: Label
|
||||
31: 6(float) Load 30(d)
|
||||
34: 33(bool) FOrdLessThan 31 32
|
||||
SelectionMerge 36 None
|
||||
BranchConditional 34 35 39
|
||||
35: Label
|
||||
ReturnValue 37
|
||||
39: Label
|
||||
ReturnValue 40
|
||||
36: Label
|
||||
42: 6(float) Undef
|
||||
ReturnValue 42
|
||||
FunctionEnd
|
||||
19(missingReturn(): 7(float) Function None 16
|
||||
20: Label
|
||||
44: 7(float) Load 31(d)
|
||||
45: 34(bool) FOrdLessThan 44 41
|
||||
SelectionMerge 47 None
|
||||
BranchConditional 45 46 47
|
||||
46: Label
|
||||
48: 7(float) Load 31(d)
|
||||
Store 22(h) 48
|
||||
ReturnValue 49
|
||||
47: Label
|
||||
51: 7(float) Undef
|
||||
ReturnValue 51
|
||||
18(missingReturn(): 6(float) Function None 15
|
||||
19: Label
|
||||
43: 6(float) Load 30(d)
|
||||
44: 33(bool) FOrdLessThan 43 40
|
||||
SelectionMerge 46 None
|
||||
BranchConditional 44 45 46
|
||||
45: Label
|
||||
47: 6(float) Load 30(d)
|
||||
Store 21(h) 47
|
||||
ReturnValue 48
|
||||
46: Label
|
||||
50: 6(float) Undef
|
||||
ReturnValue 50
|
||||
FunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user