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 43
// Id's are bound by 42
Source GLSL 120
Capability Shader
@ -14,67 +14,65 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 7 "foo("
Name 9 "foo2("
Name 13 "bar"
Name 23 "outColor"
Name 25 "bigColor"
Name 36 "gl_FragColor"
Name 40 "BaseColor"
Name 42 "d"
Decorate 36(gl_FragColor) BuiltIn FragColor
Decorate 40(BaseColor) Smooth
Decorate 40(BaseColor) NoStaticUse
Decorate 42(d) NoStaticUse
Name 6 "foo("
Name 8 "foo2("
Name 12 "bar"
Name 22 "outColor"
Name 24 "bigColor"
Name 35 "gl_FragColor"
Name 39 "BaseColor"
Name 41 "d"
Decorate 35(gl_FragColor) BuiltIn FragColor
Decorate 39(BaseColor) Smooth
Decorate 39(BaseColor) NoStaticUse
Decorate 41(d) NoStaticUse
2: TypeVoid
3: TypeFunction 2
11: TypeFloat 32
12: TypePointer PrivateGlobal 11(float)
13(bar): 12(ptr) Variable PrivateGlobal
14: 11(float) Constant 1073741824
16: 11(float) Constant 1065353216
21: TypeVector 11(float) 4
22: TypePointer Function 21(fvec4)
24: TypePointer UniformConstant 21(fvec4)
25(bigColor): 24(ptr) Variable UniformConstant
35: TypePointer Output 21(fvec4)
36(gl_FragColor): 35(ptr) Variable Output
39: TypePointer Input 21(fvec4)
40(BaseColor): 39(ptr) Variable Input
41: TypePointer UniformConstant 11(float)
42(d): 41(ptr) Variable UniformConstant
10: TypeFloat 32
11: TypePointer PrivateGlobal 10(float)
12(bar): 11(ptr) Variable PrivateGlobal
13: 10(float) Constant 1073741824
15: 10(float) Constant 1065353216
20: TypeVector 10(float) 4
21: TypePointer Function 20(fvec4)
23: TypePointer UniformConstant 20(fvec4)
24(bigColor): 23(ptr) Variable UniformConstant
34: TypePointer Output 20(fvec4)
35(gl_FragColor): 34(ptr) Variable Output
38: TypePointer Input 20(fvec4)
39(BaseColor): 38(ptr) Variable Input
40: TypePointer UniformConstant 10(float)
41(d): 40(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
23(outColor): 22(ptr) Variable Function
Store 13(bar) 14
26: 21(fvec4) Load 25(bigColor)
Store 23(outColor) 26
27: 2 FunctionCall 7(foo()
28: 2 FunctionCall 9(foo2()
29: 11(float) Load 13(bar)
30: 21(fvec4) Load 23(outColor)
31: 11(float) CompositeExtract 30 0
32: 11(float) FAdd 31 29
33: 21(fvec4) Load 23(outColor)
34: 21(fvec4) CompositeInsert 32 33 0
Store 23(outColor) 34
37: 21(fvec4) Load 23(outColor)
Store 36(gl_FragColor) 37
Branch 6
6: Label
22(outColor): 21(ptr) Variable Function
Store 12(bar) 13
25: 20(fvec4) Load 24(bigColor)
Store 22(outColor) 25
26: 2 FunctionCall 6(foo()
27: 2 FunctionCall 8(foo2()
28: 10(float) Load 12(bar)
29: 20(fvec4) Load 22(outColor)
30: 10(float) CompositeExtract 29 0
31: 10(float) FAdd 30 28
32: 20(fvec4) Load 22(outColor)
33: 20(fvec4) CompositeInsert 31 32 0
Store 22(outColor) 33
36: 20(fvec4) Load 22(outColor)
Store 35(gl_FragColor) 36
Return
FunctionEnd
7(foo(): 2 Function None 3
8: Label
15: 11(float) Load 13(bar)
17: 11(float) FAdd 15 16
Store 13(bar) 17
6(foo(): 2 Function None 3
7: Label
14: 10(float) Load 12(bar)
16: 10(float) FAdd 14 15
Store 12(bar) 16
Return
FunctionEnd
9(foo2(): 2 Function None 3
10: Label
19: 11(float) Load 13(bar)
20: 11(float) FAdd 19 16
Store 13(bar) 20
8(foo2(): 2 Function None 3
9: Label
18: 10(float) Load 12(bar)
19: 10(float) FAdd 18 15
Store 12(bar) 19
Return
FunctionEnd