HLSL: Wrap the entry-point; need to write 'in' args, and support 'inout' args.

This needs some render testing, but is destined to be part of master.

This also leads to a variety of other simplifications.
 - IO are global symbols, so only need one list of linkage nodes (deferred)
 - no longer need parse-context-wide 'inEntryPoint' state, entry-point is localized
 - several parts of splitting/flattening are now localized
This commit is contained in:
John Kessenich
2017-01-19 15:41:47 -07:00
parent 18adbdbbb8
commit 02467d8d94
171 changed files with 37604 additions and 32679 deletions

View File

@@ -2,9 +2,9 @@ hlsl.forLoop.frag
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:2 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:2 Function Definition: @PixelShaderFunction(vf4; (temp 4-component vector of float)
0:2 Function Parameters:
0:2 'input' (layout(location=0 ) in 4-component vector of float)
0:2 'input' (in 4-component vector of float)
0:? Sequence
0:? Sequence
0:3 Loop with condition tested first
@@ -12,7 +12,7 @@ gl_FragCoord origin is upper left
0:3 No loop body
0:4 Sequence
0:4 Pre-Increment (temp 4-component vector of float)
0:4 'input' (layout(location=0 ) in 4-component vector of float)
0:4 'input' (in 4-component vector of float)
0:4 Loop with condition tested first
0:4 No loop condition
0:4 No loop body
@@ -21,44 +21,38 @@ gl_FragCoord origin is upper left
0:5 Loop Condition
0:5 any (temp bool)
0:5 NotEqual (temp 4-component vector of bool)
0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (in 4-component vector of float)
0:5 'input' (in 4-component vector of float)
0:5 No loop body
0:? Sequence
0:6 Loop with condition tested first
0:6 Loop Condition
0:6 any (temp bool)
0:6 NotEqual (temp 4-component vector of bool)
0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (in 4-component vector of float)
0:6 'input' (in 4-component vector of float)
0:6 Loop Body
0:? Sequence
0:6 Sequence
0:6 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:6 Negate value (temp 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 Branch: Return
0:6 Branch: Return with expression
0:6 Negate value (temp 4-component vector of float)
0:6 'input' (in 4-component vector of float)
0:7 Sequence
0:7 Pre-Decrement (temp 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Loop with condition tested first
0:7 Loop Condition
0:7 any (temp bool)
0:7 NotEqual (temp 4-component vector of bool)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Loop Body
0:? Sequence
0:7 Sequence
0:7 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:7 Negate value (temp 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 Branch: Return
0:7 Branch: Return with expression
0:7 Negate value (temp 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Loop Terminal Expression
0:7 add second child into first child (temp 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Constant:
0:7 2.000000
0:? Sequence
@@ -69,7 +63,7 @@ gl_FragCoord origin is upper left
0:8 Condition
0:8 Compare Greater Than (temp bool)
0:8 direct index (temp float)
0:8 'input' (layout(location=0 ) in 4-component vector of float)
0:8 'input' (in 4-component vector of float)
0:8 Constant:
0:8 0 (const int)
0:8 Constant:
@@ -84,7 +78,7 @@ gl_FragCoord origin is upper left
0:9 Condition
0:9 Compare Greater Than (temp bool)
0:9 direct index (temp float)
0:9 'input' (layout(location=0 ) in 4-component vector of float)
0:9 'input' (in 4-component vector of float)
0:9 Constant:
0:9 0 (const int)
0:9 Constant:
@@ -116,6 +110,16 @@ gl_FragCoord origin is upper left
0:11 'ii' (temp int)
0:12 Pre-Decrement (temp float)
0:12 'ii' (temp float)
0:2 Function Definition: PixelShaderFunction( (temp void)
0:2 Function Parameters:
0:? Sequence
0:2 move second child to first child (temp 4-component vector of float)
0:? 'input' (temp 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:2 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:2 Function Call: @PixelShaderFunction(vf4; (temp 4-component vector of float)
0:? 'input' (temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
@@ -127,9 +131,9 @@ Linked fragment stage:
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:2 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:2 Function Definition: @PixelShaderFunction(vf4; (temp 4-component vector of float)
0:2 Function Parameters:
0:2 'input' (layout(location=0 ) in 4-component vector of float)
0:2 'input' (in 4-component vector of float)
0:? Sequence
0:? Sequence
0:3 Loop with condition tested first
@@ -137,7 +141,7 @@ gl_FragCoord origin is upper left
0:3 No loop body
0:4 Sequence
0:4 Pre-Increment (temp 4-component vector of float)
0:4 'input' (layout(location=0 ) in 4-component vector of float)
0:4 'input' (in 4-component vector of float)
0:4 Loop with condition tested first
0:4 No loop condition
0:4 No loop body
@@ -146,44 +150,38 @@ gl_FragCoord origin is upper left
0:5 Loop Condition
0:5 any (temp bool)
0:5 NotEqual (temp 4-component vector of bool)
0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (in 4-component vector of float)
0:5 'input' (in 4-component vector of float)
0:5 No loop body
0:? Sequence
0:6 Loop with condition tested first
0:6 Loop Condition
0:6 any (temp bool)
0:6 NotEqual (temp 4-component vector of bool)
0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (in 4-component vector of float)
0:6 'input' (in 4-component vector of float)
0:6 Loop Body
0:? Sequence
0:6 Sequence
0:6 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:6 Negate value (temp 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 Branch: Return
0:6 Branch: Return with expression
0:6 Negate value (temp 4-component vector of float)
0:6 'input' (in 4-component vector of float)
0:7 Sequence
0:7 Pre-Decrement (temp 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Loop with condition tested first
0:7 Loop Condition
0:7 any (temp bool)
0:7 NotEqual (temp 4-component vector of bool)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Loop Body
0:? Sequence
0:7 Sequence
0:7 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:7 Negate value (temp 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 Branch: Return
0:7 Branch: Return with expression
0:7 Negate value (temp 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Loop Terminal Expression
0:7 add second child into first child (temp 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (in 4-component vector of float)
0:7 Constant:
0:7 2.000000
0:? Sequence
@@ -194,7 +192,7 @@ gl_FragCoord origin is upper left
0:8 Condition
0:8 Compare Greater Than (temp bool)
0:8 direct index (temp float)
0:8 'input' (layout(location=0 ) in 4-component vector of float)
0:8 'input' (in 4-component vector of float)
0:8 Constant:
0:8 0 (const int)
0:8 Constant:
@@ -209,7 +207,7 @@ gl_FragCoord origin is upper left
0:9 Condition
0:9 Compare Greater Than (temp bool)
0:9 direct index (temp float)
0:9 'input' (layout(location=0 ) in 4-component vector of float)
0:9 'input' (in 4-component vector of float)
0:9 Constant:
0:9 0 (const int)
0:9 Constant:
@@ -241,193 +239,220 @@ gl_FragCoord origin is upper left
0:11 'ii' (temp int)
0:12 Pre-Decrement (temp float)
0:12 'ii' (temp float)
0:2 Function Definition: PixelShaderFunction( (temp void)
0:2 Function Parameters:
0:? Sequence
0:2 move second child to first child (temp 4-component vector of float)
0:? 'input' (temp 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:2 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:2 Function Call: @PixelShaderFunction(vf4; (temp 4-component vector of float)
0:? 'input' (temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 114
// Id's are bound by 124
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 13 43
EntryPoint Fragment 4 "PixelShaderFunction" 117 120
ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction"
Name 13 "input"
Name 43 "@entryPointOutput"
Name 91 "ii"
Name 11 "@PixelShaderFunction(vf4;"
Name 10 "input"
Name 92 "ii"
Name 111 "ii"
Decorate 13(input) Location 0
Decorate 43(@entryPointOutput) Location 0
Name 115 "input"
Name 117 "input"
Name 120 "@entryPointOutput"
Name 121 "param"
Decorate 117(input) Location 0
Decorate 120(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
10: TypeFloat 32
11: TypeVector 10(float) 4
12: TypePointer Input 11(fvec4)
13(input): 12(ptr) Variable Input
15: 10(float) Constant 1065353216
29: TypeBool
30: TypeVector 29(bool) 4
42: TypePointer Output 11(fvec4)
43(@entryPointOutput): 42(ptr) Variable Output
62: 10(float) Constant 1073741824
70: TypeInt 32 0
71: 70(int) Constant 0
72: TypePointer Input 10(float)
89: TypeInt 32 1
90: TypePointer Function 89(int)
92: 89(int) Constant 4294967295
99: 89(int) Constant 3
102: 89(int) Constant 2
108: 89(int) Constant 1
110: TypePointer Function 10(float)
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
9: TypeFunction 7(fvec4) 8(ptr)
18: 6(float) Constant 1065353216
32: TypeBool
33: TypeVector 32(bool) 4
63: 6(float) Constant 1073741824
71: TypeInt 32 0
72: 71(int) Constant 0
73: TypePointer Function 6(float)
90: TypeInt 32 1
91: TypePointer Function 90(int)
93: 90(int) Constant 4294967295
100: 90(int) Constant 3
103: 90(int) Constant 2
109: 90(int) Constant 1
116: TypePointer Input 7(fvec4)
117(input): 116(ptr) Variable Input
119: TypePointer Output 7(fvec4)
120(@entryPointOutput): 119(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3
5: Label
91(ii): 90(ptr) Variable Function
111(ii): 110(ptr) Variable Function
Branch 6
6: Label
LoopMerge 8 9 None
Branch 7
7: Label
Branch 9
9: Label
Branch 6
8: Label
14: 11(fvec4) Load 13(input)
16: 11(fvec4) CompositeConstruct 15 15 15 15
17: 11(fvec4) FAdd 14 16
Store 13(input) 17
Branch 18
18: Label
LoopMerge 20 21 None
Branch 19
19: Label
Branch 21
21: Label
Branch 18
20: Label
Branch 22
22: Label
LoopMerge 24 25 None
Branch 26
26: Label
27: 11(fvec4) Load 13(input)
28: 11(fvec4) Load 13(input)
31: 30(bvec4) FOrdNotEqual 27 28
32: 29(bool) Any 31
BranchConditional 32 23 24
23: Label
Branch 25
25: Label
Branch 22
24: Label
Branch 33
33: Label
LoopMerge 35 36 None
Branch 37
37: Label
38: 11(fvec4) Load 13(input)
39: 11(fvec4) Load 13(input)
40: 30(bvec4) FOrdNotEqual 38 39
41: 29(bool) Any 40
BranchConditional 41 34 35
34: Label
44: 11(fvec4) Load 13(input)
45: 11(fvec4) FNegate 44
Store 43(@entryPointOutput) 45
Return
36: Label
Branch 33
35: Label
47: 11(fvec4) Load 13(input)
48: 11(fvec4) CompositeConstruct 15 15 15 15
49: 11(fvec4) FSub 47 48
Store 13(input) 49
Branch 50
50: Label
LoopMerge 52 53 None
Branch 54
54: Label
55: 11(fvec4) Load 13(input)
56: 11(fvec4) Load 13(input)
57: 30(bvec4) FOrdNotEqual 55 56
58: 29(bool) Any 57
BranchConditional 58 51 52
51: Label
59: 11(fvec4) Load 13(input)
60: 11(fvec4) FNegate 59
Store 43(@entryPointOutput) 60
Return
53: Label
63: 11(fvec4) Load 13(input)
64: 11(fvec4) CompositeConstruct 62 62 62 62
65: 11(fvec4) FAdd 63 64
Store 13(input) 65
Branch 50
52: Label
Branch 66
66: Label
LoopMerge 68 69 None
Branch 67
67: Label
73: 72(ptr) AccessChain 13(input) 71
74: 10(float) Load 73
75: 29(bool) FOrdGreaterThan 74 62
SelectionMerge 77 None
BranchConditional 75 76 77
76: Label
Branch 68
77: Label
Branch 69
69: Label
Branch 66
68: Label
Branch 79
79: Label
LoopMerge 81 82 None
Branch 80
80: Label
83: 72(ptr) AccessChain 13(input) 71
84: 10(float) Load 83
85: 29(bool) FOrdGreaterThan 84 62
SelectionMerge 87 None
BranchConditional 85 86 87
86: Label
Branch 82
87: Label
Branch 82
82: Label
Branch 79
81: Label
Store 91(ii) 92
Branch 93
93: Label
LoopMerge 95 96 None
Branch 97
97: Label
98: 89(int) Load 91(ii)
100: 29(bool) SLessThan 98 99
BranchConditional 100 94 95
94: Label
101: 89(int) Load 91(ii)
103: 29(bool) IEqual 101 102
SelectionMerge 105 None
BranchConditional 103 104 105
104: Label
Branch 96
105: Label
Branch 96
96: Label
107: 89(int) Load 91(ii)
109: 89(int) IAdd 107 108
Store 91(ii) 109
Branch 93
95: Label
112: 10(float) Load 111(ii)
113: 10(float) FSub 112 15
Store 111(ii) 113
115(input): 8(ptr) Variable Function
121(param): 8(ptr) Variable Function
118: 7(fvec4) Load 117(input)
Store 115(input) 118
122: 7(fvec4) Load 115(input)
Store 121(param) 122
123: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 121(param)
Store 120(@entryPointOutput) 123
Return
FunctionEnd
11(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter
12: Label
92(ii): 91(ptr) Variable Function
111(ii): 73(ptr) Variable Function
Branch 13
13: Label
LoopMerge 15 16 None
Branch 14
14: Label
Branch 16
16: Label
Branch 13
15: Label
17: 7(fvec4) Load 10(input)
19: 7(fvec4) CompositeConstruct 18 18 18 18
20: 7(fvec4) FAdd 17 19
Store 10(input) 20
Branch 21
21: Label
LoopMerge 23 24 None
Branch 22
22: Label
Branch 24
24: Label
Branch 21
23: Label
Branch 25
25: Label
LoopMerge 27 28 None
Branch 29
29: Label
30: 7(fvec4) Load 10(input)
31: 7(fvec4) Load 10(input)
34: 33(bvec4) FOrdNotEqual 30 31
35: 32(bool) Any 34
BranchConditional 35 26 27
26: Label
Branch 28
28: Label
Branch 25
27: Label
Branch 36
36: Label
LoopMerge 38 39 None
Branch 40
40: Label
41: 7(fvec4) Load 10(input)
42: 7(fvec4) Load 10(input)
43: 33(bvec4) FOrdNotEqual 41 42
44: 32(bool) Any 43
BranchConditional 44 37 38
37: Label
45: 7(fvec4) Load 10(input)
46: 7(fvec4) FNegate 45
ReturnValue 46
39: Label
Branch 36
38: Label
48: 7(fvec4) Load 10(input)
49: 7(fvec4) CompositeConstruct 18 18 18 18
50: 7(fvec4) FSub 48 49
Store 10(input) 50
Branch 51
51: Label
LoopMerge 53 54 None
Branch 55
55: Label
56: 7(fvec4) Load 10(input)
57: 7(fvec4) Load 10(input)
58: 33(bvec4) FOrdNotEqual 56 57
59: 32(bool) Any 58
BranchConditional 59 52 53
52: Label
60: 7(fvec4) Load 10(input)
61: 7(fvec4) FNegate 60
ReturnValue 61
54: Label
64: 7(fvec4) Load 10(input)
65: 7(fvec4) CompositeConstruct 63 63 63 63
66: 7(fvec4) FAdd 64 65
Store 10(input) 66
Branch 51
53: Label
Branch 67
67: Label
LoopMerge 69 70 None
Branch 68
68: Label
74: 73(ptr) AccessChain 10(input) 72
75: 6(float) Load 74
76: 32(bool) FOrdGreaterThan 75 63
SelectionMerge 78 None
BranchConditional 76 77 78
77: Label
Branch 69
78: Label
Branch 70
70: Label
Branch 67
69: Label
Branch 80
80: Label
LoopMerge 82 83 None
Branch 81
81: Label
84: 73(ptr) AccessChain 10(input) 72
85: 6(float) Load 84
86: 32(bool) FOrdGreaterThan 85 63
SelectionMerge 88 None
BranchConditional 86 87 88
87: Label
Branch 83
88: Label
Branch 83
83: Label
Branch 80
82: Label
Store 92(ii) 93
Branch 94
94: Label
LoopMerge 96 97 None
Branch 98
98: Label
99: 90(int) Load 92(ii)
101: 32(bool) SLessThan 99 100
BranchConditional 101 95 96
95: Label
102: 90(int) Load 92(ii)
104: 32(bool) IEqual 102 103
SelectionMerge 106 None
BranchConditional 104 105 106
105: Label
Branch 97
106: Label
Branch 97
97: Label
108: 90(int) Load 92(ii)
110: 90(int) IAdd 108 109
Store 92(ii) 110
Branch 94
96: Label
112: 6(float) Load 111(ii)
113: 6(float) FSub 112 18
Store 111(ii) 113
114: 7(fvec4) Undef
ReturnValue 114
FunctionEnd