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

Closed
undeadhuman37 wants to merge 2 commits from upstream-pr/1074 into main
undeadhuman37 commented 2026-11-24 15:28:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by undeadhuman37 on 2026-11-24T15:28:32Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585323139 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1074). Originally posted by [undeadhuman37](https://github.com/undeadhuman37) on 2026-11-24T15:28:32Z. --- 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)
DenRakEiw commented 2026-11-24 16:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T15:32:49Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • cargo test -p victory-shader: 122 passed, 0 failed, 1 ignored (all hardware + WARP VALU/waterfall/diff tests green on RTX 5090 and WARP)
  • cargo clippy -p victory-shader --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean lane-mask spill tracking across VGPR lanes, verified on Blackwell hardware and WARP. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6042294398 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1074#pullrequestreview-6042294398). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T15:32:49Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP**: - `cargo test -p victory-shader`: **122 passed, 0 failed, 1 ignored** (all hardware + WARP VALU/waterfall/diff tests green on RTX 5090 and WARP) - `cargo clippy -p victory-shader --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean lane-mask spill tracking across VGPR lanes, verified on Blackwell hardware and WARP. Approving. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 16:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T15:37:33Z.

Review: COMMENTED


Draft noted — this carries the same emit/lower.rs ballot fallback as #1073 plus the structure.rs spilled() chain analysis (straight-line v_writelane_b32/v_readlane_b32 pairs with a constant lane, capped at 64 hops, phi/other writes end the search conservatively). The two tests cover both the scalar-join case and the spilled-mask case, and both run on macOS.

Same caveats as #1073, plus one specific to spilled(): the lane constant is decoded as Operand::Const(128..=192) (lane = c-128), which matches the console spill encoding, but a non-constant lane (v_readlane_b32 with a variable lane) returns None and the mask stays opaque — safe, but it means the optimization silently doesn't apply there; a test with a variable lane asserting the refusal (rather than the success path) would document that boundary. Also the 64-hop cap: a longer spill chain silently stops tracking; fine as a shortcut, worth a comment in the code.

Verified locally: test-merge with main clean; cargo test -p victory-shader --locked (macOS arm64, rustc 1.98.1) → 98 passed / 0 failed / 1 ignored.

<!-- greyfinch-sync:Marvisak/VIctory:review:6042384389 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1074#pullrequestreview-6042384389). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T15:37:33Z. **Review:** COMMENTED --- Draft noted — this carries the same `emit/lower.rs` ballot fallback as #1073 plus the `structure.rs` `spilled()` chain analysis (straight-line `v_writelane_b32`/`v_readlane_b32` pairs with a constant lane, capped at 64 hops, phi/other writes end the search conservatively). The two tests cover both the scalar-join case and the spilled-mask case, and both run on macOS. Same caveats as #1073, plus one specific to `spilled()`: the lane constant is decoded as `Operand::Const(128..=192)` (lane = c-128), which matches the console spill encoding, but a non-constant lane (`v_readlane_b32` with a variable lane) returns `None` and the mask stays opaque — safe, but it means the optimization silently doesn't apply there; a test with a variable lane asserting the refusal (rather than the success path) would document that boundary. Also the 64-hop cap: a longer spill chain silently stops tracking; fine as a shortcut, worth a comment in the code. Verified locally: test-merge with main clean; `cargo test -p victory-shader --locked` (macOS arm64, rustc 1.98.1) → **98 passed / 0 failed / 1 ignored**.
LooperSalty commented 2026-11-24 17:04:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LooperSalty on 2026-11-24T16:37:36Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137958929 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1074#issuecomment-7137958929). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-24T16:37:36Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:05:28 +00:00
Marvisak commented 2026-11-25 01:07:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:31:44Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148600029 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1074#issuecomment-7148600029). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:31:44Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1074
No description provided.