fix: zero masked sources of DS swizzles in VIctory #284

Open
github-bot wants to merge 4 commits from github-bot/gh-284 into main AGit
Owner

@⁠Tiimonprog on GitHub · 2026-11-26 00:44 UTC · original
Tiimonprog:fix/victory-guarded-swizzle → main · +335 −1 · 5 files · 4 commits · open

Change

VIctory’s DS swizzle lowering passes a masked source value to the cross-lane read. Select zero for an EXEC-masked source before the read, as the existing bpermute lowering already does.

The new synthetic wave64 regression activates only even lanes. A quad reversal reads inactive odd lanes, while a swap-16 reads active even lanes. Inactive destinations retain their sentinel. Before the fix, RTX 4060 Laptop returned 4 at thread 0, dword 1 instead of 0. After the fix, all 256 output dwords match the expected values.

Verification

Run from third_party/victory, Rust 1.98.1 MSVC, Windows 11, NVIDIA RTX 4060 Laptop (driver 32.0.16.2124):

cargo test --locked -p victory-shader guarded_swizzles -- --nocapture
→ 1 passed; 0 failed (GPU dispatch executed)
cargo test --locked -p victory-shader -- --test-threads=1
→ 243 passed; 0 failed; 2 ignored
cargo build --locked --profile diag -p victory --features diagnostics
→ Finished diag profile (two existing victory-gpu warnings)

Intel UHD and WARP were also probed using a temporary local adapter-selection change, excluded from this PR. Both refused this 32-lane program at pipeline creation, so the regression did not execute there. The test uses the existing helper that returns early on unsupported hardware. The full test run above used the unchanged host helper.

Oracle and test data

The test encodes its own small RDNA program and checks 64 lanes × 4 dwords against explicit expected values, including zero from inactive sources, live source values and preserved inactive destinations. No game inputs were used. In-game graphics and performance effects have not been measured.

Created with OpenAI Codex assistance.

**@⁠Tiimonprog** on GitHub · 2026-11-26 00:44 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/284) `Tiimonprog:fix/victory-guarded-swizzle` → `main` · +335 −1 · 5 files · 4 commits · open ## Change VIctory’s DS swizzle lowering passes a masked source value to the cross-lane read. Select zero for an EXEC-masked source before the read, as the existing bpermute lowering already does. The new synthetic wave64 regression activates only even lanes. A quad reversal reads inactive odd lanes, while a swap-16 reads active even lanes. Inactive destinations retain their sentinel. Before the fix, RTX 4060 Laptop returned 4 at thread 0, dword 1 instead of 0. After the fix, all 256 output dwords match the expected values. ## Verification Run from `third_party/victory`, Rust 1.98.1 MSVC, Windows 11, NVIDIA RTX 4060 Laptop (driver 32.0.16.2124): ``` cargo test --locked -p victory-shader guarded_swizzles -- --nocapture → 1 passed; 0 failed (GPU dispatch executed) cargo test --locked -p victory-shader -- --test-threads=1 → 243 passed; 0 failed; 2 ignored cargo build --locked --profile diag -p victory --features diagnostics → Finished diag profile (two existing victory-gpu warnings) ``` Intel UHD and WARP were also probed using a temporary local adapter-selection change, excluded from this PR. Both refused this 32-lane program at pipeline creation, so the regression did not execute there. The test uses the existing helper that returns early on unsupported hardware. The full test run above used the unchanged host helper. ## Oracle and test data The test encodes its own small RDNA program and checks 64 lanes × 4 dwords against explicit expected values, including zero from inactive sources, live source values and preserved inactive destinations. No game inputs were used. In-game graphics and performance effects have not been measured. Created with OpenAI Codex assistance.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:41:58 +00:00
Author
Owner

@⁠Tiimonprog on GitHub · 2026-11-26 00:48 UTC · original

Added c8b9fff, an opt-in deterministic GPU sweep with 256 generated wave64 programs. Each performs an in-place QUAD_PERM, changes EXEC, then performs a BITMASK_PERM. The set covers all 256 quad selectors and varying sparse, empty and full masks. It compares 32,768 output dwords against an independent CPU calculation.

Run from third_party/victory:

cargo test --locked -p victory-shader generated_swizzle_sweep -- --ignored --nocapture

Measured on RTX 4060 Laptop, driver 32.0.16.2124: 256 cases passed (5.83 s in one run). nvidia-smi also confirmed the test process on the NVIDIA adapter. To replay one case, set SWIZZLE_CASE=0 (valid range 0–255). The sweep requires a GPU accepting these 32-lane shaders and fails explicitly if device or pipeline creation fails. It is opt-in because ordinary CI may lack that hardware.

With the lowering restored to the pre-fix version, case 0 fails at lane 8: [9, 31], expected [9, 0]. With the fix, all cases pass, including replay of case 0. No additional mismatch was found in this set. The earlier full-suite result in the description predates this added opt-in test.

AI assistance: OpenAI Codex.

**@⁠Tiimonprog** on GitHub · 2026-11-26 00:48 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/284#issuecomment-7179138865) Added `c8b9fff`, an opt-in deterministic GPU sweep with 256 generated wave64 programs. Each performs an in-place QUAD_PERM, changes EXEC, then performs a BITMASK_PERM. The set covers all 256 quad selectors and varying sparse, empty and full masks. It compares 32,768 output dwords against an independent CPU calculation. Run from `third_party/victory`: ``` cargo test --locked -p victory-shader generated_swizzle_sweep -- --ignored --nocapture ``` Measured on RTX 4060 Laptop, driver 32.0.16.2124: 256 cases passed (5.83 s in one run). `nvidia-smi` also confirmed the test process on the NVIDIA adapter. To replay one case, set `SWIZZLE_CASE=0` (valid range 0–255). The sweep requires a GPU accepting these 32-lane shaders and fails explicitly if device or pipeline creation fails. It is opt-in because ordinary CI may lack that hardware. With the lowering restored to the pre-fix version, case 0 fails at lane 8: `[9, 31]`, expected `[9, 0]`. With the fix, all cases pass, including replay of case 0. No additional mismatch was found in this set. The earlier full-suite result in the description predates this added opt-in test. AI assistance: OpenAI Codex.
Author
Owner

@⁠Tiimonprog on GitHub · 2026-11-26 01:03 UTC · original

Added two commits, 13f1bf9 and 8dcc8d6, extending validation of this fix.

The divergent-loop sweep covers 260 dispatch cases across four partner mappings (XOR 1, 16, 32 and 63), including empty/full entry masks and per-lane exits after 1–8 rounds. It checks values, iteration counts, reads inside the loop and reads after reconvergence against a CPU calculation. WAVE64_LOOP_CASE=131 replays one case (valid range 0–259).

Both generated sweeps now pass synthetic DXBC/XDAT/XBCH/FSSM containers through the public translate() entry point, including native parsing, spill handling and automatic translation-form selection for a 32-lane host. The loop sweep also dispatches the explicit paired form if its result differs. A new GPU-independent round-trip test checks the code, stage settings and root bindings of the synthetic container.

Measured on Windows, RTX 4060 Laptop, driver 32.0.16.2124, Rust 1.98.1 MSVC:

cargo test --locked -p victory-shader generated_ -- --ignored --test-threads=1
2 passed; 516 selected-path dispatch cases; 99,328 output dwords matched the CPU oracle

cargo test --locked -p victory-shader -- --test-threads=1
244 passed; 0 failed; 4 ignored

cargo xtask policy
asset policy: 201 files ok

Negative controls were local and restored afterward. Removing the paired bpermute source guard makes loop case 131 fail (lane 0 reads 34 instead of 33). Restoring the swizzle lowering to its pre-fix version makes public-path swizzle case 0 fail at lane 8 ([9, 31] instead of [9, 0]). Both generated sweeps pass with the original bpermute guard and this PR’s swizzle fix restored. No additional mismatch was found in these cases. In-game effects remain unmeasured.

Created with OpenAI Codex assistance.

**@⁠Tiimonprog** on GitHub · 2026-11-26 01:03 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/284#issuecomment-7179381952) Added two commits, 13f1bf9 and 8dcc8d6, extending validation of this fix. The divergent-loop sweep covers 260 dispatch cases across four partner mappings (XOR 1, 16, 32 and 63), including empty/full entry masks and per-lane exits after 1–8 rounds. It checks values, iteration counts, reads inside the loop and reads after reconvergence against a CPU calculation. WAVE64_LOOP_CASE=131 replays one case (valid range 0–259). Both generated sweeps now pass synthetic DXBC/XDAT/XBCH/FSSM containers through the public translate() entry point, including native parsing, spill handling and automatic translation-form selection for a 32-lane host. The loop sweep also dispatches the explicit paired form if its result differs. A new GPU-independent round-trip test checks the code, stage settings and root bindings of the synthetic container. Measured on Windows, RTX 4060 Laptop, driver 32.0.16.2124, Rust 1.98.1 MSVC: ```text cargo test --locked -p victory-shader generated_ -- --ignored --test-threads=1 2 passed; 516 selected-path dispatch cases; 99,328 output dwords matched the CPU oracle cargo test --locked -p victory-shader -- --test-threads=1 244 passed; 0 failed; 4 ignored cargo xtask policy asset policy: 201 files ok ``` Negative controls were local and restored afterward. Removing the paired bpermute source guard makes loop case 131 fail (lane 0 reads 34 instead of 33). Restoring the swizzle lowering to its pre-fix version makes public-path swizzle case 0 fail at lane 8 ([9, 31] instead of [9, 0]). Both generated sweeps pass with the original bpermute guard and this PR’s swizzle fix restored. No additional mismatch was found in these cases. In-game effects remain unmeasured. Created with OpenAI Codex assistance.
This pull request has changes conflicting with the target branch.
  • third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/284/head:github-bot/gh-284'
git switch 'github-bot/gh-284'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-284'
git switch 'github-bot/gh-284'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-284'
git switch 'github-bot/gh-284'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-284'
git switch 'main'
git merge --squash 'github-bot/gh-284'
git switch 'main'
git merge --ff-only 'github-bot/gh-284'
git switch 'main'
git merge 'github-bot/gh-284'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.