Skip to content

[SPIR-V] EvaluateAttribute* on a 16-bit input emits invalid InterpolateAt* #9180

Backlog

Description

@inbelic

With -spirv -enable-16bit-types, calling EvaluateAttributeAtSample,EvaluateAttributeCentroid or EvaluateAttributeSnapped on a half pixel shader input fails to compile. DXC emits a GLSL.std.450 InterpolateAt* instruction with a half result type, and its own SPIR-V validation rejects
it. The same shaders compile to DXIL, and the 32-bit versions compile to SPIR-V.

Reproduction

repro.hlsl:

struct PSInput {
  float4 Pos : SV_Position;
  half V : ATTR0;
};

RWStructuredBuffer<half> Out : register(u0);

float4 main(PSInput I) : SV_Target {
  Out[0] = EvaluateAttributeAtSample(I.V, 1);
  return 0;
}
dxc -T ps_6_2 -enable-16bit-types -spirv repro.hlsl

Output:

fatal error: generated SPIR-V is invalid: GLSL.std.450 InterpolateAtSample: expected Result Type to be a 32-bit float scalar or vector type
  %25 = OpExtInst %half %1 InterpolateAtSample %in_var_ATTR0 %uint_1

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

Expected

The shader compiles to valid SPIR-V, as it does for DXIL. In GLSL.std.450, InterpolateAtCentroid, InterpolateAtSample and InterpolateAtOffset take only 32-bit float scalars or vectors. A 16-bit interpolant is valid only with SPV_AMD_gpu_shader_half_float, which DXC does not enable here. Possible fixes:

  • Interpolate at 32 bits and convert the result to half (OpFConvert).
  • Emit SPV_AMD_gpu_shader_half_float when it is available.
  • Report a clear front-end diagnostic instead of emitting invalid SPIR-V.

Related: #2500 (16-bit GLSL.std.450 instructions requiring
SPV_AMD_gpu_shader_half_float), which notes that the interpolation
instructions still need that extension.

Activity

  1. added
    bug
    spirv
    needs-triage
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triagespirv

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions