KhronosGroup / SPIRV-Cross

SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.
Apache License 2.0
1.96k stars 549 forks source link

Feature request: Support for SM 6.8 SV_StartVertexLocation/SV_StartInstanceLocation in HLSL output #2348

Open Ravbug opened 3 days ago

Ravbug commented 3 days ago

In Shader Model 6.8, two new system values were added to HLSL to provide the functionality of gl_BaseVertex and gl_BaseInstance.

More information can be found here: https://microsoft.github.io/hlsl-specs/proposals/0015-extended-command-info.html

This means the cbuffer SPIRV-Cross currently generates to emulate the GLSL variables would no longer be necessary if targeting SM 6.8:

cbuffer SPIRV_Cross_VertexInfo    // can eliminate this
{
    int SPIRV_Cross_BaseVertex;
    int SPIRV_Cross_BaseInstance;
};

changing to this:

struct SPIRV_Cross_Input
{
    // ...
    uint SPIRV_Cross_BaseInstance: SV_StartInstanceLocation;
};

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
   gl_BaseInstanceARB = stage_input.SPIRV_Cross_BaseInstance;
    // ...
}