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

Closed
simbaui4life wants to merge 0 commits from upstream-pr/71 into main
simbaui4life commented 2026-11-27 16:14:36 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by simbaui4life on 2026-11-27T16:14:36Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5529741790 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/71). Originally posted by [simbaui4life](https://github.com/simbaui4life) on 2026-11-27T16:14:36Z. --- 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)
Dukestar69 commented 2026-11-27 16:31:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-27T16:31:14Z.

Review: APPROVED


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).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6091014308 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/71#pullrequestreview-6091014308). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-27T16:31:14Z. **Review:** APPROVED --- 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).

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
trustno1-coder/VIctory-NVIDIA!71
No description provided.