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

@ -10,7 +10,7 @@ Linked fragment stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 62
// Id's are bound by 61
Source GLSL 130
Capability Shader
@ -19,82 +19,80 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 10 "texColor"
Name 14 "texSampler2D"
Name 20 "gl_TexCoord"
Name 35 "color"
Name 40 "alpha"
Name 45 "gl_FragColor"
Name 49 "foo"
Decorate 20(gl_TexCoord) Smooth
Decorate 35(color) Smooth
Decorate 40(alpha) Smooth
Decorate 45(gl_FragColor) BuiltIn FragColor
Decorate 49(foo) Smooth
Name 9 "texColor"
Name 13 "texSampler2D"
Name 19 "gl_TexCoord"
Name 34 "color"
Name 39 "alpha"
Name 44 "gl_FragColor"
Name 48 "foo"
Decorate 19(gl_TexCoord) Smooth
Decorate 34(color) Smooth
Decorate 39(alpha) Smooth
Decorate 44(gl_FragColor) BuiltIn FragColor
Decorate 48(foo) Smooth
2: TypeVoid
3: TypeFunction 2
7: TypeFloat 32
8: TypeVector 7(float) 4
9: TypePointer Function 8(fvec4)
11: TypeImage 7(float) 2D sampled format:Unknown
12: TypeSampledImage 11
13: TypePointer UniformConstant 12
14(texSampler2D): 13(ptr) Variable UniformConstant
16: TypeInt 32 0
17: 16(int) Constant 6
18: TypeArray 8(fvec4) 17
19: TypePointer Input 18
20(gl_TexCoord): 19(ptr) Variable Input
21: TypeInt 32 1
22: 21(int) Constant 4
23: TypePointer Input 8(fvec4)
26: 21(int) Constant 5
30: TypeVector 7(float) 2
35(color): 23(ptr) Variable Input
39: TypePointer Input 7(float)
40(alpha): 39(ptr) Variable Input
44: TypePointer Output 8(fvec4)
45(gl_FragColor): 44(ptr) Variable Output
46: 16(int) Constant 3
47: TypeArray 8(fvec4) 46
48: TypePointer Input 47
49(foo): 48(ptr) Variable Input
50: 21(int) Constant 1
53: 21(int) Constant 0
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: TypeImage 6(float) 2D sampled format:Unknown
11: TypeSampledImage 10
12: TypePointer UniformConstant 11
13(texSampler2D): 12(ptr) Variable UniformConstant
15: TypeInt 32 0
16: 15(int) Constant 6
17: TypeArray 7(fvec4) 16
18: TypePointer Input 17
19(gl_TexCoord): 18(ptr) Variable Input
20: TypeInt 32 1
21: 20(int) Constant 4
22: TypePointer Input 7(fvec4)
25: 20(int) Constant 5
29: TypeVector 6(float) 2
34(color): 22(ptr) Variable Input
38: TypePointer Input 6(float)
39(alpha): 38(ptr) Variable Input
43: TypePointer Output 7(fvec4)
44(gl_FragColor): 43(ptr) Variable Output
45: 15(int) Constant 3
46: TypeArray 7(fvec4) 45
47: TypePointer Input 46
48(foo): 47(ptr) Variable Input
49: 20(int) Constant 1
52: 20(int) Constant 0
4(main): 2 Function None 3
5: Label
10(texColor): 9(ptr) Variable Function
15: 12 Load 14(texSampler2D)
24: 23(ptr) AccessChain 20(gl_TexCoord) 22
25: 8(fvec4) Load 24
27: 23(ptr) AccessChain 20(gl_TexCoord) 26
28: 8(fvec4) Load 27
29: 8(fvec4) FAdd 25 28
31: 7(float) CompositeExtract 29 0
32: 7(float) CompositeExtract 29 1
33: 30(fvec2) CompositeConstruct 31 32
34: 8(fvec4) ImageSampleImplicitLod 15 33
Store 10(texColor) 34
36: 8(fvec4) Load 35(color)
37: 8(fvec4) Load 10(texColor)
38: 8(fvec4) FAdd 37 36
Store 10(texColor) 38
41: 7(float) Load 40(alpha)
42: 8(fvec4) Load 10(texColor)
43: 8(fvec4) CompositeInsert 41 42 3
Store 10(texColor) 43
51: 23(ptr) AccessChain 49(foo) 50
52: 8(fvec4) Load 51
54: 23(ptr) AccessChain 20(gl_TexCoord) 53
55: 8(fvec4) Load 54
56: 8(fvec4) FAdd 52 55
57: 23(ptr) AccessChain 20(gl_TexCoord) 22
58: 8(fvec4) Load 57
59: 8(fvec4) FAdd 56 58
60: 8(fvec4) Load 10(texColor)
61: 8(fvec4) FAdd 59 60
Store 45(gl_FragColor) 61
Branch 6
6: Label
9(texColor): 8(ptr) Variable Function
14: 11 Load 13(texSampler2D)
23: 22(ptr) AccessChain 19(gl_TexCoord) 21
24: 7(fvec4) Load 23
26: 22(ptr) AccessChain 19(gl_TexCoord) 25
27: 7(fvec4) Load 26
28: 7(fvec4) FAdd 24 27
30: 6(float) CompositeExtract 28 0
31: 6(float) CompositeExtract 28 1
32: 29(fvec2) CompositeConstruct 30 31
33: 7(fvec4) ImageSampleImplicitLod 14 32
Store 9(texColor) 33
35: 7(fvec4) Load 34(color)
36: 7(fvec4) Load 9(texColor)
37: 7(fvec4) FAdd 36 35
Store 9(texColor) 37
40: 6(float) Load 39(alpha)
41: 7(fvec4) Load 9(texColor)
42: 7(fvec4) CompositeInsert 40 41 3
Store 9(texColor) 42
50: 22(ptr) AccessChain 48(foo) 49
51: 7(fvec4) Load 50
53: 22(ptr) AccessChain 19(gl_TexCoord) 52
54: 7(fvec4) Load 53
55: 7(fvec4) FAdd 51 54
56: 22(ptr) AccessChain 19(gl_TexCoord) 21
57: 7(fvec4) Load 56
58: 7(fvec4) FAdd 55 57
59: 7(fvec4) Load 9(texColor)
60: 7(fvec4) FAdd 58 59
Store 44(gl_FragColor) 60
Return
FunctionEnd