Skip to content

[SPIR-V] Semantic index limits for system values are not enforced on -spirv path #8878

Description

Description

The SPIR-V backend does not enforce system-value semantic index limits, so -spirv silently accepts semantics that the DXIL path rejects. It's just a missing diagnostic rather than bad codegen; the index is discarded and the emitted module becomes the legal index-0 spelling.

Steps to Reproduce

// repro.hlsl
[shader("vertex")]
float4 main(uint vid : SV_VertexID) : SV_Position1 {
    return float4((float)vid, 0.0, 0.0, 1.0);
}
dxc -T vs_6_8 -E main repro.hlsl -Fo repro.dxo          # rejected
dxc -T vs_6_8 -E main -spirv repro.hlsl -Fo repro.spv   # accepted

Actual Behavior

DXIL path errors as expected:

error: SV_Position semantic index exceeds maximum (0).
Validation failed.

SPIR-V path exits 0 with no diagnostic and emits the index-0 builtin, so the
1 is silently dropped:

OpDecorate %gl_Position BuiltIn Position

Other SVs behave the same way (SV_VertexID1, SV_Depth1, SV_DispatchThreadID1, SV_PrimitiveID1, ...). The once exception is SV_Target, since its bound is checked in the frontend rather than backend.

Activity

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

    bugBug, regression, crashneeds-triageAwaiting triagespirvWork related to SPIR-V

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions