Shaders: s_min/s_max set SCC from the comparison; v_readlane/v_writelane lanes wrap (port of avatarmanz#404) #71

Closed
github-bot wants to merge 2 commits from github-bot/gh-71 into main AGit
Owner

@⁠simbaui4life on GitHub · 2026-11-27 16:14 UTC · original
fix/salu-minmax-scc-lane-masks → main · +64 −4 · 2 files · 2 commits · closed without merging

A port of avatarmanz/VIctory-7900XTX#404, review fix included. Two commits on d12eb1b.

Cause

  • s_min_{i,u}32 / s_max_{i,u}32 set SCC when S0 is chosen. The lowering gave no SCC of its own, so the generic D != 0 was used. An s_cselect or s_cbranch_scc after a min/max then took the wrong side whenever the two disagree, for example s_min_u32 s0, 5, 3: SCC 0 on the console, 1 here.
  • v_readlane_b32 / v_writelane_b32 take the lane from S1[4:0] (wave32) or S1[5:0] (wave64). A select past the wave read the wrong lane or wrote no lane here.
  • Spill tracker (review fix): unspill matched constant lanes before they were wrapped, so in wave32 lanes 36 and 4 were two slots. UwUCammie found this; their version is in jtrudeau1530/VIctory-7900XTX#38.

What this does

  • emit/lower.rs: min/max return the comparison as SCC, and readlane/writelane mask a console lane with wave - 1. Host lanes (MaskData::Host) are unchanged.
  • ir.rs: lane_wrapped_fields wraps constant lanes before ir::build and unspill see them.
  • No version bump: this fork's shader cache is keyed by the build.

Tested (RTX 4070 Ti, driver 621.01)

  • Base 288 passed; this branch 289 passed. The new IR test a_constant_lane_past_the_wave_is_its_lane_modulo_the_wave fails without the change.
  • Clippy -D warnings is clean.
  • With the oracle PR #70, the fuzzer's min/max-SCC and lane-select programs agree with the interpreter.

Not tested: in the game (no game data here).

No game data in the commits.

🤖 Generated with Claude Code

**@⁠simbaui4life** on GitHub · 2026-11-27 16:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/71) `fix/salu-minmax-scc-lane-masks` → `main` · +64 −4 · 2 files · 2 commits · closed without merging A port of avatarmanz/VIctory-7900XTX#404, review fix included. Two commits on `d12eb1b`. **Cause** - `s_min_{i,u}32` / `s_max_{i,u}32` set SCC when S0 is chosen. The lowering gave no SCC of its own, so the generic `D != 0` was used. An `s_cselect` or `s_cbranch_scc` after a min/max then took the wrong side whenever the two disagree, for example `s_min_u32 s0, 5, 3`: SCC 0 on the console, 1 here. - `v_readlane_b32` / `v_writelane_b32` take the lane from S1[4:0] (wave32) or S1[5:0] (wave64). A select past the wave read the wrong lane or wrote no lane here. - **Spill tracker (review fix):** `unspill` matched constant lanes before they were wrapped, so in wave32 lanes 36 and 4 were two slots. UwUCammie found this; their version is in jtrudeau1530/VIctory-7900XTX#38. **What this does** - `emit/lower.rs`: min/max return the comparison as SCC, and readlane/writelane mask a console lane with `wave - 1`. Host lanes (`MaskData::Host`) are unchanged. - `ir.rs`: `lane_wrapped_fields` wraps constant lanes before `ir::build` and `unspill` see them. - No version bump: this fork's shader cache is keyed by the build. **Tested** (RTX 4070 Ti, driver 621.01) - Base 288 passed; this branch 289 passed. The new IR test `a_constant_lane_past_the_wave_is_its_lane_modulo_the_wave` fails without the change. - Clippy `-D warnings` is clean. - With the oracle PR #70, the fuzzer's min/max-SCC and lane-select programs agree with the interpreter. **Not tested:** in the game (no game data here). No game data in the commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
s_min_{i,u}32 and s_max_{i,u}32 set SCC when S0 is chosen (S0 < S1 for min,
S0 > S1 for max). The lowering returned no SCC, so the generic D != 0 was
used: s_cselect or s_cbranch_scc after a min/max took the wrong side
whenever the result was nonzero but S1 was chosen (or zero with S0 chosen).
Marvisak/VIctory's lowering already does this.

v_readlane_b32 and v_writelane_b32 take the lane from S1[4:0] (wave32) or
S1[5:0] (wave64). A select past the wave read 0 or wrote no lane here; it
now wraps as on the console. Lanes that are host lanes (pixel/vertex
programs with a computed lane) are unchanged.

Both were found by differential testing of the translator against an
independent RDNA2 interpreter on the GPU.

Ported from avatarmanz/VIctory-7900XTX#404. No version bump here: the shader cache is keyed by the build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v_readlane_b32 / v_writelane_b32 with a constant lane: ir::build and unspill now see
the lane modulo the wave (S1[4:0] in wave32, S1[5:0] in wave64), so the spill tracker
takes lanes 36 and 4 of a wave32 program for the one slot they are on the console.
The lowering already wrapped the lane; unspill, which runs before it, did not.

Found by UwUCammie in the review of #404, and done the same way in
jtrudeau1530/VIctory-7900XTX#38. Test: ir::tests::
a_constant_lane_past_the_wave_is_its_lane_modulo_the_wave (wave32 aliases, wave64
does not; it fails without the change).

Ported from avatarmanz/VIctory-7900XTX#404.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 16:18:52 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-27 16:31 UTC · original · approved these changes

LGTM — verified on Windows (RTX 5090):

  • Setting SCC = Some(t) for s_min_*/s_max_* and masking v_readlane_b32/v_writelane_b32 lanes to wave - 1 (both in lower.rs and in ir.rs::lane_wrapped_fields before unspill) matches RDNA2 ISA semantics cleanly
  • cargo test -p victory-shader --lib ir:: (11/11, including a_constant_lane_past_the_wave_is_its_lane_modulo_the_wave) and emit::tests:: (21/21) passed
  • cargo clippy -p victory-shader --all-targets -- -D warnings passed with 0 warnings
  • cargo xtask policy passed (279 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-27 16:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/71#pullrequestreview-6091014308) · **approved these changes** LGTM — verified on Windows (RTX 5090): - Setting `SCC = Some(t)` for `s_min_*`/`s_max_*` and masking `v_readlane_b32`/`v_writelane_b32` lanes to `wave - 1` (both in `lower.rs` and in `ir.rs::lane_wrapped_fields` before `unspill`) matches RDNA2 ISA semantics cleanly - `cargo test -p victory-shader --lib ir::` (11/11, including `a_constant_lane_past_the_wave_is_its_lane_modulo_the_wave`) and `emit::tests::` (21/21) passed - `cargo clippy -p victory-shader --all-targets -- -D warnings` passed with 0 warnings - `cargo xtask policy` passed (`279 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot closed this pull request 2026-11-27 21:47:08 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.