Unverified Commit cdf7a85b by John Kessenich Committed by GitHub

Merge pull request #1557 from nicebyte/spec-const-decorations

Add names for composite spec constants in SPIR-V
parents a440fbb0 4c9876b3
......@@ -7292,18 +7292,19 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
// An AST node labelled as specialization constant should be a symbol node.
// Its initializer should either be a sub tree with constant nodes, or a constant union array.
if (auto* sn = node.getAsSymbolNode()) {
spv::Id result;
if (auto* sub_tree = sn->getConstSubtree()) {
// Traverse the constant constructor sub tree like generating normal run-time instructions.
// During the AST traversal, if the node is marked as 'specConstant', SpecConstantOpModeGuard
// will set the builder into spec constant op instruction generating mode.
sub_tree->traverse(this);
return accessChainLoad(sub_tree->getType());
} else if (auto* const_union_array = &sn->getConstArray()){
result = accessChainLoad(sub_tree->getType());
} else if (auto* const_union_array = &sn->getConstArray()) {
int nextConst = 0;
spv::Id id = createSpvConstantFromConstUnionArray(sn->getType(), *const_union_array, nextConst, true);
builder.addName(id, sn->getName().c_str());
return id;
result = createSpvConstantFromConstUnionArray(sn->getType(), *const_union_array, nextConst, true);
}
builder.addName(result, sn->getName().c_str());
return result;
}
// Neither a front-end constant node, nor a specialization constant node with constant union array or
......
......@@ -114,6 +114,10 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Name 526 "sf16"
Name 527 "sf"
Name 528 "sd"
Name 529 "f16_to_f"
Name 531 "f16_to_d"
Name 532 "f_to_f16"
Name 533 "d_to_f16"
Decorate 512 ArrayStride 16
Decorate 513 ArrayStride 32
MemberDecorate 514(S) 0 Offset 0
......@@ -235,11 +239,11 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
526(sf16):28(float16_t) SpecConstant 12288
527(sf): 164(float) SpecConstant 1048576000
528(sd):172(float64_t) SpecConstant 0 1071644672
529: 164(float) SpecConstantOp 115 526(sf16)
529(f16_to_f): 164(float) SpecConstantOp 115 526(sf16)
530: 164(float) SpecConstantOp 115 526(sf16)
531:172(float64_t) SpecConstantOp 115 530
532:28(float16_t) SpecConstantOp 115 527(sf)
533:28(float16_t) SpecConstantOp 115 528(sd)
531(f16_to_d):172(float64_t) SpecConstantOp 115 530
532(f_to_f16):28(float16_t) SpecConstantOp 115 527(sf)
533(d_to_f16):28(float16_t) SpecConstantOp 115 528(sd)
4(main): 2 Function None 3
5: Label
Return
......
......@@ -104,6 +104,10 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
Name 525 "sf16"
Name 526 "sf"
Name 527 "sd"
Name 528 "f16_to_f"
Name 530 "f16_to_d"
Name 531 "f_to_f16"
Name 532 "d_to_f16"
Decorate 518 ArrayStride 16
Decorate 519 ArrayStride 32
MemberDecorate 520(S) 0 Offset 0
......@@ -209,11 +213,11 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
525(sf16):172(float16_t) SpecConstant 12288
526(sf): 26(float) SpecConstant 1048576000
527(sd):149(float64_t) SpecConstant 0 1071644672
528: 26(float) SpecConstantOp 115 525(sf16)
528(f16_to_f): 26(float) SpecConstantOp 115 525(sf16)
529: 26(float) SpecConstantOp 115 525(sf16)
530:149(float64_t) SpecConstantOp 115 529
531:172(float16_t) SpecConstantOp 115 526(sf)
532:172(float16_t) SpecConstantOp 115 527(sd)
530(f16_to_d):149(float64_t) SpecConstantOp 115 529
531(f_to_f16):172(float16_t) SpecConstantOp 115 526(sf)
532(d_to_f16):172(float16_t) SpecConstantOp 115 527(sd)
4(main): 2 Function None 3
5: Label
Return
......
......@@ -103,6 +103,10 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
Name 515 "sf16"
Name 517 "sf"
Name 518 "sd"
Name 519 "f16_to_f"
Name 521 "f16_to_d"
Name 522 "f_to_f16"
Name 523 "d_to_f16"
Decorate 461(if64v) Flat
Decorate 508 ArrayStride 16
Decorate 509 ArrayStride 64
......@@ -207,11 +211,11 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
516: TypeFloat 32
517(sf): 516(float) SpecConstant 1048576000
518(sd):26(float64_t) SpecConstant 0 1071644672
519: 516(float) SpecConstantOp 115 515(sf16)
519(f16_to_f): 516(float) SpecConstantOp 115 515(sf16)
520: 516(float) SpecConstantOp 115 515(sf16)
521:26(float64_t) SpecConstantOp 115 520
522:162(float16_t) SpecConstantOp 115 517(sf)
523:162(float16_t) SpecConstantOp 115 518(sd)
521(f16_to_d):26(float64_t) SpecConstantOp 115 520
522(f_to_f16):162(float16_t) SpecConstantOp 115 517(sf)
523(d_to_f16):162(float16_t) SpecConstantOp 115 518(sd)
4(main): 2 Function None 3
5: Label
Return
......
......@@ -76,6 +76,28 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Name 526 "sb"
Name 527 "si16"
Name 528 "su16"
Name 529 "i16_to_b"
Name 530 "u16_to_b"
Name 531 "b_to_i16"
Name 532 "b_to_u16"
Name 533 "i16_to_i"
Name 535 "u16_to_i"
Name 536 "i_to_i16"
Name 538 "i_to_u16"
Name 540 "i16_to_u"
Name 541 "u16_to_u"
Name 543 "u_to_i16"
Name 544 "u_to_u16"
Name 545 "i16_to_i64"
Name 548 "u16_to_i64"
Name 549 "i64_to_i16"
Name 551 "i64_to_u16"
Name 553 "i16_to_u64"
Name 554 "u16_to_u64"
Name 556 "u64_to_i16"
Name 557 "u64_to_u16"
Name 558 "i16_to_u16"
Name 559 "u16_to_i16"
MemberDecorate 25(Uniforms) 0 Offset 0
Decorate 25(Uniforms) Block
Decorate 27 DescriptorSet 0
......@@ -195,37 +217,37 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
526(sb): 125(bool) SpecConstantTrue
527(si16): 17(int16_t) SpecConstant 4294967291
528(su16): 14(int16_t) SpecConstant 4
529: 125(bool) SpecConstantOp 171 527(si16) 202
530: 125(bool) SpecConstantOp 171 528(su16) 202
531: 17(int16_t) SpecConstantOp 169 526(sb) 53 194
532: 14(int16_t) SpecConstantOp 169 526(sb) 203 202
533: 28(int) SpecConstantOp 114 527(si16)
529(i16_to_b): 125(bool) SpecConstantOp 171 527(si16) 202
530(u16_to_b): 125(bool) SpecConstantOp 171 528(su16) 202
531(b_to_i16): 17(int16_t) SpecConstantOp 169 526(sb) 53 194
532(b_to_u16): 14(int16_t) SpecConstantOp 169 526(sb) 203 202
533(i16_to_i): 28(int) SpecConstantOp 114 527(si16)
534: 18(int) SpecConstantOp 113 528(su16)
535: 28(int) SpecConstantOp 128 534 128
536: 17(int16_t) SpecConstantOp 114 524(si)
535(u16_to_i): 28(int) SpecConstantOp 128 534 128
536(i_to_i16): 17(int16_t) SpecConstantOp 114 524(si)
537: 17(int16_t) SpecConstantOp 114 524(si)
538: 14(int16_t) SpecConstantOp 128 537 202
538(i_to_u16): 14(int16_t) SpecConstantOp 128 537 202
539: 28(int) SpecConstantOp 114 527(si16)
540: 18(int) SpecConstantOp 128 539 128
541: 18(int) SpecConstantOp 113 528(su16)
540(i16_to_u): 18(int) SpecConstantOp 128 539 128
541(u16_to_u): 18(int) SpecConstantOp 113 528(su16)
542: 14(int16_t) SpecConstantOp 113 525(su)
543: 17(int16_t) SpecConstantOp 128 542 202
544: 14(int16_t) SpecConstantOp 113 525(su)
545:273(int64_t) SpecConstantOp 114 527(si16)
543(u_to_i16): 17(int16_t) SpecConstantOp 128 542 202
544(u_to_u16): 14(int16_t) SpecConstantOp 113 525(su)
545(i16_to_i64):273(int64_t) SpecConstantOp 114 527(si16)
546:285(int64_t) SpecConstantOp 113 528(su16)
547:285(int64_t) Constant 0 0
548:273(int64_t) SpecConstantOp 128 546 547
549: 17(int16_t) SpecConstantOp 114 522(si64)
548(u16_to_i64):273(int64_t) SpecConstantOp 128 546 547
549(i64_to_i16): 17(int16_t) SpecConstantOp 114 522(si64)
550: 17(int16_t) SpecConstantOp 114 522(si64)
551: 14(int16_t) SpecConstantOp 128 550 202
551(i64_to_u16): 14(int16_t) SpecConstantOp 128 550 202
552:273(int64_t) SpecConstantOp 114 527(si16)
553:285(int64_t) SpecConstantOp 128 552 547
554:285(int64_t) SpecConstantOp 113 528(su16)
553(i16_to_u64):285(int64_t) SpecConstantOp 128 552 547
554(u16_to_u64):285(int64_t) SpecConstantOp 113 528(su16)
555: 14(int16_t) SpecConstantOp 113 523(su64)
556: 17(int16_t) SpecConstantOp 128 555 202
557: 14(int16_t) SpecConstantOp 113 523(su64)
558: 14(int16_t) SpecConstantOp 128 527(si16) 202
559: 17(int16_t) SpecConstantOp 128 528(su16) 202
556(u64_to_i16): 17(int16_t) SpecConstantOp 128 555 202
557(u64_to_u16): 14(int16_t) SpecConstantOp 113 523(su64)
558(i16_to_u16): 14(int16_t) SpecConstantOp 128 527(si16) 202
559(u16_to_i16): 17(int16_t) SpecConstantOp 128 528(su16) 202
4(main): 2 Function None 3
5: Label
511: 2 FunctionCall 6(literal()
......
spv.int64.frag
error: SPIRV-Tools Validation Errors
error: OpDecorate SpecId decoration target <id> '1' is not a scalar specialization constant.
OpDecorate %su64inc SpecId 105
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 488
// Id's are bound by 489
Capability Shader
Capability Float64
......@@ -55,6 +59,21 @@ spv.int64.frag
Name 467 "si"
Name 468 "su"
Name 469 "sb"
Name 470 "su64inc"
Name 471 "i64_to_b"
Name 472 "u64_to_b"
Name 473 "b_to_i64"
Name 474 "b_to_u64"
Name 475 "i64_to_i"
Name 476 "i_to_i64"
Name 477 "u64_to_u"
Name 478 "u_to_u64"
Name 479 "u64_to_i64"
Name 480 "i64_to_u64"
Name 482 "u64_to_i"
Name 484 "i_to_u64"
Name 486 "i64_to_u"
Name 488 "u_to_i64"
MemberDecorate 28(Uniforms) 0 Offset 0
Decorate 28(Uniforms) Block
Decorate 30 DescriptorSet 0
......@@ -69,6 +88,7 @@ spv.int64.frag
Decorate 467(si) SpecId 102
Decorate 468(su) SpecId 103
Decorate 469(sb) SpecId 104
Decorate 470(su64inc) SpecId 105
2: TypeVoid
3: TypeFunction 2
14: TypeInt 64 0
......@@ -157,24 +177,25 @@ spv.int64.frag
467(si): 31(int) SpecConstant 4294967291
468(su): 21(int) SpecConstant 4
469(sb): 55(bool) SpecConstantTrue
470: 55(bool) SpecConstantOp 171 465(si64) 69
471: 55(bool) SpecConstantOp 171 466(su64) 69
472: 18(int64_t) SpecConstantOp 169 469(sb) 61 60
473: 14(int64_t) SpecConstantOp 169 469(sb) 70 69
474: 31(int) SpecConstantOp 114 465(si64)
475: 18(int64_t) SpecConstantOp 114 467(si)
476: 21(int) SpecConstantOp 113 466(su64)
477: 14(int64_t) SpecConstantOp 113 468(su)
478: 18(int64_t) SpecConstantOp 128 466(su64) 69
479: 14(int64_t) SpecConstantOp 128 465(si64) 69
480: 21(int) SpecConstantOp 113 466(su64)
481: 31(int) SpecConstantOp 128 480 227
482: 18(int64_t) SpecConstantOp 114 467(si)
483: 14(int64_t) SpecConstantOp 128 482 69
484: 31(int) SpecConstantOp 114 465(si64)
485: 21(int) SpecConstantOp 128 484 227
486: 14(int64_t) SpecConstantOp 113 468(su)
487: 18(int64_t) SpecConstantOp 128 486 69
470(su64inc): 14(int64_t) SpecConstantOp 128 466(su64) 70
471(i64_to_b): 55(bool) SpecConstantOp 171 465(si64) 69
472(u64_to_b): 55(bool) SpecConstantOp 171 466(su64) 69
473(b_to_i64): 18(int64_t) SpecConstantOp 169 469(sb) 61 60
474(b_to_u64): 14(int64_t) SpecConstantOp 169 469(sb) 70 69
475(i64_to_i): 31(int) SpecConstantOp 114 465(si64)
476(i_to_i64): 18(int64_t) SpecConstantOp 114 467(si)
477(u64_to_u): 21(int) SpecConstantOp 113 466(su64)
478(u_to_u64): 14(int64_t) SpecConstantOp 113 468(su)
479(u64_to_i64): 18(int64_t) SpecConstantOp 128 466(su64) 69
480(i64_to_u64): 14(int64_t) SpecConstantOp 128 465(si64) 69
481: 21(int) SpecConstantOp 113 466(su64)
482(u64_to_i): 31(int) SpecConstantOp 128 481 227
483: 18(int64_t) SpecConstantOp 114 467(si)
484(i_to_u64): 14(int64_t) SpecConstantOp 128 483 69
485: 31(int) SpecConstantOp 114 465(si64)
486(i64_to_u): 21(int) SpecConstantOp 128 485 227
487: 14(int64_t) SpecConstantOp 113 468(su)
488(u_to_i64): 18(int64_t) SpecConstantOp 128 487 69
4(main): 2 Function None 3
5: Label
Store 16(u64Max) 17
......
......@@ -236,6 +236,7 @@ layout(constant_id = 101) const uint64_t su64 = 20UL;
layout(constant_id = 102) const int si = -5;
layout(constant_id = 103) const uint su = 4;
layout(constant_id = 104) const bool sb = true;
layout(constant_id = 105) const uint64_t su64inc = su64 + 1UL;
// bool <-> int64/uint64
const bool i64_to_b = bool(si64);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment