Add names for composite constants in SPIR-V

Consider the following code:

    layout(constant_id=0) const int Y = 1;
    layout(constant_id=1) const int Z = 2;
    layout(constant_id=3) const int X = Y + Z;

Previously, it would produce SPIR-V decorations like this:

    Decorate 21(Y) SpecId 1
    Decorate 22 SpecId 3
    Decorate 33(Z) SpecId 0

This seems inaccurate, since the spec constant `X` that is dependent on
the two others did not get a name in the SPIR-V decorations. This behavior
may potentially negatively affect shader introspection capabilities.

This change alters the behavior to always add a name, which results in the code
above producing the following decorations:

    Decorate 21(Y) SpecId 1
    Decorate 22(X) SpecId 3
    Decorate 33(Z) SpecId 0
This commit is contained in:
Grigory Dzhavadyan
2018-10-29 22:56:44 -07:00
committed by nicebyte
parent b2b3d81e9b
commit 4c9876b34c
8 changed files with 232 additions and 117 deletions

View File

@@ -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()