glslang icon indicating copy to clipboard operation
glslang copied to clipboard

Missing flat decoration for integer members of nested structs in HLSL

Open TheMostDiligent opened this issue 2 years ago • 1 comments

When compiling HLSL source, there is no need to add the nointerpolation qualifier for integer outputs of a vertex shader, for example:

struct VSOutput
{
    float4 Pos : SV_Position;
    uint SomeIndex : MyIndex; // nointerpolation is not required
};

The struct above compiles and works fine. However, if integer member is in a substruct, e.g.

struct SubStruct
{
    uint SomeIndex : MyIndex; // nointerpolation is required
};
struct VSOutput
{
    float4 Pos : SV_Position;
    SubStruct Substr;
};

then without the nointerpolation, the shader compiles, but SPIRV-Tools then produce the following error:

Spirv optimizer error: [VUID-StandaloneSpirv-Flat-04744] Fragment OpEntryPoint operand 2165 with Input interfaces with integer or float type must have a Flat decoration for Entry Point id 4.
  %In_VSOut_SomeIndex  = OpVariable %_ptr_Input_uint Input

The shader also does not work correctly. Adding the nointerpolation fixes the issues.

TheMostDiligent avatar Jul 08 '22 04:07 TheMostDiligent

Yes, glslang needs to add a Flat decoration for the second case.

greg-lunarg avatar Jul 08 '22 22:07 greg-lunarg