stride3d / stride3d/stride

[Shaders] SV_SampleIndex causes shader error

Open
#1,404 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.