Merge pull request #508 from amdrexu/bugfix
SPV: Support simultaneous l-value swizzle and dynamic component selection.
This commit is contained in:
commit
315b6b9f68
@ -1328,15 +1328,20 @@ Id Builder::createRvalueSwizzle(Decoration precision, Id typeId, Id source, std:
|
|||||||
// Comments in header
|
// Comments in header
|
||||||
Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, std::vector<unsigned>& channels)
|
Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, std::vector<unsigned>& channels)
|
||||||
{
|
{
|
||||||
assert(getNumComponents(source) == (int)channels.size());
|
|
||||||
if (channels.size() == 1 && getNumComponents(source) == 1)
|
if (channels.size() == 1 && getNumComponents(source) == 1)
|
||||||
return createCompositeInsert(source, target, typeId, channels.front());
|
return createCompositeInsert(source, target, typeId, channels.front());
|
||||||
|
|
||||||
Instruction* swizzle = new Instruction(getUniqueId(), typeId, OpVectorShuffle);
|
Instruction* swizzle = new Instruction(getUniqueId(), typeId, OpVectorShuffle);
|
||||||
assert(isVector(source));
|
|
||||||
assert(isVector(target));
|
assert(isVector(target));
|
||||||
swizzle->addIdOperand(target);
|
swizzle->addIdOperand(target);
|
||||||
|
if (accessChain.component != NoResult)
|
||||||
|
// For dynamic component selection, source does not involve in l-value swizzle
|
||||||
|
swizzle->addIdOperand(target);
|
||||||
|
else {
|
||||||
|
assert(getNumComponents(source) == (int)channels.size());
|
||||||
|
assert(isVector(source));
|
||||||
swizzle->addIdOperand(source);
|
swizzle->addIdOperand(source);
|
||||||
|
}
|
||||||
|
|
||||||
// Set up an identity shuffle from the base value to the result value
|
// Set up an identity shuffle from the base value to the result value
|
||||||
unsigned int components[4];
|
unsigned int components[4];
|
||||||
@ -1345,8 +1350,12 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, std::vector<uns
|
|||||||
components[i] = i;
|
components[i] = i;
|
||||||
|
|
||||||
// Punch in the l-value swizzle
|
// Punch in the l-value swizzle
|
||||||
for (int i = 0; i < (int)channels.size(); ++i)
|
for (int i = 0; i < (int)channels.size(); ++i) {
|
||||||
|
if (accessChain.component != NoResult)
|
||||||
|
components[i] = channels[i]; // Only shuffle the base value
|
||||||
|
else
|
||||||
components[channels[i]] = numTargetComponents + i;
|
components[channels[i]] = numTargetComponents + i;
|
||||||
|
}
|
||||||
|
|
||||||
// finish the instruction with these components selectors
|
// finish the instruction with these components selectors
|
||||||
for (int i = 0; i < numTargetComponents; ++i)
|
for (int i = 0; i < numTargetComponents; ++i)
|
||||||
@ -2118,9 +2127,6 @@ void Builder::accessChainStore(Id rvalue)
|
|||||||
transferAccessChainSwizzle(true);
|
transferAccessChainSwizzle(true);
|
||||||
Id base = collapseAccessChain();
|
Id base = collapseAccessChain();
|
||||||
|
|
||||||
if (accessChain.swizzle.size() && accessChain.component != NoResult)
|
|
||||||
logger->missingFunctionality("simultaneous l-value swizzle and dynamic component selection");
|
|
||||||
|
|
||||||
// If swizzle still exists, it is out-of-order or not full, we must load the target vector,
|
// If swizzle still exists, it is out-of-order or not full, we must load the target vector,
|
||||||
// extract and insert elements to perform writeMask and/or swizzle.
|
// extract and insert elements to perform writeMask and/or swizzle.
|
||||||
Id source = NoResult;
|
Id source = NoResult;
|
||||||
|
@ -7,12 +7,12 @@ Linked fragment stage:
|
|||||||
|
|
||||||
// Module Version 10000
|
// Module Version 10000
|
||||||
// Generated by (magic number): 80001
|
// Generated by (magic number): 80001
|
||||||
// Id's are bound by 197
|
// Id's are bound by 206
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
1: ExtInstImport "GLSL.std.450"
|
1: ExtInstImport "GLSL.std.450"
|
||||||
MemoryModel Logical GLSL450
|
MemoryModel Logical GLSL450
|
||||||
EntryPoint Fragment 4 "main" 65 149
|
EntryPoint Fragment 4 "main" 65 158
|
||||||
ExecutionMode 4 OriginUpperLeft
|
ExecutionMode 4 OriginUpperLeft
|
||||||
Source GLSL 420
|
Source GLSL 420
|
||||||
Name 4 "main"
|
Name 4 "main"
|
||||||
@ -57,22 +57,22 @@ Linked fragment stage:
|
|||||||
Name 60 "i"
|
Name 60 "i"
|
||||||
Name 61 "comp"
|
Name 61 "comp"
|
||||||
Name 65 "OutColor"
|
Name 65 "OutColor"
|
||||||
Name 144 "s"
|
Name 153 "s"
|
||||||
Name 149 "u"
|
Name 158 "u"
|
||||||
Name 150 "param"
|
Name 159 "param"
|
||||||
Name 154 "param"
|
Name 163 "param"
|
||||||
Name 158 "param"
|
Name 167 "param"
|
||||||
Name 162 "param"
|
Name 171 "param"
|
||||||
Name 166 "param"
|
Name 175 "param"
|
||||||
Name 170 "param"
|
Name 179 "param"
|
||||||
Name 174 "param"
|
Name 183 "param"
|
||||||
Name 178 "param"
|
Name 187 "param"
|
||||||
Name 182 "param"
|
Name 191 "param"
|
||||||
Name 186 "param"
|
Name 195 "param"
|
||||||
Name 190 "param"
|
Name 199 "param"
|
||||||
Name 194 "param"
|
Name 203 "param"
|
||||||
Decorate 65(OutColor) Location 0
|
Decorate 65(OutColor) Location 0
|
||||||
Decorate 149(u) Flat
|
Decorate 158(u) Flat
|
||||||
2: TypeVoid
|
2: TypeVoid
|
||||||
3: TypeFunction 2
|
3: TypeFunction 2
|
||||||
6: TypeFloat 32
|
6: TypeFloat 32
|
||||||
@ -90,77 +90,77 @@ Linked fragment stage:
|
|||||||
95: TypeVector 6(float) 2
|
95: TypeVector 6(float) 2
|
||||||
109: 67(int) Constant 2
|
109: 67(int) Constant 2
|
||||||
136: TypePointer Output 6(float)
|
136: TypePointer Output 6(float)
|
||||||
141: 6(float) Constant 0
|
150: 6(float) Constant 0
|
||||||
142: 7(fvec3) ConstantComposite 141 141 141
|
151: 7(fvec3) ConstantComposite 150 150 150
|
||||||
143: TypePointer Function 8(S)
|
152: TypePointer Function 8(S)
|
||||||
148: TypePointer Input 13(int)
|
157: TypePointer Input 13(int)
|
||||||
149(u): 148(ptr) Variable Input
|
158(u): 157(ptr) Variable Input
|
||||||
4(main): 2 Function None 3
|
4(main): 2 Function None 3
|
||||||
5: Label
|
5: Label
|
||||||
144(s): 143(ptr) Variable Function
|
153(s): 152(ptr) Variable Function
|
||||||
150(param): 14(ptr) Variable Function
|
159(param): 14(ptr) Variable Function
|
||||||
154(param): 14(ptr) Variable Function
|
163(param): 14(ptr) Variable Function
|
||||||
158(param): 14(ptr) Variable Function
|
167(param): 14(ptr) Variable Function
|
||||||
162(param): 14(ptr) Variable Function
|
171(param): 14(ptr) Variable Function
|
||||||
166(param): 14(ptr) Variable Function
|
175(param): 14(ptr) Variable Function
|
||||||
170(param): 14(ptr) Variable Function
|
179(param): 14(ptr) Variable Function
|
||||||
174(param): 14(ptr) Variable Function
|
183(param): 14(ptr) Variable Function
|
||||||
178(param): 14(ptr) Variable Function
|
187(param): 14(ptr) Variable Function
|
||||||
182(param): 14(ptr) Variable Function
|
191(param): 14(ptr) Variable Function
|
||||||
186(param): 14(ptr) Variable Function
|
195(param): 14(ptr) Variable Function
|
||||||
190(param): 14(ptr) Variable Function
|
199(param): 14(ptr) Variable Function
|
||||||
194(param): 14(ptr) Variable Function
|
203(param): 14(ptr) Variable Function
|
||||||
Store 65(OutColor) 142
|
Store 65(OutColor) 151
|
||||||
145: 8(S) Load 144(s)
|
154: 8(S) Load 153(s)
|
||||||
146: 2 FunctionCall 11(GetColor1(struct-S-vf31;) 145
|
155: 2 FunctionCall 11(GetColor1(struct-S-vf31;) 154
|
||||||
147: 8(S) Load 144(s)
|
156: 8(S) Load 153(s)
|
||||||
151: 13(int) Load 149(u)
|
160: 13(int) Load 158(u)
|
||||||
Store 150(param) 151
|
Store 159(param) 160
|
||||||
152: 2 FunctionCall 18(GetColor2(struct-S-vf31;i1;) 147 150(param)
|
161: 2 FunctionCall 18(GetColor2(struct-S-vf31;i1;) 156 159(param)
|
||||||
153: 8(S) Load 144(s)
|
162: 8(S) Load 153(s)
|
||||||
155: 13(int) Load 149(u)
|
164: 13(int) Load 158(u)
|
||||||
Store 154(param) 155
|
Store 163(param) 164
|
||||||
156: 2 FunctionCall 22(GetColor3(struct-S-vf31;i1;) 153 154(param)
|
165: 2 FunctionCall 22(GetColor3(struct-S-vf31;i1;) 162 163(param)
|
||||||
157: 8(S) Load 144(s)
|
166: 8(S) Load 153(s)
|
||||||
159: 13(int) Load 149(u)
|
168: 13(int) Load 158(u)
|
||||||
Store 158(param) 159
|
Store 167(param) 168
|
||||||
160: 2 FunctionCall 26(GetColor4(struct-S-vf31;i1;) 157 158(param)
|
169: 2 FunctionCall 26(GetColor4(struct-S-vf31;i1;) 166 167(param)
|
||||||
161: 8(S) Load 144(s)
|
170: 8(S) Load 153(s)
|
||||||
163: 13(int) Load 149(u)
|
172: 13(int) Load 158(u)
|
||||||
Store 162(param) 163
|
Store 171(param) 172
|
||||||
164: 2 FunctionCall 30(GetColor5(struct-S-vf31;i1;) 161 162(param)
|
173: 2 FunctionCall 30(GetColor5(struct-S-vf31;i1;) 170 171(param)
|
||||||
165: 8(S) Load 144(s)
|
174: 8(S) Load 153(s)
|
||||||
167: 13(int) Load 149(u)
|
176: 13(int) Load 158(u)
|
||||||
Store 166(param) 167
|
Store 175(param) 176
|
||||||
168: 2 FunctionCall 34(GetColor6(struct-S-vf31;i1;) 165 166(param)
|
177: 2 FunctionCall 34(GetColor6(struct-S-vf31;i1;) 174 175(param)
|
||||||
169: 8(S) Load 144(s)
|
178: 8(S) Load 153(s)
|
||||||
171: 13(int) Load 149(u)
|
180: 13(int) Load 158(u)
|
||||||
Store 170(param) 171
|
Store 179(param) 180
|
||||||
172: 2 FunctionCall 38(GetColor7(struct-S-vf31;i1;) 169 170(param)
|
181: 2 FunctionCall 38(GetColor7(struct-S-vf31;i1;) 178 179(param)
|
||||||
173: 8(S) Load 144(s)
|
182: 8(S) Load 153(s)
|
||||||
175: 13(int) Load 149(u)
|
184: 13(int) Load 158(u)
|
||||||
Store 174(param) 175
|
Store 183(param) 184
|
||||||
176: 2 FunctionCall 42(GetColor8(struct-S-vf31;i1;) 173 174(param)
|
185: 2 FunctionCall 42(GetColor8(struct-S-vf31;i1;) 182 183(param)
|
||||||
177: 8(S) Load 144(s)
|
186: 8(S) Load 153(s)
|
||||||
179: 13(int) Load 149(u)
|
188: 13(int) Load 158(u)
|
||||||
Store 178(param) 179
|
Store 187(param) 188
|
||||||
180: 2 FunctionCall 46(GetColor9(struct-S-vf31;i1;) 177 178(param)
|
189: 2 FunctionCall 46(GetColor9(struct-S-vf31;i1;) 186 187(param)
|
||||||
181: 8(S) Load 144(s)
|
190: 8(S) Load 153(s)
|
||||||
183: 13(int) Load 149(u)
|
192: 13(int) Load 158(u)
|
||||||
Store 182(param) 183
|
Store 191(param) 192
|
||||||
184: 2 FunctionCall 50(GetColor10(struct-S-vf31;i1;) 181 182(param)
|
193: 2 FunctionCall 50(GetColor10(struct-S-vf31;i1;) 190 191(param)
|
||||||
185: 8(S) Load 144(s)
|
194: 8(S) Load 153(s)
|
||||||
187: 13(int) Load 149(u)
|
196: 13(int) Load 158(u)
|
||||||
Store 186(param) 187
|
Store 195(param) 196
|
||||||
188: 2 FunctionCall 54(GetColor11(struct-S-vf31;i1;) 185 186(param)
|
197: 2 FunctionCall 54(GetColor11(struct-S-vf31;i1;) 194 195(param)
|
||||||
189: 8(S) Load 144(s)
|
198: 8(S) Load 153(s)
|
||||||
191: 13(int) Load 149(u)
|
200: 13(int) Load 158(u)
|
||||||
Store 190(param) 191
|
Store 199(param) 200
|
||||||
192: 2 FunctionCall 58(GetColor12(struct-S-vf31;i1;) 189 190(param)
|
201: 2 FunctionCall 58(GetColor12(struct-S-vf31;i1;) 198 199(param)
|
||||||
193: 8(S) Load 144(s)
|
202: 8(S) Load 153(s)
|
||||||
195: 13(int) Load 149(u)
|
204: 13(int) Load 158(u)
|
||||||
Store 194(param) 195
|
Store 203(param) 204
|
||||||
196: 2 FunctionCall 62(GetColor13(struct-S-vf31;i1;) 193 194(param)
|
205: 2 FunctionCall 62(GetColor13(struct-S-vf31;i1;) 202 203(param)
|
||||||
Return
|
Return
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
11(GetColor1(struct-S-vf31;): 2 Function None 9
|
11(GetColor1(struct-S-vf31;): 2 Function None 9
|
||||||
@ -319,5 +319,15 @@ Linked fragment stage:
|
|||||||
60(i): 8(S) FunctionParameter
|
60(i): 8(S) FunctionParameter
|
||||||
61(comp): 14(ptr) FunctionParameter
|
61(comp): 14(ptr) FunctionParameter
|
||||||
63: Label
|
63: Label
|
||||||
|
141: 13(int) Load 61(comp)
|
||||||
|
142: 6(float) CompositeExtract 60(i) 0 0
|
||||||
|
143: 7(fvec3) Load 65(OutColor)
|
||||||
|
144: 95(fvec2) VectorShuffle 143 143 2 1
|
||||||
|
145: 6(float) VectorExtractDynamic 144 141
|
||||||
|
146: 6(float) FAdd 145 142
|
||||||
|
147: 7(fvec3) Load 65(OutColor)
|
||||||
|
148: 7(fvec3) VectorShuffle 147 147 2 1 2
|
||||||
|
149: 7(fvec3) VectorInsertDynamic 148 146 141
|
||||||
|
Store 65(OutColor) 149
|
||||||
Return
|
Return
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
@ -71,7 +71,7 @@ void GetColor12(const S i, int comp)
|
|||||||
|
|
||||||
void GetColor13(const S i, int comp)
|
void GetColor13(const S i, int comp)
|
||||||
{
|
{
|
||||||
// OutColor.zy[comp] += i.color.x; // not yet supported
|
OutColor.zy[comp] += i.color.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user