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