Shaders: a lane mask spilled to a VGPR lane is still that mask #1074

Closed
github-bot wants to merge 2 commits from gh-pr/1074/head into gh-pr/1074/base
Owner

@⁠undeadhuman37 on GitHub · 2026-11-24 15:28 UTC · original
undeadhuman37:fix/mask-spill → main · +168 −4 · 3 files · 2 commits · closed without merging

The console compiler spills scalars, lane-mask pairs among them, with v_writelane_b32 into constant lanes of a VGPR and restores them with v_readlane_b32 of the same lane. The restored pair was an opaque mask, so selects, EXEC writes and joins that used it refused ("a select on an untracked mask", "an opaque lane mask", "a lane-mask join of an untracked mask").

structure now follows a constant-lane readlane back through a plain chain of writelanes to the scalar written to that lane, and gives the restored pair that scalar pair's mask. A chain with a phi or another write of the VGPR stays opaque (shortcut noted in code).

Stacked: this branch contains the commit of the lane-mask-join PR (shares its test helper), so it should merge after that one.

Measured offline over the shader corpus (26148 programs), against the first commit alone:

  • vertex/pixel programs emitted: 12250 -> 12269; compute: 1443 -> 1452
  • "a lane-mask join of an untracked mask": 20 -> 0
  • "an opaque lane mask": 29 -> 8
  • "a conditional export": 8 -> 0

Tests: a synthetic pixel program fails to lower before and lowers after. cargo clippy -p victory-shader --all-targets -- -D warnings is clean. Not run on a GPU, hence draft.

No game data. AI-assisted: written with Claude Code (Claude Sonnet 5.5).

🤖 Generated with Claude Code

**@⁠undeadhuman37** on GitHub · 2026-11-24 15:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1074) `undeadhuman37:fix/mask-spill` → `main` · +168 −4 · 3 files · 2 commits · closed without merging The console compiler spills scalars, lane-mask pairs among them, with `v_writelane_b32` into constant lanes of a VGPR and restores them with `v_readlane_b32` of the same lane. The restored pair was an opaque mask, so selects, EXEC writes and joins that used it refused ("a select on an untracked mask", "an opaque lane mask", "a lane-mask join of an untracked mask"). `structure` now follows a constant-lane readlane back through a plain chain of writelanes to the scalar written to that lane, and gives the restored pair that scalar pair's mask. A chain with a phi or another write of the VGPR stays opaque (shortcut noted in code). Stacked: this branch contains the commit of the lane-mask-join PR (shares its test helper), so it should merge after that one. Measured offline over the shader corpus (26148 programs), against the first commit alone: - vertex/pixel programs emitted: 12250 -> 12269; compute: 1443 -> 1452 - "a lane-mask join of an untracked mask": 20 -> 0 - "an opaque lane mask": 29 -> 8 - "a conditional export": 8 -> 0 Tests: a synthetic pixel program fails to lower before and lowers after. `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean. Not run on a GPU, hence draft. No game data. AI-assisted: written with Claude Code (Claude Sonnet 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A register can hold a compare result's high dword on one path and a loaded
number on another; the compiler only reads it where the number is live. The
join's mask side was "a lane mask read as data", which refused the program.
A pixel or vertex program now takes the mask's ballot as that incoming value
(counts and zero tests mean the same on any wave size). shortcut: the ballot
is the host wave's, so a join read some other way would differ from the console.

Offline corpus: "a lane mask read as data" 250 -> 212, vertex/pixel programs
emitted 12243 -> 12250; the other 31 move on to descriptor/scalar-memory
refusals. Synthetic wave64 pixel program fails before, lowers after.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The console compiler spills scalars, lane-mask pairs among them, with
v_writelane_b32 into constant lanes of a VGPR and restores them with
v_readlane_b32 of the same lane. The restored pair was an opaque mask, so
the selects, EXEC writes and joins that used it refused ("a select on an
untracked mask", "an opaque lane mask", "a lane-mask join of an untracked
mask"). structure now follows a constant-lane readlane back through a plain
chain of writelanes to the scalar written to that lane, and gives the
restored pair that scalar pair's mask. A chain with a phi or another write
of the VGPR stays opaque (shortcut noted in code).

Offline corpus, against fix/mask-phi-ballot (neither branch carries #585):
vertex/pixel programs emitted 12250 -> 12269, compute 1443 -> 1452,
"a lane-mask join of an untracked mask" 20 -> 0, "an opaque lane mask"
29 -> 8, "a conditional export" 8 -> 0. Synthetic pixel program fails
before, lowers after. Stacked on fix/mask-phi-ballot (shares its test helper).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:19:06 +00:00
github-bot closed this pull request 2026-11-26 04:19:06 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-24 16:37 UTC · original

From a tester working with Claude (AI-assisted); measured on my own machine (i7-13700KF, RTX 4070 Super). No game data involved.

We carry the same fix independently (this PR, #298 and our local commit all follow a v_readlane_b32 of a constant lane back to the v_writelane_b32 that wrote it), so I am not opening another PR. Our version resolves the restored pair inside structure.rs's mask lookup, using the same spill map the resource tracer already builds (spilled_sgprs), with a cycle guard for joins through the spill; one test (a_mask_spilled_to_a_vgpr_lane_is_the_mask_read_back, fails without it).

Measured offline over the translation corpus on an integration tree (with other open PRs merged), before/after this one change:

  • vertex/pixel emitted 13327 -> 13358, compute 2107 -> 2198, mesh 8373 -> 8420 (+169 programs)
  • refusals "a lane-mask join of an untracked mask" 167 -> 43
  • RaytracingResolve (standard_rdp variant) now emits and validates with dxil.dll

If useful, I can post the exact diff or test as a comment here.

**@⁠LooperSalty** on GitHub · 2026-11-24 16:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1074#issuecomment-7137958929) From a tester working with Claude (AI-assisted); measured on my own machine (i7-13700KF, RTX 4070 Super). No game data involved. We carry the same fix independently (this PR, #298 and our local commit all follow a `v_readlane_b32` of a constant lane back to the `v_writelane_b32` that wrote it), so I am not opening another PR. Our version resolves the restored pair inside `structure.rs`'s mask lookup, using the same spill map the resource tracer already builds (`spilled_sgprs`), with a cycle guard for joins through the spill; one test (`a_mask_spilled_to_a_vgpr_lane_is_the_mask_read_back`, fails without it). Measured offline over the translation corpus on an integration tree (with other open PRs merged), before/after this one change: - vertex/pixel emitted 13327 -> 13358, compute 2107 -> 2198, mesh 8373 -> 8420 (+169 programs) - refusals "a lane-mask join of an untracked mask" 167 -> 43 - RaytracingResolve (standard_rdp variant) now emits and validates with dxil.dll If useful, I can post the exact diff or test as a comment here.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:31 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Draft. A mask restored from a VGPR lane is that mask in main (structure.rs restored, with a test of the same name). Same as #298.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1074#issuecomment-7148600029) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Draft. A mask restored from a VGPR lane is that mask in main (structure.rs restored, with a test of the same name). Same as #298. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1074
No description provided.