Skip to content

DXC can sink and duplicate SetMeshOutputCounts if the inputs are computed within a scalar branch #8104

Open

Description

Description
DXC can sink a call to SetMeshOutputCounts into a scalar branch if the branches are used to compute the number of vertices/indices. Anecdotally I have been able to fix it by wrapping the branch condition with WaveReadLaneFirst, despite the branch being scalar anyway.

Steps to Reproduce
See https://godbolt.org/z/oca77vqGh

Actual Behavior
DXC validation fails after SetMeshOutputCounts is duplicated in resulting DXIL:
<source>:32:5: error: SetMeshOUtputCounts cannot be called multiple times.

Environment

  • DXC version: DXC 1.8.2505 on compiler explorer
  • Host Operating System Observed on: windows and linux (via compiler explorer)

Activity

  1. damyanp commented on Feb 3, 2026

    @damyanp
    Member

    A possible workaround for this is to change the SetMeshOutputs call to:

        SetMeshOutputCounts(WaveReadLaneFirst(nverts), nprims);

    See https://godbolt.org/z/W4bh6dErW

  2. llvm-beanz commented on Apr 24, 2026

    @llvm-beanz
    Collaborator

    The correct fix here is that we should just annotate these operations with noduplicate.

  3. Copilot commented on Apr 24, 2026

    Copilot
    Contributor

    The agent encountered an error and was unable to start working on this issue: Please try again later, or contact support if the problem persists. (Request id: DC94:3F9BEF:447318F:5993951:69EBE042)

  4. damyanp commented on Apr 24, 2026

    @damyanp
    Member

    Chris B (@llvm-beanz) - can you have copilot work on this in your fork please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugBug, regression, crashcorrectnessBugs that impact shader correctness

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions