[Shaders] SV_SampleIndex causes shader error
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
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:
- 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

Additional context
Needed to deal with MSAA in #1403
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided shader using the project's shader compiler or reproduction setup. Trace how SV_SampleIndex stream variables are assigned to shader-stage inputs and outputs; done means the semantic is present only in the pixel shader input and stream structures and the shader compiles without the reported error.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100