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 93
// Id's are bound by 92
Source GLSL 140
Capability Shader
@ -14,151 +14,149 @@ Linked fragment stage:
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 9 "foo("
Name 12 "i1"
Name 17 "gl_FrontFacing"
Name 25 "i2"
Name 29 "o"
Name 34 "gl_ClipDistance"
Name 43 "k"
Name 55 "sampR"
Name 62 "sampB"
Name 86 "samp2Da"
Name 90 "bn"
MemberName 90(bn) 0 "matra"
MemberName 90(bn) 1 "matca"
MemberName 90(bn) 2 "matr"
MemberName 90(bn) 3 "matc"
MemberName 90(bn) 4 "matrdef"
Name 92 ""
Decorate 17(gl_FrontFacing) BuiltIn FrontFacing
Decorate 34(gl_ClipDistance) Smooth
Decorate 34(gl_ClipDistance) BuiltIn ClipDistance
Decorate 43(k) Smooth
Decorate 86(samp2Da) NoStaticUse
Decorate 89 ArrayStride 64
Decorate 89 ArrayStride 64
MemberDecorate 90(bn) 0 RowMajor
MemberDecorate 90(bn) 0 Offset 0
MemberDecorate 90(bn) 0 MatrixStride 16
MemberDecorate 90(bn) 1 ColMajor
MemberDecorate 90(bn) 1 Offset 256
MemberDecorate 90(bn) 1 MatrixStride 16
MemberDecorate 90(bn) 2 RowMajor
MemberDecorate 90(bn) 2 Offset 512
MemberDecorate 90(bn) 2 MatrixStride 16
MemberDecorate 90(bn) 3 ColMajor
MemberDecorate 90(bn) 3 Offset 576
MemberDecorate 90(bn) 3 MatrixStride 16
MemberDecorate 90(bn) 4 RowMajor
MemberDecorate 90(bn) 4 Offset 640
MemberDecorate 90(bn) 4 MatrixStride 16
Decorate 90(bn) Block
Decorate 92 NoStaticUse
Name 8 "foo("
Name 11 "i1"
Name 16 "gl_FrontFacing"
Name 24 "i2"
Name 28 "o"
Name 33 "gl_ClipDistance"
Name 42 "k"
Name 54 "sampR"
Name 61 "sampB"
Name 85 "samp2Da"
Name 89 "bn"
MemberName 89(bn) 0 "matra"
MemberName 89(bn) 1 "matca"
MemberName 89(bn) 2 "matr"
MemberName 89(bn) 3 "matc"
MemberName 89(bn) 4 "matrdef"
Name 91 ""
Decorate 16(gl_FrontFacing) BuiltIn FrontFacing
Decorate 33(gl_ClipDistance) Smooth
Decorate 33(gl_ClipDistance) BuiltIn ClipDistance
Decorate 42(k) Smooth
Decorate 85(samp2Da) NoStaticUse
Decorate 88 ArrayStride 64
Decorate 88 ArrayStride 64
MemberDecorate 89(bn) 0 RowMajor
MemberDecorate 89(bn) 0 Offset 0
MemberDecorate 89(bn) 0 MatrixStride 16
MemberDecorate 89(bn) 1 ColMajor
MemberDecorate 89(bn) 1 Offset 256
MemberDecorate 89(bn) 1 MatrixStride 16
MemberDecorate 89(bn) 2 RowMajor
MemberDecorate 89(bn) 2 Offset 512
MemberDecorate 89(bn) 2 MatrixStride 16
MemberDecorate 89(bn) 3 ColMajor
MemberDecorate 89(bn) 3 Offset 576
MemberDecorate 89(bn) 3 MatrixStride 16
MemberDecorate 89(bn) 4 RowMajor
MemberDecorate 89(bn) 4 Offset 640
MemberDecorate 89(bn) 4 MatrixStride 16
Decorate 89(bn) Block
Decorate 91 NoStaticUse
2: TypeVoid
3: TypeFunction 2
7: TypeFloat 32
8: TypeFunction 7(float)
11: TypePointer PrivateGlobal 7(float)
12(i1): 11(ptr) Variable PrivateGlobal
13: TypePointer Function 7(float)
15: TypeBool
16: TypePointer Input 15(bool)
17(gl_FrontFacing): 16(ptr) Variable Input
21: 7(float) Constant 3221225472
23: 7(float) Constant 1073741824
25(i2): 11(ptr) Variable PrivateGlobal
26: 7(float) Constant 1120665600
27: TypeVector 7(float) 4
28: TypePointer Output 27(fvec4)
29(o): 28(ptr) Variable Output
30: TypeInt 32 0
31: 30(int) Constant 5
32: TypeArray 7(float) 31
33: TypePointer Input 32
34(gl_ClipDistance): 33(ptr) Variable Input
35: TypeInt 32 1
36: 35(int) Constant 2
37: TypePointer Input 7(float)
42: TypePointer Input 27(fvec4)
43(k): 42(ptr) Variable Input
45: TypeVector 35(int) 4
52: TypeImage 7(float) Rect sampled format:Unknown
53: TypeSampledImage 52
54: TypePointer UniformConstant 53
55(sampR): 54(ptr) Variable UniformConstant
57: TypeVector 35(int) 2
59: TypeImage 35(int) Buffer sampled format:Unknown
60: TypeSampledImage 59
61: TypePointer UniformConstant 60
62(sampB): 61(ptr) Variable UniformConstant
67: TypeVector 7(float) 2
70: 7(float) Constant 1120403456
81: TypeImage 7(float) 2D sampled format:Unknown
82: TypeSampledImage 81
83: 30(int) Constant 3
84: TypeArray 82 83
85: TypePointer UniformConstant 84
86(samp2Da): 85(ptr) Variable UniformConstant
87: TypeMatrix 27(fvec4) 4
88: 30(int) Constant 4
89: TypeArray 87 88
90(bn): TypeStruct 89 89 87 87 87
91: TypePointer Uniform 90(bn)
92: 91(ptr) Variable Uniform
6: TypeFloat 32
7: TypeFunction 6(float)
10: TypePointer PrivateGlobal 6(float)
11(i1): 10(ptr) Variable PrivateGlobal
12: TypePointer Function 6(float)
14: TypeBool
15: TypePointer Input 14(bool)
16(gl_FrontFacing): 15(ptr) Variable Input
20: 6(float) Constant 3221225472
22: 6(float) Constant 1073741824
24(i2): 10(ptr) Variable PrivateGlobal
25: 6(float) Constant 1120665600
26: TypeVector 6(float) 4
27: TypePointer Output 26(fvec4)
28(o): 27(ptr) Variable Output
29: TypeInt 32 0
30: 29(int) Constant 5
31: TypeArray 6(float) 30
32: TypePointer Input 31
33(gl_ClipDistance): 32(ptr) Variable Input
34: TypeInt 32 1
35: 34(int) Constant 2
36: TypePointer Input 6(float)
41: TypePointer Input 26(fvec4)
42(k): 41(ptr) Variable Input
44: TypeVector 34(int) 4
51: TypeImage 6(float) Rect sampled format:Unknown
52: TypeSampledImage 51
53: TypePointer UniformConstant 52
54(sampR): 53(ptr) Variable UniformConstant
56: TypeVector 34(int) 2
58: TypeImage 34(int) Buffer sampled format:Unknown
59: TypeSampledImage 58
60: TypePointer UniformConstant 59
61(sampB): 60(ptr) Variable UniformConstant
66: TypeVector 6(float) 2
69: 6(float) Constant 1120403456
80: TypeImage 6(float) 2D sampled format:Unknown
81: TypeSampledImage 80
82: 29(int) Constant 3
83: TypeArray 81 82
84: TypePointer UniformConstant 83
85(samp2Da): 84(ptr) Variable UniformConstant
86: TypeMatrix 26(fvec4) 4
87: 29(int) Constant 4
88: TypeArray 86 87
89(bn): TypeStruct 88 88 86 86 86
90: TypePointer Uniform 89(bn)
91: 90(ptr) Variable Uniform
4(main): 2 Function None 3
5: Label
14: 13(ptr) Variable Function
18: 15(bool) Load 17(gl_FrontFacing)
SelectionMerge 20 None
BranchConditional 18 19 22
19: Label
Store 14 21
Branch 20
22: Label
Store 14 23
Branch 20
20: Label
24: 7(float) Load 14
Store 12(i1) 24
Store 25(i2) 26
38: 37(ptr) AccessChain 34(gl_ClipDistance) 36
39: 7(float) Load 38
40: 27(fvec4) Load 29(o)
41: 27(fvec4) CompositeInsert 39 40 1
Store 29(o) 41
44: 27(fvec4) Load 43(k)
46: 45(ivec4) ConvertFToS 44
47: 35(int) CompositeExtract 46 0
48: 37(ptr) AccessChain 34(gl_ClipDistance) 47
49: 7(float) Load 48
50: 27(fvec4) Load 29(o)
51: 27(fvec4) CompositeInsert 49 50 2
Store 29(o) 51
56: 53 Load 55(sampR)
58: 57(ivec2) ImageQuerySize 56
63: 60 Load 62(sampB)
64: 35(int) ImageQuerySize 63
65: 57(ivec2) CompositeConstruct 64 64
66: 57(ivec2) IAdd 58 65
68: 67(fvec2) ConvertSToF 66
69: 7(float) CompositeExtract 68 0
71: 7(float) FDiv 69 70
72: 27(fvec4) Load 29(o)
73: 27(fvec4) CompositeInsert 71 72 3
Store 29(o) 73
74: 7(float) FunctionCall 9(foo()
75: 27(fvec4) Load 29(o)
76: 27(fvec4) CompositeInsert 74 75 2
Store 29(o) 76
Branch 6
6: Label
13: 12(ptr) Variable Function
17: 14(bool) Load 16(gl_FrontFacing)
SelectionMerge 19 None
BranchConditional 17 18 21
18: Label
Store 13 20
Branch 19
21: Label
Store 13 22
Branch 19
19: Label
23: 6(float) Load 13
Store 11(i1) 23
Store 24(i2) 25
37: 36(ptr) AccessChain 33(gl_ClipDistance) 35
38: 6(float) Load 37
39: 26(fvec4) Load 28(o)
40: 26(fvec4) CompositeInsert 38 39 1
Store 28(o) 40
43: 26(fvec4) Load 42(k)
45: 44(ivec4) ConvertFToS 43
46: 34(int) CompositeExtract 45 0
47: 36(ptr) AccessChain 33(gl_ClipDistance) 46
48: 6(float) Load 47
49: 26(fvec4) Load 28(o)
50: 26(fvec4) CompositeInsert 48 49 2
Store 28(o) 50
55: 52 Load 54(sampR)
57: 56(ivec2) ImageQuerySize 55
62: 59 Load 61(sampB)
63: 34(int) ImageQuerySize 62
64: 56(ivec2) CompositeConstruct 63 63
65: 56(ivec2) IAdd 57 64
67: 66(fvec2) ConvertSToF 65
68: 6(float) CompositeExtract 67 0
70: 6(float) FDiv 68 69
71: 26(fvec4) Load 28(o)
72: 26(fvec4) CompositeInsert 70 71 3
Store 28(o) 72
73: 6(float) FunctionCall 8(foo()
74: 26(fvec4) Load 28(o)
75: 26(fvec4) CompositeInsert 73 74 2
Store 28(o) 75
Return
FunctionEnd
9(foo(): 7(float) Function None 8
10: Label
77: 7(float) Load 12(i1)
78: 7(float) Load 25(i2)
79: 7(float) FAdd 77 78
ReturnValue 79
8(foo(): 6(float) Function None 7
9: Label
76: 6(float) Load 11(i1)
77: 6(float) Load 24(i2)
78: 6(float) FAdd 76 77
ReturnValue 78
FunctionEnd