Kode/krafix

Error X3018: invalid subscript. [GLSL -> HLSL]

Closed this issue · 1 comments

Hey ;)
Got that error with matrices.
GLSL vertex shader code:

in ...
out ...
out mat3 someMatrix;

void main ()
{

    someMatrix = mat3(A, B, C); //where A, B and C is a vec3;
    ....
}

Generated HLSL:


uniform ....
uniform ....
....
static float3x3 someMatrix;
.....

struct SPIRV_Cross_Input
{
    ....
};

struct SPIRV_Cross_Output
{
    .....
    float3 someMatrix_0 : TEXCOORD1;
    float3 someMatrix_1 : TEXCOORD2;
    float3 someMatrix_2 : TEXCOORD3;
    .....
};

void vert_main()
{
    ....
    someMatrix = float3x3(float3(A), float3(B), float3(C));
    ....
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    ....
    stage_output.someMatrix = someMatrix;  //! error X3018: invalid subscript 'someMatrix'
    ....
    return stage_output;
}

Error:
error X3018: invalid subscript 'someMatrix'

So, output declarated as

    float3 someMatrix_0 : TEXCOORD1;
    float3 someMatrix_1 : TEXCOORD2;
    float3 someMatrix_2 : TEXCOORD3;

But in main function it trying to apply matrix as:
stage_output.someMatrix = someMatrix;

Totally fixed.