SPV: Implement short circuiting of && and || when emitting SPIR-V.

This commit is contained in:
John Kessenich
2015-10-15 13:29:11 -06:00
parent da581a2b95
commit 7c1aa1026e
9 changed files with 1942 additions and 1429 deletions

View File

@@ -115,6 +115,9 @@ protected:
void addDecoration(spv::Id id, spv::Decoration dec); void addDecoration(spv::Id id, spv::Decoration dec);
void addMemberDecoration(spv::Id id, int member, spv::Decoration dec); void addMemberDecoration(spv::Id id, int member, spv::Decoration dec);
spv::Id createSpvConstant(const glslang::TType& type, const glslang::TConstUnionArray&, int& nextConst); spv::Id createSpvConstant(const glslang::TType& type, const glslang::TConstUnionArray&, int& nextConst);
bool isTrivialLeaf(const glslang::TIntermTyped* node);
bool isTrivial(const glslang::TIntermTyped* node);
spv::Id createShortCircuit(glslang::TOperator, glslang::TIntermTyped& left, glslang::TIntermTyped& right);
spv::Function* shaderEntry; spv::Function* shaderEntry;
int sequenceDepth; int sequenceDepth;
@@ -725,6 +728,21 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
builder.accessChainPushSwizzle(swizzle, convertGlslangToSpvType(node->getLeft()->getType())); builder.accessChainPushSwizzle(swizzle, convertGlslangToSpvType(node->getLeft()->getType()));
} }
return false; return false;
case glslang::EOpLogicalOr:
case glslang::EOpLogicalAnd:
{
// These may require short circuiting, but can sometimes be done as straight
// binary operations. The right operand must be short circuited if it has
// side effects, and should probably be if it is complex.
if (isTrivial(node->getRight()->getAsTyped()))
break; // handle below as a normal binary operation
// otherwise, we need to do dynamic short circuiting on the right operand
spv::Id result = createShortCircuit(node->getOp(), *node->getLeft()->getAsTyped(), *node->getRight()->getAsTyped());
builder.clearAccessChain();
builder.setAccessChainRValue(result);
}
return false;
default: default:
break; break;
} }
@@ -2177,7 +2195,9 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
break; break;
} }
// handle mapped binary operations (should be non-comparison)
if (binOp != spv::OpNop) { if (binOp != spv::OpNop) {
assert(comparison == false);
if (builder.isMatrix(left) || builder.isMatrix(right)) { if (builder.isMatrix(left) || builder.isMatrix(right)) {
switch (binOp) { switch (binOp) {
case spv::OpMatrixTimesScalar: case spv::OpMatrixTimesScalar:
@@ -2215,7 +2235,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
if (! comparison) if (! comparison)
return 0; return 0;
// Comparison instructions // Handle comparison instructions
if (reduceComparison && (builder.isVector(left) || builder.isMatrix(left) || builder.isAggregate(left))) { if (reduceComparison && (builder.isVector(left) || builder.isMatrix(left) || builder.isAggregate(left))) {
assert(op == glslang::EOpEqual || op == glslang::EOpNotEqual); assert(op == glslang::EOpEqual || op == glslang::EOpNotEqual);
@@ -3025,6 +3045,133 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TType& glslangT
return builder.makeCompositeConstant(typeId, spvConsts); return builder.makeCompositeConstant(typeId, spvConsts);
} }
// Return true if the node is a constant or symbol whose reading has no
// non-trivial observable cost or effect.
bool TGlslangToSpvTraverser::isTrivialLeaf(const glslang::TIntermTyped* node)
{
// don't know what this is
if (node == nullptr)
return false;
// a constant is safe
if (node->getAsConstantUnion() != nullptr)
return true;
// not a symbol means non-trivial
if (node->getAsSymbolNode() == nullptr)
return false;
// a symbol, depends on what's being read
switch (node->getType().getQualifier().storage) {
case glslang::EvqTemporary:
case glslang::EvqGlobal:
case glslang::EvqIn:
case glslang::EvqInOut:
case glslang::EvqConst:
case glslang::EvqConstReadOnly:
case glslang::EvqUniform:
return true;
default:
return false;
}
}
// A node is trivial if it is a single operation with no side effects.
// Error on the side of saying non-trivial.
// Return true if trivial.
bool TGlslangToSpvTraverser::isTrivial(const glslang::TIntermTyped* node)
{
if (node == nullptr)
return false;
// symbols and constants are trivial
if (isTrivialLeaf(node))
return true;
// otherwise, it needs to be a simple operation or one or two leaf nodes
// not a simple operation
const glslang::TIntermBinary* binaryNode = node->getAsBinaryNode();
const glslang::TIntermUnary* unaryNode = node->getAsUnaryNode();
if (binaryNode == nullptr && unaryNode == nullptr)
return false;
// not on leaf nodes
if (binaryNode && (! isTrivialLeaf(binaryNode->getLeft()) || ! isTrivialLeaf(binaryNode->getRight())))
return false;
if (unaryNode && ! isTrivialLeaf(unaryNode->getOperand())) {
return false;
}
switch (node->getAsOperator()->getOp()) {
case glslang::EOpLogicalNot:
case glslang::EOpConvIntToBool:
case glslang::EOpConvUintToBool:
case glslang::EOpConvFloatToBool:
case glslang::EOpConvDoubleToBool:
case glslang::EOpEqual:
case glslang::EOpNotEqual:
case glslang::EOpLessThan:
case glslang::EOpGreaterThan:
case glslang::EOpLessThanEqual:
case glslang::EOpGreaterThanEqual:
case glslang::EOpIndexDirect:
case glslang::EOpIndexDirectStruct:
case glslang::EOpLogicalXor:
case glslang::EOpAny:
case glslang::EOpAll:
return true;
default:
return false;
}
}
// Emit short-circuiting code, where 'right' is never evaluated unless
// the left side is true (for &&) or false (for ||).
spv::Id TGlslangToSpvTraverser::createShortCircuit(glslang::TOperator op, glslang::TIntermTyped& left, glslang::TIntermTyped& right)
{
spv::Id boolTypeId = builder.makeBoolType();
// emit left operand
builder.clearAccessChain();
left.traverse(this);
spv::Id leftId = builder.accessChainLoad(boolTypeId);
// Operands to accumulate OpPhi operands
std::vector<spv::Id> phiOperands;
// accumulate left operand's phi information
phiOperands.push_back(leftId);
phiOperands.push_back(builder.getBuildPoint()->getId());
// Make the two kinds of operation symmetric with a "!"
// || => emit "if (! left) result = right"
// && => emit "if ( left) result = right"
//
// TODO: this runtime "not" for || could be avoided by adding functionality
// to 'builder' to have an "else" without an "then"
if (op == glslang::EOpLogicalOr)
leftId = builder.createUnaryOp(spv::OpLogicalNot, boolTypeId, leftId);
// make an "if" based on the left value
spv::Builder::If ifBuilder(leftId, builder);
// emit right operand as the "then" part of the "if"
builder.clearAccessChain();
right.traverse(this);
spv::Id rightId = builder.accessChainLoad(boolTypeId);
// accumulate left operand's phi information
phiOperands.push_back(rightId);
phiOperands.push_back(builder.getBuildPoint()->getId());
// finish the "if"
ifBuilder.makeEndIf();
// phi together the two results
return builder.createOp(spv::OpPhi, boolTypeId, phiOperands);
}
}; // end anonymous namespace }; // end anonymous namespace
namespace glslang { namespace glslang {

View File

@@ -5,7 +5,7 @@ Linked vertex stage:
// Module Version 99 // Module Version 99
// Generated by (magic number): 51a00bb // Generated by (magic number): 51a00bb
// Id's are bound by 111 // Id's are bound by 114
Source ESSL 300 Source ESSL 300
Capability Shader Capability Shader
@@ -40,8 +40,8 @@ Linked vertex stage:
MemberName 77(S) 0 "c" MemberName 77(S) 0 "c"
MemberName 77(S) 1 "f" MemberName 77(S) 1 "f"
Name 79 "s" Name 79 "s"
Name 109 "gl_VertexID" Name 112 "gl_VertexID"
Name 110 "gl_InstanceID" Name 113 "gl_InstanceID"
Decorate 9(pos) Smooth Decorate 9(pos) Smooth
Decorate 11(p) Location 3 Decorate 11(p) Location 3
MemberDecorate 17(Transform) 0 RowMajor MemberDecorate 17(Transform) 0 RowMajor
@@ -67,10 +67,10 @@ Linked vertex stage:
Decorate 53(c) Location 7 Decorate 53(c) Location 7
Decorate 61(iout) Flat Decorate 61(iout) Flat
Decorate 73(aiv2) Location 9 Decorate 73(aiv2) Location 9
Decorate 109(gl_VertexID) BuiltIn VertexId Decorate 112(gl_VertexID) BuiltIn VertexId
Decorate 109(gl_VertexID) NoStaticUse Decorate 112(gl_VertexID) NoStaticUse
Decorate 110(gl_InstanceID) BuiltIn InstanceId Decorate 113(gl_InstanceID) BuiltIn InstanceId
Decorate 110(gl_InstanceID) NoStaticUse Decorate 113(gl_InstanceID) NoStaticUse
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
@@ -124,12 +124,12 @@ Linked vertex stage:
89: 6(float) Constant 1065353216 89: 6(float) Constant 1065353216
90: 14(fvec3) ConstantComposite 89 89 89 90: 14(fvec3) ConstantComposite 89 89 89
91: TypeVector 42(bool) 3 91: TypeVector 42(bool) 3
94: TypePointer Uniform 30(ivec3) 97: TypePointer Uniform 30(ivec3)
97: 29(int) Constant 5 100: 29(int) Constant 5
98: 30(ivec3) ConstantComposite 97 97 97 101: 30(ivec3) ConstantComposite 100 100 100
108: TypePointer Input 16(int) 111: TypePointer Input 16(int)
109(gl_VertexID): 108(ptr) Variable Input 112(gl_VertexID): 111(ptr) Variable Input
110(gl_InstanceID): 108(ptr) Variable Input 113(gl_InstanceID): 111(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
12: 7(fvec4) Load 11(p) 12: 7(fvec4) Load 11(p)
@@ -174,20 +174,26 @@ Linked vertex stage:
88: 14(fvec3) Load 87 88: 14(fvec3) Load 87
92: 91(bvec3) FOrdNotEqual 88 90 92: 91(bvec3) FOrdNotEqual 88 90
93: 42(bool) Any 92 93: 42(bool) Any 92
95: 94(ptr) AccessChain 35 62 55 94: 42(bool) LogicalNot 93
96: 30(ivec3) Load 95 SelectionMerge 96 None
99: 91(bvec3) INotEqual 96 98 BranchConditional 94 95 96
100: 42(bool) Any 99 95: Label
101: 42(bool) LogicalOr 93 100 98: 97(ptr) AccessChain 35 62 55
SelectionMerge 103 None 99: 30(ivec3) Load 98
BranchConditional 101 102 103 102: 91(bvec3) INotEqual 99 101
102: Label 103: 42(bool) Any 102
104: 50(ptr) AccessChain 79(s) 20 Branch 96
105: 14(fvec3) Load 104 96: Label
106: 14(fvec3) CompositeConstruct 89 89 89 104: 42(bool) Phi 93 5 103 95
107: 14(fvec3) FAdd 105 106 SelectionMerge 106 None
Store 104 107 BranchConditional 104 105 106
Branch 103 105: Label
103: Label 107: 50(ptr) AccessChain 79(s) 20
108: 14(fvec3) Load 107
109: 14(fvec3) CompositeConstruct 89 89 89
110: 14(fvec3) FAdd 108 109
Store 107 110
Branch 106
106: Label
Return Return
FunctionEnd FunctionEnd

View File

@@ -5,7 +5,7 @@ Linked fragment stage:
// Module Version 99 // Module Version 99
// Generated by (magic number): 51a00bb // Generated by (magic number): 51a00bb
// Id's are bound by 398 // Id's are bound by 416
Source GLSL 130 Source GLSL 130
Capability Shader Capability Shader
@@ -20,15 +20,15 @@ Linked fragment stage:
Name 22 "ui" Name 22 "ui"
Name 169 "uf" Name 169 "uf"
Name 216 "b" Name 216 "b"
Name 242 "ub41" Name 250 "ub41"
Name 244 "ub42" Name 252 "ub42"
Name 301 "f" Name 316 "f"
Name 377 "gl_FragColor" Name 395 "gl_FragColor"
Name 395 "uiv4" Name 413 "uiv4"
Name 397 "ub" Name 415 "ub"
Decorate 377(gl_FragColor) BuiltIn FragColor Decorate 395(gl_FragColor) BuiltIn FragColor
Decorate 395(uiv4) NoStaticUse Decorate 413(uiv4) NoStaticUse
Decorate 397(ub) NoStaticUse Decorate 415(ub) NoStaticUse
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
@@ -45,31 +45,31 @@ Linked fragment stage:
214: TypeBool 214: TypeBool
215: TypePointer Function 214(bool) 215: TypePointer Function 214(bool)
219: TypeVector 214(bool) 4 219: TypeVector 214(bool) 4
241: TypePointer UniformConstant 219(bvec4) 249: TypePointer UniformConstant 219(bvec4)
242(ub41): 241(ptr) Variable UniformConstant 250(ub41): 249(ptr) Variable UniformConstant
244(ub42): 241(ptr) Variable UniformConstant 252(ub42): 249(ptr) Variable UniformConstant
291: 18(int) Constant 2 306: 18(int) Constant 2
298: 18(int) Constant 1 313: 18(int) Constant 1
300: TypePointer Function 6(float) 315: TypePointer Function 6(float)
330: TypeVector 6(float) 3 345: TypeVector 6(float) 3
346: 6(float) Constant 1073741824 364: 6(float) Constant 1073741824
353: 6(float) Constant 1065353216 371: 6(float) Constant 1065353216
358: 18(int) Constant 66 376: 18(int) Constant 66
364: 18(int) Constant 17 382: 18(int) Constant 17
376: TypePointer Output 7(fvec4) 394: TypePointer Output 7(fvec4)
377(gl_FragColor): 376(ptr) Variable Output 395(gl_FragColor): 394(ptr) Variable Output
393: TypeVector 18(int) 4 411: TypeVector 18(int) 4
394: TypePointer UniformConstant 393(ivec4) 412: TypePointer UniformConstant 411(ivec4)
395(uiv4): 394(ptr) Variable UniformConstant 413(uiv4): 412(ptr) Variable UniformConstant
396: TypePointer UniformConstant 214(bool) 414: TypePointer UniformConstant 214(bool)
397(ub): 396(ptr) Variable UniformConstant 415(ub): 414(ptr) Variable UniformConstant
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
9(v): 8(ptr) Variable Function 9(v): 8(ptr) Variable Function
20(i): 19(ptr) Variable Function 20(i): 19(ptr) Variable Function
216(b): 215(ptr) Variable Function 216(b): 215(ptr) Variable Function
301(f): 300(ptr) Variable Function 316(f): 315(ptr) Variable Function
378: 8(ptr) Variable Function 396: 8(ptr) Variable Function
12: 7(fvec4) Load 11(uv4) 12: 7(fvec4) Load 11(uv4)
13: 7(fvec4) ExtInst 1(GLSL.std.450) 11(Radians) 12 13: 7(fvec4) ExtInst 1(GLSL.std.450) 11(Radians) 12
Store 9(v) 13 Store 9(v) 13
@@ -315,199 +315,241 @@ Linked fragment stage:
221: 214(bool) Any 220 221: 214(bool) Any 220
Store 216(b) 221 Store 216(b) 221
222: 214(bool) Load 216(b) 222: 214(bool) Load 216(b)
223: 7(fvec4) Load 9(v) SelectionMerge 224 None
224: 7(fvec4) Load 11(uv4) BranchConditional 222 223 224
225: 219(bvec4) FOrdLessThanEqual 223 224 223: Label
226: 214(bool) Any 225 225: 7(fvec4) Load 9(v)
227: 214(bool) LogicalAnd 222 226 226: 7(fvec4) Load 11(uv4)
Store 216(b) 227 227: 219(bvec4) FOrdLessThanEqual 225 226
228: 214(bool) Load 216(b) 228: 214(bool) Any 227
229: 7(fvec4) Load 9(v) Branch 224
230: 7(fvec4) Load 11(uv4) 224: Label
231: 219(bvec4) FOrdGreaterThan 229 230 229: 214(bool) Phi 222 5 228 223
232: 214(bool) Any 231 Store 216(b) 229
233: 214(bool) LogicalAnd 228 232 230: 214(bool) Load 216(b)
Store 216(b) 233 SelectionMerge 232 None
234: 214(bool) Load 216(b) BranchConditional 230 231 232
235: 7(fvec4) Load 9(v) 231: Label
236: 7(fvec4) Load 11(uv4) 233: 7(fvec4) Load 9(v)
237: 219(bvec4) FOrdGreaterThanEqual 235 236 234: 7(fvec4) Load 11(uv4)
238: 214(bool) Any 237 235: 219(bvec4) FOrdGreaterThan 233 234
239: 214(bool) LogicalAnd 234 238 236: 214(bool) Any 235
Store 216(b) 239 Branch 232
240: 214(bool) Load 216(b) 232: Label
243: 219(bvec4) Load 242(ub41) 237: 214(bool) Phi 230 224 236 231
245: 219(bvec4) Load 244(ub42) Store 216(b) 237
246: 219(bvec4) IEqual 243 245 238: 214(bool) Load 216(b)
247: 214(bool) Any 246 SelectionMerge 240 None
248: 214(bool) LogicalAnd 240 247 BranchConditional 238 239 240
Store 216(b) 248 239: Label
249: 214(bool) Load 216(b) 241: 7(fvec4) Load 9(v)
250: 219(bvec4) Load 242(ub41) 242: 7(fvec4) Load 11(uv4)
251: 219(bvec4) Load 244(ub42) 243: 219(bvec4) FOrdGreaterThanEqual 241 242
252: 219(bvec4) INotEqual 250 251 244: 214(bool) Any 243
253: 214(bool) Any 252 Branch 240
254: 214(bool) LogicalAnd 249 253 240: Label
Store 216(b) 254 245: 214(bool) Phi 238 232 244 239
255: 214(bool) Load 216(b) Store 216(b) 245
256: 219(bvec4) Load 242(ub41) 246: 214(bool) Load 216(b)
257: 214(bool) Any 256 SelectionMerge 248 None
258: 214(bool) LogicalAnd 255 257 BranchConditional 246 247 248
Store 216(b) 258 247: Label
259: 214(bool) Load 216(b) 251: 219(bvec4) Load 250(ub41)
260: 219(bvec4) Load 242(ub41) 253: 219(bvec4) Load 252(ub42)
261: 214(bool) All 260 254: 219(bvec4) IEqual 251 253
262: 214(bool) LogicalAnd 259 261 255: 214(bool) Any 254
Store 216(b) 262 Branch 248
263: 214(bool) Load 216(b) 248: Label
264: 219(bvec4) Load 242(ub41) 256: 214(bool) Phi 246 240 255 247
265: 219(bvec4) LogicalNot 264 Store 216(b) 256
266: 214(bool) Any 265 257: 214(bool) Load 216(b)
267: 214(bool) LogicalAnd 263 266 SelectionMerge 259 None
Store 216(b) 267 BranchConditional 257 258 259
268: 18(int) Load 20(i) 258: Label
269: 18(int) Load 22(ui) 260: 219(bvec4) Load 250(ub41)
270: 18(int) IAdd 268 269 261: 219(bvec4) Load 252(ub42)
271: 18(int) Load 20(i) 262: 219(bvec4) INotEqual 260 261
272: 18(int) IMul 270 271 263: 214(bool) Any 262
273: 18(int) Load 22(ui) Branch 259
274: 18(int) ISub 272 273 259: Label
275: 18(int) Load 20(i) 264: 214(bool) Phi 257 248 263 258
276: 18(int) SDiv 274 275 Store 216(b) 264
Store 20(i) 276 265: 214(bool) Load 216(b)
277: 18(int) Load 20(i) 266: 219(bvec4) Load 250(ub41)
278: 18(int) Load 22(ui) 267: 214(bool) Any 266
279: 18(int) SMod 277 278 268: 214(bool) LogicalAnd 265 267
Store 20(i) 279 Store 216(b) 268
269: 214(bool) Load 216(b)
270: 219(bvec4) Load 250(ub41)
271: 214(bool) All 270
272: 214(bool) LogicalAnd 269 271
Store 216(b) 272
273: 214(bool) Load 216(b)
SelectionMerge 275 None
BranchConditional 273 274 275
274: Label
276: 219(bvec4) Load 250(ub41)
277: 219(bvec4) LogicalNot 276
278: 214(bool) Any 277
Branch 275
275: Label
279: 214(bool) Phi 273 259 278 274
Store 216(b) 279
280: 18(int) Load 20(i) 280: 18(int) Load 20(i)
281: 18(int) Load 22(ui) 281: 18(int) Load 22(ui)
282: 214(bool) IEqual 280 281 282: 18(int) IAdd 280 281
283: 18(int) Load 20(i) 283: 18(int) Load 20(i)
284: 18(int) Load 22(ui) 284: 18(int) IMul 282 283
285: 214(bool) INotEqual 283 284 285: 18(int) Load 22(ui)
286: 18(int) Load 20(i) 286: 18(int) ISub 284 285
287: 18(int) Load 22(ui) 287: 18(int) Load 20(i)
288: 214(bool) IEqual 286 287 288: 18(int) SDiv 286 287
289: 214(bool) LogicalAnd 285 288 Store 20(i) 288
290: 18(int) Load 20(i) 289: 18(int) Load 20(i)
292: 214(bool) INotEqual 290 291 290: 18(int) Load 22(ui)
293: 214(bool) LogicalNotEqual 289 292 291: 18(int) SMod 289 290
294: 214(bool) LogicalOr 282 293 Store 20(i) 291
SelectionMerge 296 None 292: 18(int) Load 20(i)
BranchConditional 294 295 296 293: 18(int) Load 22(ui)
295: Label 294: 214(bool) IEqual 292 293
297: 18(int) Load 20(i) 295: 214(bool) LogicalNot 294
299: 18(int) IAdd 297 298 SelectionMerge 297 None
Store 20(i) 299 BranchConditional 295 296 297
Branch 296 296: Label
296: Label 298: 18(int) Load 20(i)
302: 6(float) Load 169(uf) 299: 18(int) Load 22(ui)
303: 6(float) Load 169(uf) 300: 214(bool) INotEqual 298 299
304: 6(float) FAdd 302 303 301: 18(int) Load 20(i)
305: 6(float) Load 169(uf) 302: 18(int) Load 22(ui)
306: 6(float) FMul 304 305 303: 214(bool) IEqual 301 302
307: 6(float) Load 169(uf) 304: 214(bool) LogicalAnd 300 303
308: 6(float) FSub 306 307 305: 18(int) Load 20(i)
309: 6(float) Load 169(uf) 307: 214(bool) INotEqual 305 306
310: 6(float) FDiv 308 309 308: 214(bool) LogicalNotEqual 304 307
Store 301(f) 310 Branch 297
311: 7(fvec4) Load 9(v) 297: Label
312: 6(float) ExtInst 1(GLSL.std.450) 65(Length) 311 309: 214(bool) Phi 294 275 308 296
313: 6(float) Load 301(f) SelectionMerge 311 None
314: 6(float) FAdd 313 312 BranchConditional 309 310 311
Store 301(f) 314 310: Label
315: 7(fvec4) Load 9(v) 312: 18(int) Load 20(i)
316: 7(fvec4) Load 9(v) 314: 18(int) IAdd 312 313
317: 6(float) ExtInst 1(GLSL.std.450) 66(Distance) 315 316 Store 20(i) 314
318: 6(float) Load 301(f) Branch 311
319: 6(float) FAdd 318 317 311: Label
Store 301(f) 319 317: 6(float) Load 169(uf)
320: 7(fvec4) Load 9(v) 318: 6(float) Load 169(uf)
321: 7(fvec4) Load 9(v) 319: 6(float) FAdd 317 318
322: 6(float) Dot 320 321 320: 6(float) Load 169(uf)
323: 6(float) Load 301(f) 321: 6(float) FMul 319 320
324: 6(float) FAdd 323 322 322: 6(float) Load 169(uf)
Store 301(f) 324 323: 6(float) FSub 321 322
325: 6(float) Load 301(f) 324: 6(float) Load 169(uf)
326: 6(float) Load 169(uf) 325: 6(float) FDiv 323 324
327: 6(float) FMul 325 326 Store 316(f) 325
328: 6(float) Load 301(f) 326: 7(fvec4) Load 9(v)
327: 6(float) ExtInst 1(GLSL.std.450) 65(Length) 326
328: 6(float) Load 316(f)
329: 6(float) FAdd 328 327 329: 6(float) FAdd 328 327
Store 301(f) 329 Store 316(f) 329
330: 7(fvec4) Load 9(v)
331: 7(fvec4) Load 9(v) 331: 7(fvec4) Load 9(v)
332: 330(fvec3) VectorShuffle 331 331 0 1 2 332: 6(float) ExtInst 1(GLSL.std.450) 66(Distance) 330 331
333: 7(fvec4) Load 9(v) 333: 6(float) Load 316(f)
334: 330(fvec3) VectorShuffle 333 333 0 1 2 334: 6(float) FAdd 333 332
335: 330(fvec3) ExtInst 1(GLSL.std.450) 67(Cross) 332 334 Store 316(f) 334
336: 6(float) CompositeExtract 335 0 335: 7(fvec4) Load 9(v)
337: 6(float) Load 301(f) 336: 7(fvec4) Load 9(v)
338: 6(float) FAdd 337 336 337: 6(float) Dot 335 336
Store 301(f) 338 338: 6(float) Load 316(f)
339: 6(float) Load 301(f) 339: 6(float) FAdd 338 337
340: 6(float) Load 169(uf) Store 316(f) 339
341: 214(bool) FOrdEqual 339 340 340: 6(float) Load 316(f)
342: 6(float) Load 301(f) 341: 6(float) Load 169(uf)
343: 6(float) Load 169(uf) 342: 6(float) FMul 340 341
344: 214(bool) FOrdNotEqual 342 343 343: 6(float) Load 316(f)
345: 6(float) Load 301(f) 344: 6(float) FAdd 343 342
347: 214(bool) FOrdNotEqual 345 346 Store 316(f) 344
348: 214(bool) LogicalAnd 344 347 346: 7(fvec4) Load 9(v)
349: 214(bool) LogicalOr 341 348 347: 345(fvec3) VectorShuffle 346 346 0 1 2
SelectionMerge 351 None 348: 7(fvec4) Load 9(v)
BranchConditional 349 350 351 349: 345(fvec3) VectorShuffle 348 348 0 1 2
350: Label 350: 345(fvec3) ExtInst 1(GLSL.std.450) 67(Cross) 347 349
352: 6(float) Load 301(f) 351: 6(float) CompositeExtract 350 0
354: 6(float) FAdd 352 353 352: 6(float) Load 316(f)
Store 301(f) 354 353: 6(float) FAdd 352 351
Branch 351 Store 316(f) 353
351: Label 354: 6(float) Load 316(f)
355: 18(int) Load 22(ui) 355: 6(float) Load 169(uf)
356: 18(int) Load 20(i) 356: 214(bool) FOrdEqual 354 355
357: 18(int) BitwiseAnd 356 355 357: 214(bool) LogicalNot 356
Store 20(i) 357 SelectionMerge 359 None
359: 18(int) Load 20(i) BranchConditional 357 358 359
360: 18(int) BitwiseOr 359 358 358: Label
Store 20(i) 360 360: 6(float) Load 316(f)
361: 18(int) Load 22(ui) 361: 6(float) Load 169(uf)
362: 18(int) Load 20(i) 362: 214(bool) FOrdNotEqual 360 361
363: 18(int) BitwiseXor 362 361 363: 6(float) Load 316(f)
Store 20(i) 363 365: 214(bool) FOrdNotEqual 363 364
365: 18(int) Load 20(i) 366: 214(bool) LogicalAnd 362 365
366: 18(int) SMod 365 364 Branch 359
Store 20(i) 366 359: Label
367: 18(int) Load 20(i) 367: 214(bool) Phi 356 311 366 358
368: 18(int) ShiftRightArithmetic 367 291 SelectionMerge 369 None
Store 20(i) 368 BranchConditional 367 368 369
369: 18(int) Load 22(ui) 368: Label
370: 18(int) Load 20(i) 370: 6(float) Load 316(f)
371: 18(int) ShiftLeftLogical 370 369 372: 6(float) FAdd 370 371
Store 20(i) 371 Store 316(f) 372
372: 18(int) Load 20(i) Branch 369
373: 18(int) Not 372 369: Label
Store 20(i) 373 373: 18(int) Load 22(ui)
374: 214(bool) Load 216(b) 374: 18(int) Load 20(i)
375: 214(bool) LogicalNot 374 375: 18(int) BitwiseAnd 374 373
Store 216(b) 375 Store 20(i) 375
379: 214(bool) Load 216(b) 377: 18(int) Load 20(i)
SelectionMerge 381 None 378: 18(int) BitwiseOr 377 376
BranchConditional 379 380 390 Store 20(i) 378
380: Label 379: 18(int) Load 22(ui)
382: 18(int) Load 20(i) 380: 18(int) Load 20(i)
383: 6(float) ConvertSToF 382 381: 18(int) BitwiseXor 380 379
384: 7(fvec4) CompositeConstruct 383 383 383 383 Store 20(i) 381
385: 6(float) Load 301(f) 383: 18(int) Load 20(i)
386: 7(fvec4) CompositeConstruct 385 385 385 385 384: 18(int) SMod 383 382
387: 7(fvec4) FAdd 384 386 Store 20(i) 384
388: 7(fvec4) Load 9(v) 385: 18(int) Load 20(i)
389: 7(fvec4) FAdd 387 388 386: 18(int) ShiftRightArithmetic 385 306
Store 378 389 Store 20(i) 386
Branch 381 387: 18(int) Load 22(ui)
390: Label 388: 18(int) Load 20(i)
391: 7(fvec4) Load 9(v) 389: 18(int) ShiftLeftLogical 388 387
Store 378 391 Store 20(i) 389
Branch 381 390: 18(int) Load 20(i)
381: Label 391: 18(int) Not 390
392: 7(fvec4) Load 378 Store 20(i) 391
Store 377(gl_FragColor) 392 392: 214(bool) Load 216(b)
393: 214(bool) LogicalNot 392
Store 216(b) 393
397: 214(bool) Load 216(b)
SelectionMerge 399 None
BranchConditional 397 398 408
398: Label
400: 18(int) Load 20(i)
401: 6(float) ConvertSToF 400
402: 7(fvec4) CompositeConstruct 401 401 401 401
403: 6(float) Load 316(f)
404: 7(fvec4) CompositeConstruct 403 403 403 403
405: 7(fvec4) FAdd 402 404
406: 7(fvec4) Load 9(v)
407: 7(fvec4) FAdd 405 406
Store 396 407
Branch 399
408: Label
409: 7(fvec4) Load 9(v)
Store 396 409
Branch 399
399: Label
410: 7(fvec4) Load 396
Store 395(gl_FragColor) 410
Return Return
FunctionEnd FunctionEnd

View File

@@ -5,7 +5,7 @@ Linked fragment stage:
// Module Version 99 // Module Version 99
// Generated by (magic number): 51a00bb // Generated by (magic number): 51a00bb
// Id's are bound by 443 // Id's are bound by 452
Source GLSL 130 Source GLSL 130
Capability Shader Capability Shader
@@ -34,50 +34,50 @@ Linked fragment stage:
Name 114 "f3" Name 114 "f3"
Name 118 "f4" Name 118 "f4"
Name 157 "i_i4" Name 157 "i_i4"
Name 312 "gl_FragColor" Name 321 "gl_FragColor"
Name 405 "cv2" Name 414 "cv2"
Name 406 "cv5" Name 415 "cv5"
Name 416 "u_b" Name 425 "u_b"
Name 418 "u_b2" Name 427 "u_b2"
Name 420 "u_b3" Name 429 "u_b3"
Name 422 "u_b4" Name 431 "u_b4"
Name 424 "u_i2" Name 433 "u_i2"
Name 426 "u_i3" Name 435 "u_i3"
Name 428 "u_i4" Name 437 "u_i4"
Name 429 "i_b" Name 438 "i_b"
Name 430 "i_b2" Name 439 "i_b2"
Name 431 "i_b3" Name 440 "i_b3"
Name 432 "i_b4" Name 441 "i_b4"
Name 434 "i_i2" Name 443 "i_i2"
Name 436 "i_i3" Name 445 "i_i3"
Name 438 "i_f2" Name 447 "i_f2"
Name 440 "i_f3" Name 449 "i_f3"
Name 442 "i_f4" Name 451 "i_f4"
Decorate 39(i_i) Flat Decorate 39(i_i) Flat
Decorate 53(i_f) Smooth Decorate 53(i_f) Smooth
Decorate 157(i_i4) Flat Decorate 157(i_i4) Flat
Decorate 312(gl_FragColor) BuiltIn FragColor Decorate 321(gl_FragColor) BuiltIn FragColor
Decorate 416(u_b) NoStaticUse Decorate 425(u_b) NoStaticUse
Decorate 418(u_b2) NoStaticUse Decorate 427(u_b2) NoStaticUse
Decorate 420(u_b3) NoStaticUse Decorate 429(u_b3) NoStaticUse
Decorate 422(u_b4) NoStaticUse Decorate 431(u_b4) NoStaticUse
Decorate 424(u_i2) NoStaticUse Decorate 433(u_i2) NoStaticUse
Decorate 426(u_i3) NoStaticUse Decorate 435(u_i3) NoStaticUse
Decorate 428(u_i4) NoStaticUse Decorate 437(u_i4) NoStaticUse
Decorate 429(i_b) NoStaticUse Decorate 438(i_b) NoStaticUse
Decorate 430(i_b2) NoStaticUse Decorate 439(i_b2) NoStaticUse
Decorate 431(i_b3) NoStaticUse Decorate 440(i_b3) NoStaticUse
Decorate 432(i_b4) NoStaticUse Decorate 441(i_b4) NoStaticUse
Decorate 434(i_i2) Flat Decorate 443(i_i2) Flat
Decorate 434(i_i2) NoStaticUse Decorate 443(i_i2) NoStaticUse
Decorate 436(i_i3) Flat Decorate 445(i_i3) Flat
Decorate 436(i_i3) NoStaticUse Decorate 445(i_i3) NoStaticUse
Decorate 438(i_f2) Smooth Decorate 447(i_f2) Smooth
Decorate 438(i_f2) NoStaticUse Decorate 447(i_f2) NoStaticUse
Decorate 440(i_f3) Smooth Decorate 449(i_f3) Smooth
Decorate 440(i_f3) NoStaticUse Decorate 449(i_f3) NoStaticUse
Decorate 442(i_f4) Smooth Decorate 451(i_f4) Smooth
Decorate 442(i_f4) NoStaticUse Decorate 451(i_f4) NoStaticUse
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeBool 6: TypeBool
@@ -140,36 +140,36 @@ Linked fragment stage:
157(i_i4): 156(ptr) Variable Input 157(i_i4): 156(ptr) Variable Input
159: TypeVector 13(int) 4 159: TypeVector 13(int) 4
160: 159(ivec4) ConstantComposite 14 14 14 14 160: 159(ivec4) ConstantComposite 14 14 14 14
311: TypePointer Output 95(fvec4) 320: TypePointer Output 95(fvec4)
312(gl_FragColor): 311(ptr) Variable Output 321(gl_FragColor): 320(ptr) Variable Output
415: TypePointer UniformConstant 6(bool) 424: TypePointer UniformConstant 6(bool)
416(u_b): 415(ptr) Variable UniformConstant 425(u_b): 424(ptr) Variable UniformConstant
417: TypePointer UniformConstant 23(bvec2) 426: TypePointer UniformConstant 23(bvec2)
418(u_b2): 417(ptr) Variable UniformConstant 427(u_b2): 426(ptr) Variable UniformConstant
419: TypePointer UniformConstant 31(bvec3) 428: TypePointer UniformConstant 31(bvec3)
420(u_b3): 419(ptr) Variable UniformConstant 429(u_b3): 428(ptr) Variable UniformConstant
421: TypePointer UniformConstant 43(bvec4) 430: TypePointer UniformConstant 43(bvec4)
422(u_b4): 421(ptr) Variable UniformConstant 431(u_b4): 430(ptr) Variable UniformConstant
423: TypePointer UniformConstant 66(ivec2) 432: TypePointer UniformConstant 66(ivec2)
424(u_i2): 423(ptr) Variable UniformConstant 433(u_i2): 432(ptr) Variable UniformConstant
425: TypePointer UniformConstant 79(ivec3) 434: TypePointer UniformConstant 79(ivec3)
426(u_i3): 425(ptr) Variable UniformConstant 435(u_i3): 434(ptr) Variable UniformConstant
427: TypePointer UniformConstant 92(ivec4) 436: TypePointer UniformConstant 92(ivec4)
428(u_i4): 427(ptr) Variable UniformConstant 437(u_i4): 436(ptr) Variable UniformConstant
429(i_b): 415(ptr) Variable UniformConstant 438(i_b): 424(ptr) Variable UniformConstant
430(i_b2): 417(ptr) Variable UniformConstant 439(i_b2): 426(ptr) Variable UniformConstant
431(i_b3): 419(ptr) Variable UniformConstant 440(i_b3): 428(ptr) Variable UniformConstant
432(i_b4): 421(ptr) Variable UniformConstant 441(i_b4): 430(ptr) Variable UniformConstant
433: TypePointer Input 66(ivec2) 442: TypePointer Input 66(ivec2)
434(i_i2): 433(ptr) Variable Input 443(i_i2): 442(ptr) Variable Input
435: TypePointer Input 79(ivec3) 444: TypePointer Input 79(ivec3)
436(i_i3): 435(ptr) Variable Input 445(i_i3): 444(ptr) Variable Input
437: TypePointer Input 69(fvec2) 446: TypePointer Input 69(fvec2)
438(i_f2): 437(ptr) Variable Input 447(i_f2): 446(ptr) Variable Input
439: TypePointer Input 82(fvec3) 448: TypePointer Input 82(fvec3)
440(i_f3): 439(ptr) Variable Input 449(i_f3): 448(ptr) Variable Input
441: TypePointer Input 95(fvec4) 450: TypePointer Input 95(fvec4)
442(i_f4): 441(ptr) Variable Input 451(i_f4): 450(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(b): 7(ptr) Variable Function 8(b): 7(ptr) Variable Function
@@ -184,11 +184,11 @@ Linked fragment stage:
110(f2): 109(ptr) Variable Function 110(f2): 109(ptr) Variable Function
114(f3): 113(ptr) Variable Function 114(f3): 113(ptr) Variable Function
118(f4): 117(ptr) Variable Function 118(f4): 117(ptr) Variable Function
288: 105(ptr) Variable Function 297: 105(ptr) Variable Function
298: 105(ptr) Variable Function 307: 105(ptr) Variable Function
313: 117(ptr) Variable Function 322: 117(ptr) Variable Function
405(cv2): 93(ptr) Variable Function 414(cv2): 93(ptr) Variable Function
406(cv5): 44(ptr) Variable Function 415(cv5): 44(ptr) Variable Function
12: 9(int) Load 11(u_i) 12: 9(int) Load 11(u_i)
15: 6(bool) INotEqual 12 14 15: 6(bool) INotEqual 12 14
19: 16(float) Load 18(u_f) 19: 16(float) Load 18(u_f)
@@ -408,170 +408,188 @@ Linked fragment stage:
266: 9(int) Load 58(i) 266: 9(int) Load 58(i)
267: 16(float) ConvertSToF 266 267: 16(float) ConvertSToF 266
268: 6(bool) FOrdLessThan 265 267 268: 6(bool) FOrdLessThan 265 267
269: 9(int) Load 58(i) 269: 6(bool) LogicalNot 268
270: 16(float) ConvertSToF 269 SelectionMerge 271 None
271: 16(float) Load 106(f) BranchConditional 269 270 271
272: 6(bool) FOrdLessThan 270 271 270: Label
273: 6(bool) LogicalOr 268 272 272: 9(int) Load 58(i)
274: 69(fvec2) Load 110(f2) 273: 16(float) ConvertSToF 272
275: 66(ivec2) Load 68(i2) 274: 16(float) Load 106(f)
276: 69(fvec2) ConvertSToF 275 275: 6(bool) FOrdLessThan 273 274
277: 23(bvec2) FOrdEqual 274 276 Branch 271
278: 6(bool) All 277 271: Label
279: 6(bool) LogicalOr 273 278 276: 6(bool) Phi 268 5 275 270
280: 79(ivec3) Load 81(i3) 277: 6(bool) LogicalNot 276
281: 82(fvec3) ConvertSToF 280 SelectionMerge 279 None
282: 82(fvec3) Load 114(f3) BranchConditional 277 278 279
283: 31(bvec3) FOrdNotEqual 281 282 278: Label
284: 6(bool) Any 283 280: 69(fvec2) Load 110(f2)
285: 6(bool) LogicalOr 279 284 281: 66(ivec2) Load 68(i2)
SelectionMerge 287 None 282: 69(fvec2) ConvertSToF 281
BranchConditional 285 286 287 283: 23(bvec2) FOrdEqual 280 282
286: Label 284: 6(bool) All 283
289: 6(bool) Load 8(b) Branch 279
SelectionMerge 291 None 279: Label
BranchConditional 289 290 294 285: 6(bool) Phi 276 271 284 278
290: Label 286: 6(bool) LogicalNot 285
292: 9(int) Load 58(i) SelectionMerge 288 None
293: 16(float) ConvertSToF 292 BranchConditional 286 287 288
Store 288 293 287: Label
Branch 291 289: 79(ivec3) Load 81(i3)
294: Label 290: 82(fvec3) ConvertSToF 289
295: 69(fvec2) Load 110(f2) 291: 82(fvec3) Load 114(f3)
296: 16(float) CompositeExtract 295 0 292: 31(bvec3) FOrdNotEqual 290 291
Store 288 296 293: 6(bool) Any 292
Branch 291 Branch 288
291: Label 288: Label
297: 16(float) Load 288 294: 6(bool) Phi 285 279 293 287
299: 23(bvec2) Load 25(b2) SelectionMerge 296 None
300: 6(bool) CompositeExtract 299 0 BranchConditional 294 295 296
SelectionMerge 302 None 295: Label
BranchConditional 300 301 305 298: 6(bool) Load 8(b)
301: Label SelectionMerge 300 None
303: 82(fvec3) Load 114(f3) BranchConditional 298 299 303
304: 16(float) CompositeExtract 303 0 299: Label
Store 298 304 301: 9(int) Load 58(i)
Branch 302 302: 16(float) ConvertSToF 301
305: Label Store 297 302
306: 66(ivec2) Load 68(i2) Branch 300
307: 9(int) CompositeExtract 306 1 303: Label
308: 16(float) ConvertSToF 307 304: 69(fvec2) Load 110(f2)
Store 298 308 305: 16(float) CompositeExtract 304 0
Branch 302 Store 297 305
302: Label Branch 300
309: 16(float) Load 298 300: Label
310: 16(float) FAdd 297 309 306: 16(float) Load 297
Store 106(f) 310 308: 23(bvec2) Load 25(b2)
Branch 287 309: 6(bool) CompositeExtract 308 0
287: Label SelectionMerge 311 None
314: 6(bool) Load 8(b) BranchConditional 309 310 314
315: 23(bvec2) Load 25(b2) 310: Label
316: 6(bool) CompositeExtract 315 0 312: 82(fvec3) Load 114(f3)
317: 6(bool) LogicalOr 314 316 313: 16(float) CompositeExtract 312 0
318: 23(bvec2) Load 25(b2) Store 307 313
319: 6(bool) CompositeExtract 318 1 Branch 311
320: 6(bool) LogicalOr 317 319 314: Label
321: 31(bvec3) Load 33(b3) 315: 66(ivec2) Load 68(i2)
322: 6(bool) CompositeExtract 321 0 316: 9(int) CompositeExtract 315 1
323: 6(bool) LogicalOr 320 322 317: 16(float) ConvertSToF 316
324: 31(bvec3) Load 33(b3) Store 307 317
325: 6(bool) CompositeExtract 324 1 Branch 311
311: Label
318: 16(float) Load 307
319: 16(float) FAdd 306 318
Store 106(f) 319
Branch 296
296: Label
323: 6(bool) Load 8(b)
324: 23(bvec2) Load 25(b2)
325: 6(bool) CompositeExtract 324 0
326: 6(bool) LogicalOr 323 325 326: 6(bool) LogicalOr 323 325
327: 31(bvec3) Load 33(b3) 327: 23(bvec2) Load 25(b2)
328: 6(bool) CompositeExtract 327 2 328: 6(bool) CompositeExtract 327 1
329: 6(bool) LogicalOr 326 328 329: 6(bool) LogicalOr 326 328
330: 43(bvec4) Load 45(b4) 330: 31(bvec3) Load 33(b3)
331: 6(bool) CompositeExtract 330 0 331: 6(bool) CompositeExtract 330 0
332: 6(bool) LogicalOr 329 331 332: 6(bool) LogicalOr 329 331
333: 43(bvec4) Load 45(b4) 333: 31(bvec3) Load 33(b3)
334: 6(bool) CompositeExtract 333 1 334: 6(bool) CompositeExtract 333 1
335: 6(bool) LogicalOr 332 334 335: 6(bool) LogicalOr 332 334
336: 43(bvec4) Load 45(b4) 336: 31(bvec3) Load 33(b3)
337: 6(bool) CompositeExtract 336 2 337: 6(bool) CompositeExtract 336 2
338: 6(bool) LogicalOr 335 337 338: 6(bool) LogicalOr 335 337
339: 43(bvec4) Load 45(b4) 339: 43(bvec4) Load 45(b4)
340: 6(bool) CompositeExtract 339 3 340: 6(bool) CompositeExtract 339 0
341: 6(bool) LogicalOr 338 340 341: 6(bool) LogicalOr 338 340
SelectionMerge 343 None 342: 43(bvec4) Load 45(b4)
BranchConditional 341 342 403 343: 6(bool) CompositeExtract 342 1
342: Label 344: 6(bool) LogicalOr 341 343
344: 9(int) Load 58(i) 345: 43(bvec4) Load 45(b4)
345: 66(ivec2) Load 68(i2) 346: 6(bool) CompositeExtract 345 2
346: 9(int) CompositeExtract 345 0 347: 6(bool) LogicalOr 344 346
347: 9(int) IAdd 344 346 348: 43(bvec4) Load 45(b4)
348: 66(ivec2) Load 68(i2) 349: 6(bool) CompositeExtract 348 3
349: 9(int) CompositeExtract 348 1 350: 6(bool) LogicalOr 347 349
350: 9(int) IAdd 347 349 SelectionMerge 352 None
351: 79(ivec3) Load 81(i3) BranchConditional 350 351 412
352: 9(int) CompositeExtract 351 0 351: Label
353: 9(int) IAdd 350 352 353: 9(int) Load 58(i)
354: 79(ivec3) Load 81(i3) 354: 66(ivec2) Load 68(i2)
355: 9(int) CompositeExtract 354 1 355: 9(int) CompositeExtract 354 0
356: 9(int) IAdd 353 355 356: 9(int) IAdd 353 355
357: 79(ivec3) Load 81(i3) 357: 66(ivec2) Load 68(i2)
358: 9(int) CompositeExtract 357 2 358: 9(int) CompositeExtract 357 1
359: 9(int) IAdd 356 358 359: 9(int) IAdd 356 358
360: 92(ivec4) Load 94(i4) 360: 79(ivec3) Load 81(i3)
361: 9(int) CompositeExtract 360 0 361: 9(int) CompositeExtract 360 0
362: 9(int) IAdd 359 361 362: 9(int) IAdd 359 361
363: 92(ivec4) Load 94(i4) 363: 79(ivec3) Load 81(i3)
364: 9(int) CompositeExtract 363 1 364: 9(int) CompositeExtract 363 1
365: 9(int) IAdd 362 364 365: 9(int) IAdd 362 364
366: 92(ivec4) Load 94(i4) 366: 79(ivec3) Load 81(i3)
367: 9(int) CompositeExtract 366 2 367: 9(int) CompositeExtract 366 2
368: 9(int) IAdd 365 367 368: 9(int) IAdd 365 367
369: 92(ivec4) Load 94(i4) 369: 92(ivec4) Load 94(i4)
370: 9(int) CompositeExtract 369 3 370: 9(int) CompositeExtract 369 0
371: 9(int) IAdd 368 370 371: 9(int) IAdd 368 370
372: 16(float) ConvertSToF 371 372: 92(ivec4) Load 94(i4)
373: 16(float) Load 106(f) 373: 9(int) CompositeExtract 372 1
374: 16(float) FAdd 372 373 374: 9(int) IAdd 371 373
375: 69(fvec2) Load 110(f2) 375: 92(ivec4) Load 94(i4)
376: 16(float) CompositeExtract 375 0 376: 9(int) CompositeExtract 375 2
377: 16(float) FAdd 374 376 377: 9(int) IAdd 374 376
378: 69(fvec2) Load 110(f2) 378: 92(ivec4) Load 94(i4)
379: 16(float) CompositeExtract 378 1 379: 9(int) CompositeExtract 378 3
380: 16(float) FAdd 377 379 380: 9(int) IAdd 377 379
381: 82(fvec3) Load 114(f3) 381: 16(float) ConvertSToF 380
382: 16(float) CompositeExtract 381 0 382: 16(float) Load 106(f)
383: 16(float) FAdd 380 382 383: 16(float) FAdd 381 382
384: 82(fvec3) Load 114(f3) 384: 69(fvec2) Load 110(f2)
385: 16(float) CompositeExtract 384 1 385: 16(float) CompositeExtract 384 0
386: 16(float) FAdd 383 385 386: 16(float) FAdd 383 385
387: 82(fvec3) Load 114(f3) 387: 69(fvec2) Load 110(f2)
388: 16(float) CompositeExtract 387 2 388: 16(float) CompositeExtract 387 1
389: 16(float) FAdd 386 388 389: 16(float) FAdd 386 388
390: 95(fvec4) Load 118(f4) 390: 82(fvec3) Load 114(f3)
391: 16(float) CompositeExtract 390 0 391: 16(float) CompositeExtract 390 0
392: 16(float) FAdd 389 391 392: 16(float) FAdd 389 391
393: 95(fvec4) Load 118(f4) 393: 82(fvec3) Load 114(f3)
394: 16(float) CompositeExtract 393 1 394: 16(float) CompositeExtract 393 1
395: 16(float) FAdd 392 394 395: 16(float) FAdd 392 394
396: 95(fvec4) Load 118(f4) 396: 82(fvec3) Load 114(f3)
397: 16(float) CompositeExtract 396 2 397: 16(float) CompositeExtract 396 2
398: 16(float) FAdd 395 397 398: 16(float) FAdd 395 397
399: 95(fvec4) Load 118(f4) 399: 95(fvec4) Load 118(f4)
400: 16(float) CompositeExtract 399 3 400: 16(float) CompositeExtract 399 0
401: 16(float) FAdd 398 400 401: 16(float) FAdd 398 400
402: 95(fvec4) CompositeConstruct 401 401 401 401 402: 95(fvec4) Load 118(f4)
Store 313 402 403: 16(float) CompositeExtract 402 1
Branch 343 404: 16(float) FAdd 401 403
403: Label 405: 95(fvec4) Load 118(f4)
Store 313 151 406: 16(float) CompositeExtract 405 2
Branch 343 407: 16(float) FAdd 404 406
343: Label 408: 95(fvec4) Load 118(f4)
404: 95(fvec4) Load 313 409: 16(float) CompositeExtract 408 3
Store 312(gl_FragColor) 404 410: 16(float) FAdd 407 409
Store 405(cv2) 102 411: 95(fvec4) CompositeConstruct 410 410 410 410
407: 92(ivec4) Load 405(cv2) Store 322 411
408: 43(bvec4) INotEqual 407 160 Branch 352
Store 406(cv5) 408 412: Label
409: 43(bvec4) Load 406(cv5) Store 322 151
410: 95(fvec4) Select 409 151 150 Branch 352
411: 16(float) CompositeExtract 410 0 352: Label
412: 95(fvec4) Load 312(gl_FragColor) 413: 95(fvec4) Load 322
413: 95(fvec4) CompositeConstruct 411 411 411 411 Store 321(gl_FragColor) 413
414: 95(fvec4) FAdd 412 413 Store 414(cv2) 102
Store 312(gl_FragColor) 414 416: 92(ivec4) Load 414(cv2)
417: 43(bvec4) INotEqual 416 160
Store 415(cv5) 417
418: 43(bvec4) Load 415(cv5)
419: 95(fvec4) Select 418 151 150
420: 16(float) CompositeExtract 419 0
421: 95(fvec4) Load 321(gl_FragColor)
422: 95(fvec4) CompositeConstruct 420 420 420 420
423: 95(fvec4) FAdd 421 422
Store 321(gl_FragColor) 423
Return Return
FunctionEnd FunctionEnd

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,237 @@
spv.shortCircuit.frag
Warning, version 400 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 143
Source GLSL 400
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Name 4 "main"
Name 8 "foo("
Name 12 "of1"
Name 23 "of4"
Name 26 "ub"
Name 30 "ui"
Name 40 "uba"
Name 109 "uf"
Name 136 "uiv4"
Name 138 "uv4"
Name 141 "ub41"
Name 142 "ub42"
Decorate 136(uiv4) NoStaticUse
Decorate 138(uv4) NoStaticUse
Decorate 141(ub41) NoStaticUse
Decorate 142(ub42) NoStaticUse
2: TypeVoid
3: TypeFunction 2
6: TypeBool
7: TypeFunction 6(bool)
10: TypeFloat 32
11: TypePointer Output 10(float)
12(of1): 11(ptr) Variable Output
14: 10(float) Constant 1065353216
17: 10(float) Constant 1092616192
20: 10(float) Constant 0
21: TypeVector 10(float) 4
22: TypePointer Output 21(fvec4)
23(of4): 22(ptr) Variable Output
24: 21(fvec4) ConstantComposite 20 20 20 20
25: TypePointer UniformConstant 6(bool)
26(ub): 25(ptr) Variable UniformConstant
28: TypeInt 32 1
29: TypePointer UniformConstant 28(int)
30(ui): 29(ptr) Variable UniformConstant
32: 28(int) Constant 2
40(uba): 25(ptr) Variable UniformConstant
108: TypePointer UniformConstant 10(float)
109(uf): 108(ptr) Variable UniformConstant
112: 10(float) Constant 1082130432
134: TypeVector 28(int) 4
135: TypePointer UniformConstant 134(ivec4)
136(uiv4): 135(ptr) Variable UniformConstant
137: TypePointer UniformConstant 21(fvec4)
138(uv4): 137(ptr) Variable UniformConstant
139: TypeVector 6(bool) 4
140: TypePointer UniformConstant 139(bvec4)
141(ub41): 140(ptr) Variable UniformConstant
142(ub42): 140(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
Store 12(of1) 20
Store 23(of4) 24
27: 6(bool) Load 26(ub)
31: 28(int) Load 30(ui)
33: 6(bool) SGreaterThan 31 32
34: 6(bool) LogicalOr 27 33
SelectionMerge 36 None
BranchConditional 34 35 36
35: Label
37: 10(float) Load 12(of1)
38: 10(float) FAdd 37 14
Store 12(of1) 38
Branch 36
36: Label
39: 6(bool) Load 26(ub)
41: 6(bool) Load 40(uba)
42: 6(bool) LogicalNot 41
43: 6(bool) LogicalAnd 39 42
SelectionMerge 45 None
BranchConditional 43 44 45
44: Label
46: 10(float) Load 12(of1)
47: 10(float) FAdd 46 14
Store 12(of1) 47
Branch 45
45: Label
48: 6(bool) Load 26(ub)
49: 6(bool) LogicalNot 48
SelectionMerge 51 None
BranchConditional 49 50 51
50: Label
52: 6(bool) FunctionCall 8(foo()
Branch 51
51: Label
53: 6(bool) Phi 48 45 52 50
SelectionMerge 55 None
BranchConditional 53 54 55
54: Label
56: 10(float) Load 12(of1)
57: 10(float) FAdd 56 14
Store 12(of1) 57
Branch 55
55: Label
58: 6(bool) Load 26(ub)
SelectionMerge 60 None
BranchConditional 58 59 60
59: Label
61: 6(bool) FunctionCall 8(foo()
Branch 60
60: Label
62: 6(bool) Phi 58 55 61 59
SelectionMerge 64 None
BranchConditional 62 63 64
63: Label
65: 10(float) Load 12(of1)
66: 10(float) FAdd 65 14
Store 12(of1) 66
Branch 64
64: Label
67: 6(bool) FunctionCall 8(foo()
68: 6(bool) Load 26(ub)
69: 6(bool) LogicalOr 67 68
SelectionMerge 71 None
BranchConditional 69 70 71
70: Label
72: 10(float) Load 12(of1)
73: 10(float) FAdd 72 14
Store 12(of1) 73
Branch 71
71: Label
74: 6(bool) FunctionCall 8(foo()
75: 6(bool) Load 26(ub)
76: 6(bool) LogicalAnd 74 75
SelectionMerge 78 None
BranchConditional 76 77 78
77: Label
79: 10(float) Load 12(of1)
80: 10(float) FAdd 79 14
Store 12(of1) 80
Branch 78
78: Label
81: 6(bool) Load 26(ub)
82: 6(bool) LogicalNot 81
SelectionMerge 84 None
BranchConditional 82 83 84
83: Label
85: 10(float) Load 12(of1)
86: 10(float) FAdd 85 14
Store 12(of1) 86
87: 6(bool) FOrdGreaterThan 86 14
Branch 84
84: Label
88: 6(bool) Phi 81 78 87 83
SelectionMerge 90 None
BranchConditional 88 89 90
89: Label
91: 21(fvec4) Load 23(of4)
92: 21(fvec4) CompositeConstruct 14 14 14 14
93: 21(fvec4) FAdd 91 92
Store 23(of4) 93
Branch 90
90: Label
94: 10(float) Load 12(of1)
95: 10(float) FAdd 94 14
Store 12(of1) 95
96: 6(bool) FOrdGreaterThan 95 14
97: 6(bool) Load 26(ub)
98: 6(bool) LogicalOr 96 97
SelectionMerge 100 None
BranchConditional 98 99 100
99: Label
101: 21(fvec4) Load 23(of4)
102: 21(fvec4) CompositeConstruct 14 14 14 14
103: 21(fvec4) FAdd 101 102
Store 23(of4) 103
Branch 100
100: Label
104: 6(bool) Load 26(ub)
105: 6(bool) LogicalNot 104
SelectionMerge 107 None
BranchConditional 105 106 107
106: Label
110: 10(float) Load 109(uf)
111: 10(float) ExtInst 1(GLSL.std.450) 13(Sin) 110
113: 10(float) FMul 111 112
114: 10(float) Load 12(of1)
115: 6(bool) FOrdGreaterThan 113 114
Branch 107
107: Label
116: 6(bool) Phi 104 100 115 106
SelectionMerge 118 None
BranchConditional 116 117 118
117: Label
119: 10(float) Load 12(of1)
120: 10(float) FAdd 119 14
Store 12(of1) 120
Branch 118
118: Label
121: 6(bool) Load 26(ub)
SelectionMerge 123 None
BranchConditional 121 122 123
122: Label
124: 10(float) Load 109(uf)
125: 10(float) ExtInst 1(GLSL.std.450) 13(Sin) 124
126: 10(float) FMul 125 112
127: 10(float) Load 12(of1)
128: 6(bool) FOrdGreaterThan 126 127
Branch 123
123: Label
129: 6(bool) Phi 121 118 128 122
SelectionMerge 131 None
BranchConditional 129 130 131
130: Label
132: 10(float) Load 12(of1)
133: 10(float) FAdd 132 14
Store 12(of1) 133
Branch 131
131: Label
Return
FunctionEnd
8(foo(): 6(bool) Function None 7
9: Label
13: 10(float) Load 12(of1)
15: 10(float) FAdd 13 14
Store 12(of1) 15
16: 10(float) Load 12(of1)
18: 6(bool) FOrdGreaterThan 16 17
ReturnValue 18
FunctionEnd

50
Test/spv.shortCircuit.frag Executable file
View File

@@ -0,0 +1,50 @@
#version 400
uniform ivec4 uiv4;
uniform vec4 uv4;
uniform bool ub;
uniform bool uba;
uniform bvec4 ub41, ub42;
uniform float uf;
uniform int ui;
out float of1;
out vec4 of4;
bool foo() { ++of1; return of1 > 10.0; }
void main()
{
of1 = 0.0;
of4 = vec4(0.0);
if (ub || ui > 2) // not worth short circuiting
++of1;
if (ub && !uba) // not worth short circuiting
++of1;
if (ub || foo()) // must short circuit
++of1;
if (ub && foo()) // must short circuit
++of1;
if (foo() || ub) // not worth short circuiting
++of1;
if (foo() && ub) // not worth short circuiting
++of1;
if (ub || ++of1 > 1.0) // must short circuit
++of4;
if (++of1 > 1.0 || ub) // not worth short circuiting
++of4;
if (ub || sin(uf) * 4.0 > of1) // worth short circuiting
++of1;
if (ub && sin(uf) * 4.0 > of1) // worth short circuiting
++of1;
}

View File

@@ -82,3 +82,6 @@ spv.whileLoop.frag
spv.atomic.comp spv.atomic.comp
spv.AofA.frag spv.AofA.frag
spv.queryL.frag spv.queryL.frag
spv.shortCircuit.frag
# GLSL-level semantics
vulkan.frag

View File

@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "3.0.788" #define GLSLANG_REVISION "3.0.789"
#define GLSLANG_DATE "14-Oct-2015" #define GLSLANG_DATE "15-Oct-2015"