fix(victory-shader): handle console_lanes and inactive EXEC for v_permlane16/x16 #440

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

@⁠mauroalvare on GitHub · 2026-11-26 18:49 UTC · original
mauroalvare:fix/victory-permlane16-inactive-exec → main · +206 −36 · 3 files · 2 commits · closed without merging

Change

In VIctory's RDNA2-to-DXIL translator (third_party/victory/crates/victory-shader/src/emit/lower.rs), v_permlane16_b32 and v_permlanex16_b32 had two bugs:

  1. console_lanes detection missed v_permlane*: the compute prologue checked n.contains("permute"), which does not match "v_permlane16_b32" or "v_permlanex16_b32". A compute shader using v_permlane16_b32 / v_permlanex16_b32 without another cross-lane op panicked on debug_assert!(self.s.threads.is_none() || self.console_lanes) in debug builds and silently omitted WaveSize and console-lane thread-ID relabelling in release builds.
  2. Inactive source lanes (EXEC), fi (op_sel[0]), and bound_ctrl (op_sel[1]) were ignored: v_permlane16_b32 / v_permlanex16_b32 always passed the raw waveReadLaneAt result directly to int(self, r). Under AMD RDNA 2 ISA semantics, unless fi:1 is set, reading an inactive source lane (EXEC == 0) must supply 0 when bound_ctrl:1 or preserve vdst when bound_ctrl:0. This silently corrupted results in guarded wave32, divergent-branch wave32, and paired wave64 compute shaders on NVIDIA 32-lane hosts.

Fix:

  • Include n.starts_with("v_permlane") in console_lanes.
  • In "v_permlane16_b32" | "v_permlanex16_b32", check v.opsel bits 0 (fi) and 1 (bound_ctrl); when !fi, check source-lane activity via waveActiveBallot(guard.unwrap_or(true)) and either substitute 0 (bound_ctrl:1) or gate the destination write (bound_ctrl:0).

Linked issue: none

Verification

Base SHA: c3cc02932fc596ee9d937e5743f73007c538365a (LooperSalty/AnyXboxX:main)
Hardware: Windows 11, Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver 621.40), dxil.dll 10.0.26100.0, Rust 1.98.1 (MSVC).

Before the fix (failing on base c3cc029 on RTX 5070 Ti):

cargo test --locked -p victory-shader permlane16_and_x16_honor_inactive -- --test-threads=1 --nocapture
-> FAILED (base): panicked at crates\victory-shader\src\emit\lower.rs:4261:9: assertion failed: self.s.threads.is_none() || self.console_lanes
-> FAILED (with console_lanes fix alone): thread 0, dword 0: 0xb, the console's 0xaaaa

After the fix (from third_party/victory):

cargo test --locked -p victory-shader permlane16_and_x16_honor_inactive -- --test-threads=1 --nocapture
-> ran on the hardware device: v_permlane16 and v_permlanex16 honored EXEC, fi, and bound_ctrl in wave32 and paired wave64
-> test result: ok. 1 passed; 0 failed; 0 ignored
cargo test --locked -p victory-shader -- --test-threads=1
-> test result: ok. 258 passed; 0 failed; 2 ignored
cargo xtask policy
-> asset policy: 215 files ok

Oracle and test data

The new regression test permlane16_and_x16_honor_inactive_source_lanes_fi_and_bound_ctrl in third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs synthesizes six minimal GFX10 compute shaders (v_permlane16_b32 and v_permlanex16_b32 across guarded wave32, divergent-branch wave32, and paired wave64 on a 32-lane host) with EXEC narrowed to even lanes, testing fi:0 bound_ctrl:0, fi:0 bound_ctrl:1, fi:1 bound_ctrl:0, and active source reads without any other cross-lane instructions (also exercising console_lanes). All shaders are validated with dxil.dll and verified dword-for-dword on RTX 5070 Ti against AMD RDNA 2 ISA semantics.

No game, console, or SDK files were used.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: unchanged (not applicable).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none (synthetic tests only).
  • Code taken from another project: none.

AI assistance: investigated, implemented, tested on RTX 5070 Ti, and drafted with Antigravity (Gemini).

**@⁠mauroalvare** on GitHub · 2026-11-26 18:49 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/440) `mauroalvare:fix/victory-permlane16-inactive-exec` → `main` · +206 −36 · 3 files · 2 commits · closed without merging ## Change In VIctory's RDNA2-to-DXIL translator (`third_party/victory/crates/victory-shader/src/emit/lower.rs`), `v_permlane16_b32` and `v_permlanex16_b32` had two bugs: 1. **`console_lanes` detection missed `v_permlane*`**: the compute prologue checked `n.contains("permute")`, which does not match `"v_permlane16_b32"` or `"v_permlanex16_b32"`. A compute shader using `v_permlane16_b32` / `v_permlanex16_b32` without another cross-lane op panicked on `debug_assert!(self.s.threads.is_none() || self.console_lanes)` in debug builds and silently omitted `WaveSize` and console-lane thread-ID relabelling in release builds. 2. **Inactive source lanes (`EXEC`), `fi` (`op_sel[0]`), and `bound_ctrl` (`op_sel[1]`) were ignored**: `v_permlane16_b32` / `v_permlanex16_b32` always passed the raw `waveReadLaneAt` result directly to `int(self, r)`. Under AMD RDNA 2 ISA semantics, unless `fi:1` is set, reading an inactive source lane (`EXEC == 0`) must supply `0` when `bound_ctrl:1` or preserve `vdst` when `bound_ctrl:0`. This silently corrupted results in guarded wave32, divergent-branch wave32, and paired wave64 compute shaders on NVIDIA 32-lane hosts. Fix: - Include `n.starts_with("v_permlane")` in `console_lanes`. - In `"v_permlane16_b32" | "v_permlanex16_b32"`, check `v.opsel` bits 0 (`fi`) and 1 (`bound_ctrl`); when `!fi`, check source-lane activity via `waveActiveBallot(guard.unwrap_or(true))` and either substitute `0` (`bound_ctrl:1`) or gate the destination write (`bound_ctrl:0`). Linked issue: none ## Verification Base SHA: `c3cc02932fc596ee9d937e5743f73007c538365a` (`LooperSalty/AnyXboxX:main`) Hardware: Windows 11, Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver `621.40`), `dxil.dll` `10.0.26100.0`, Rust `1.98.1` (MSVC). Before the fix (failing on base `c3cc029` on RTX 5070 Ti): ``` cargo test --locked -p victory-shader permlane16_and_x16_honor_inactive -- --test-threads=1 --nocapture -> FAILED (base): panicked at crates\victory-shader\src\emit\lower.rs:4261:9: assertion failed: self.s.threads.is_none() || self.console_lanes -> FAILED (with console_lanes fix alone): thread 0, dword 0: 0xb, the console's 0xaaaa ``` After the fix (from `third_party/victory`): ``` cargo test --locked -p victory-shader permlane16_and_x16_honor_inactive -- --test-threads=1 --nocapture -> ran on the hardware device: v_permlane16 and v_permlanex16 honored EXEC, fi, and bound_ctrl in wave32 and paired wave64 -> test result: ok. 1 passed; 0 failed; 0 ignored cargo test --locked -p victory-shader -- --test-threads=1 -> test result: ok. 258 passed; 0 failed; 2 ignored cargo xtask policy -> asset policy: 215 files ok ``` ## Oracle and test data The new regression test `permlane16_and_x16_honor_inactive_source_lanes_fi_and_bound_ctrl` in `third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs` synthesizes six minimal GFX10 compute shaders (`v_permlane16_b32` and `v_permlanex16_b32` across guarded wave32, divergent-branch wave32, and paired wave64 on a 32-lane host) with `EXEC` narrowed to even lanes, testing `fi:0 bound_ctrl:0`, `fi:0 bound_ctrl:1`, `fi:1 bound_ctrl:0`, and active source reads without any other cross-lane instructions (also exercising `console_lanes`). All shaders are validated with `dxil.dll` and verified dword-for-dword on RTX 5070 Ti against AMD RDNA 2 ISA semantics. No game, console, or SDK files were used. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: unchanged (not applicable). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none (synthetic tests only). - [x] Code taken from another project: none. *AI assistance: investigated, implemented, tested on RTX 5070 Ti, and drafted with Antigravity (Gemini).*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:56:37 +00:00
github-bot closed this pull request 2026-11-27 00:35:49 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 23:08 UTC · original

Closing after #454 moved third_party/victory to the Vice-Tay base (TaynanGT/Vice-Tay a252348).

Vice-Tay's translator already implements the console lanes, EXEC, fi and bound_ctrl handling for v_permlane16/x16 (victory-shader/src/emit/lower.rs). The regression test alone would still be welcome as a new PR.

Thanks for the work. If you measure a gain on the new base, a new PR against main is welcome.

🤖 Closed by Claude Code on behalf of the maintainer

**@⁠LooperSalty** on GitHub · 2026-11-26 23:08 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/440#issuecomment-7205294265) Closing after #454 moved `third_party/victory` to the Vice-Tay base (TaynanGT/Vice-Tay a252348). Vice-Tay's translator already implements the console lanes, EXEC, `fi` and `bound_ctrl` handling for `v_permlane16`/`x16` (`victory-shader/src/emit/lower.rs`). The regression test alone would still be welcome as a new PR. Thanks for the work. If you measure a gain on the new base, a new PR against `main` is welcome. _🤖 Closed by [Claude Code](https://claude.com/claude-code) on behalf of the maintainer_

Pull request closed

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