Add names for composite constants in SPIR-V
authorGrigory Dzhavadyan <grigoryj@google.com>
Tue, 30 Oct 2018 05:56:44 +0000 (22:56 -0700)
committernicebyte <nicebyte@mailinator.com>
Fri, 2 Nov 2018 07:45:12 +0000 (00:45 -0700)
commit4c9876b34c6080b869f249ba12d6d626201d176e
treebb9aaedde004b7cd54e1ff50470759fb6463f7f4
parentb2b3d81e9bb0603f8b59e470aec3b3b513c10378
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
SPIRV/GlslangToSpv.cpp
Test/baseResults/spv.float16.frag.out
Test/baseResults/spv.float32.frag.out
Test/baseResults/spv.float64.frag.out
Test/baseResults/spv.int16.amd.frag.out
Test/baseResults/spv.int64.frag.out
Test/baseResults/spv.specConstantOperations.vert.out
Test/spv.int64.frag