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

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