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

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