fix: zero masked sources of DS swizzles in VIctory #284
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/284"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by Tiimonprog on 2026-11-26T00:44:18Z.
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):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.
Imported from LooperSalty/AnyXboxX. Originally posted by Tiimonprog on 2026-11-26T00:48:50Z.
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:Measured on RTX 4060 Laptop, driver 32.0.16.2124: 256 cases passed (5.83 s in one run).
nvidia-smialso confirmed the test process on the NVIDIA adapter. To replay one case, setSWIZZLE_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.
Imported from LooperSalty/AnyXboxX. Originally posted by Tiimonprog on 2026-11-26T01:03:09Z.
Added two commits,
13f1bf9and8dcc8d6, 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:
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.
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T16:24:22Z.
The fix is still needed on the current base: in
third_party/victory/crates/victory-shader/src/emit/lower.rs(main), theds_swizzle_b32branch readsx = self.vgprs(inst, addr…)without zeroing EXEC-masked source lanes, while theds_bpermutepath selects 0 for them. Butthird_party/victoryis now the Vice-Tay base (#454), and the branch conflicts inwave64_tests.rs(two adjacent additions). Please rebase on main, keep both sides' tests, check that the generated loop/swizzle tests and thepub(crate) mod tests/wave64_uav_containerhelper innative.rsstill compile against the new base, and post the result ofcargo test -p victory-shader(GPU or WARP).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.