stride icon indicating copy to clipboard operation
stride copied to clipboard

[Shaders] SV_SampleIndex causes shader error

Open tebjan opened this issue 2 years ago • 1 comments

Describe the bug The SV_SampleIndex semantic is only allowed as input to the pixel shader stage. If used, it gets created as vertex shader input and output which leads to an error of the HLSL compiler.

shader MyShader : VS_PS_Base
{
    stage stream uint SampleIndex : SV_SampleIndex;

    override stage void VSMain()
    {
        streams.ShadingPosition = mul(streams.Position, WorldViewProjection);
    }

    override stage void PSMain() 
    {
        streams.ColorTarget = streams.SampleIndex * 0.25;
    }
};

To Reproduce Steps to reproduce the behavior:

  1. Use the SV_SampleIndex semantic as a stream variable in the pixel shader.

Expected behavior The variable will only be added to the pixel shader input struct and the pixel shader stream struct.

Screenshots image

Additional context Needed to deal with MSAA in #1403

tebjan avatar Apr 13 '22 18:04 tebjan

I've noticed the same happens when using the SV_VertexID semantic, when it gets added as a semantic to the geometry shader input, the shader has an error. So to fix these issues, the streams compiler needs to understand what semantics are allowed in what shader stage.

tebjan avatar Jul 23 '22 20:07 tebjan