KhronosGroup / KhronosGroup/glslang

Missing flat decoration for integer members of nested structs in HLSL

Open
#2,972 1 comment 0 reactions 0 assignees View on GitHub
bug HLSL SPIR-V
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

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

```hlsl
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.

```hlsl
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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the two HLSL examples in the report and inspect the generated SPIR-V and SPIRV-Tools validation output. Trace how integer members of nested structs are lowered for vertex outputs; done means the nested integer member receives the required flat decoration without requiring an explicit nointerpolation qualifier, and the resulting shader validates and works correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.