fix(victory-shader): enforce inactive-lane EXEC rules for DPP16 and DPP8 #435

Open
mauroalvare wants to merge 6 commits from upstream-pr/435 into main
mauroalvare commented 2026-11-26 18:44:00 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T18:44:00Z.


Change

In VIctory's RDNA2-to-DXIL translator (third_party/victory/crates/victory-shader/src/emit/lower.rs), Lower::dpp ignored fi (fetch-inactive) and the source lane's EXEC activity for both DPP16 (Dpp::Row) and DPP8 (Dpp::Lanes), and passed out-of-bounds lane indices (e.g. 0xFFFF_FFFF on row_shr lane 0, or >= wave_size on row_shl lane 31) directly to waveReadLaneAt.

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 (DPP16), or
  • leave vdst unmodified when bound_ctrl:0 (DPP16 and DPP8 0xE9).

On 32-lane NVIDIA hosts this broke both guarded wave32 / divergent wave32 shaders and paired wave64 compute shaders (where every divergent branch is lowered wave-wide with EXEC as a per-lane guard, so all host lanes stay physically active and waveReadLaneAt silently read stale inactive-lane VGPRs).

Fix:

  • Clamp out-of-bounds row-shift source lanes to lane before waveReadLaneAt / quad_pick.
  • When !fi, check source-lane activity via waveActiveBallot(guard.unwrap_or(true)) (or quad_pick(guard) for mesh quads), covering both guarded blocks (including paired wave64) and divergent branches (guard == None).
  • Combine inside and src_active into valid: substitute 0 if bound_ctrl is set, or gate the destination write otherwise.

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 dpp16_and_dpp8_honor_inactive -- --test-threads=1 --nocapture
-> FAILED: thread 0, dword 0: 0xb, the console's 0xaaaa

After the fix (from third_party/victory):

cargo test --locked -p victory-shader dpp16_and_dpp8_honor_inactive -- --test-threads=1 --nocapture
-> ran on the hardware device: DPP16 and DPP8 honored EXEC, bound_ctrl, and fi in wave32 (guarded & branched) 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: 201 files ok

Oracle and test data

The new regression test dpp16_and_dpp8_honor_inactive_source_lanes_and_fi in third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs synthesizes three minimal GFX10 compute shaders (guarded wave32, divergent-branch wave32, and paired wave64 on a 32-lane host) with EXEC narrowed to even lanes, executing DPP16 quad_perm:[1,0,3,2] (bound_ctrl:0 fi:0, bound_ctrl:1 fi:0, bound_ctrl:0 fi:1), DPP8 dpp8:[1,0,3,2,5,4,7,6] (fi:0), and DPP16 quad_perm:[2,3,0,1] (reading an active even lane). All shaders are validated with dxil.dll and checked dword-for-dword on RTX 5070 Ti against AMD RDNA 2 ISA semantics (matching PrototypeScarlett/emu/rdna2_exec_ext.py).

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

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5515465282 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/435). Originally posted by [mauroalvare](https://github.com/mauroalvare) on 2026-11-26T18:44:00Z. --- ## Change In VIctory's RDNA2-to-DXIL translator (`third_party/victory/crates/victory-shader/src/emit/lower.rs`), `Lower::dpp` ignored `fi` (fetch-inactive) and the source lane's `EXEC` activity for both DPP16 (`Dpp::Row`) and DPP8 (`Dpp::Lanes`), and passed out-of-bounds lane indices (e.g. `0xFFFF_FFFF` on `row_shr` lane 0, or `>= wave_size` on `row_shl` lane 31) directly to `waveReadLaneAt`. 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` (DPP16), or - leave `vdst` unmodified when `bound_ctrl:0` (DPP16 and DPP8 `0xE9`). On 32-lane NVIDIA hosts this broke both guarded wave32 / divergent wave32 shaders and paired wave64 compute shaders (where every divergent branch is lowered wave-wide with `EXEC` as a per-lane guard, so all host lanes stay physically active and `waveReadLaneAt` silently read stale inactive-lane VGPRs). Fix: - Clamp out-of-bounds row-shift source lanes to `lane` before `waveReadLaneAt` / `quad_pick`. - When `!fi`, check source-lane activity via `waveActiveBallot(guard.unwrap_or(true))` (or `quad_pick(guard)` for mesh quads), covering both guarded blocks (including paired wave64) and divergent branches (`guard == None`). - Combine `inside` and `src_active` into `valid`: substitute `0` if `bound_ctrl` is set, or gate the destination write otherwise. 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 dpp16_and_dpp8_honor_inactive -- --test-threads=1 --nocapture -> FAILED: thread 0, dword 0: 0xb, the console's 0xaaaa ``` After the fix (from `third_party/victory`): ``` cargo test --locked -p victory-shader dpp16_and_dpp8_honor_inactive -- --test-threads=1 --nocapture -> ran on the hardware device: DPP16 and DPP8 honored EXEC, bound_ctrl, and fi in wave32 (guarded & branched) 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: 201 files ok ``` ## Oracle and test data The new regression test `dpp16_and_dpp8_honor_inactive_source_lanes_and_fi` in `third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs` synthesizes three minimal GFX10 compute shaders (guarded wave32, divergent-branch wave32, and paired wave64 on a 32-lane host) with `EXEC` narrowed to even lanes, executing DPP16 `quad_perm:[1,0,3,2]` (`bound_ctrl:0 fi:0`, `bound_ctrl:1 fi:0`, `bound_ctrl:0 fi:1`), DPP8 `dpp8:[1,0,3,2,5,4,7,6]` (`fi:0`), and DPP16 `quad_perm:[2,3,0,1]` (reading an active even lane). All shaders are validated with `dxil.dll` and checked dword-for-dword on RTX 5070 Ti against AMD RDNA 2 ISA semantics (matching `PrototypeScarlett/emu/rdna2_exec_ext.py`). 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).*
mauroalvare commented 2026-11-26 23:37:50 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T23:37:50Z.


The Vice-Tay port is up in 721c320. The DPP16 and DPP8 GPU regression passed for guarded and branched wave32 and for split wave64, covering inactive EXEC lanes, bound_ctrl, and fi. The asset-policy check passed too.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7205709406 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/435#issuecomment-7205709406). Originally posted by [mauroalvare](https://github.com/mauroalvare) on 2026-11-26T23:37:50Z. --- The Vice-Tay port is up in `721c320`. The DPP16 and DPP8 GPU regression passed for guarded and branched wave32 and for split wave64, covering inactive EXEC lanes, `bound_ctrl`, and `fi`. The asset-policy check passed too.
mauroalvare commented 2026-11-27 19:49:04 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T19:49:04Z.


Updated to ec3b7348 after #545. The DPP module now combines the instruction's EXEC guard with the partial-group mask already on main. I bumped TRANSLATOR_VERSION to 11. The split-wave row masks, DPP16/DPP8 inactive-source cases, and unlaunched-lane regression ran on the RTX 5070 Ti and passed. The VIctory asset policy also passed.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7226899715 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/435#issuecomment-7226899715). Originally posted by [mauroalvare](https://github.com/mauroalvare) on 2026-11-27T19:49:04Z. --- Updated to `ec3b7348` after #545. The DPP module now combines the instruction's EXEC guard with the partial-group mask already on main. I bumped `TRANSLATOR_VERSION` to `11`. The split-wave row masks, DPP16/DPP8 inactive-source cases, and unlaunched-lane regression ran on the RTX 5070 Ti and passed. The VIctory asset policy also passed.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/435:upstream-pr/435'
git switch 'upstream-pr/435'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/435'
git switch 'upstream-pr/435'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/435'
git switch 'upstream-pr/435'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/435'
git switch 'main'
git merge --squash 'upstream-pr/435'
git switch 'main'
git merge --ff-only 'upstream-pr/435'
git switch 'main'
git merge 'upstream-pr/435'
git push origin 'main'
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
LooperSalty/AnyXboxX!435
No description provided.