fix: keep wave64 ds_bpermute within each 32-lane half #334

Open
github-bot wants to merge 1 commit from github-bot/gh-334 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 04:02 UTC · original
mauroalvare:codex/victory-bpermute-half → main · +61 −77 · 3 files · 1 commits · open

Change

Neptune treated ds_bpermute_b32 as a whole-wave read. On a 32-lane host, its paired lowering could fetch the matching lane of the other simulated half. The compute pipeline built by tools/lancer_victory.ps1 reaches this lowering through victory_shader::emit::translate.

Use address bits 6:2 as the index within the current 32-lane half. On a native wave64 host, add the caller's half base. On a wave32 host, each paired half uses the same half-local lowering, and the normal split path can handle this instruction without an inter-half exchange. This adapts the native half-mask change from VIctory #573 to Neptune's ordinary and paired forms.

Verification

Base c4c93bdc413191a9dc909998d2d53080a3f0c880, fix ecbb041708703a72413263b5249a260b0c90e394.

From third_party/victory on Windows:

$env:VICTORY_DXIL = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll'
Remove-Item Env:VICTORY_WARP -ErrorAction SilentlyContinue
cargo test --locked --offline -j 2 -p victory-shader --lib bpermute_wave64_stays_in_each_half -- --nocapture --test-threads=1
  • On the base with the test added, the RTX 5070 Ti accepted the pipeline. The first runtime-selected dispatch gave lane 32 0x1 instead of the interpreter's 0x21. The test failed at readback.
  • With the fix, SDK validator 1.8.2502.11 accepted both the runtime-selected and paired DXIL. Both pipelines ran on the RTX 5070 Ti (driver 621.40). For each of three addresses, all 64 reads matched the reference in both forms. Lanes 0 and 32 read (1, 33), (31, 63), and (0, 32) respectively, including the address wrap after adding the instruction's byte offset.
  • Forcing WARP with VICTORY_WARP=1 validated both DXIL containers, then skipped execution when the Microsoft Basic Render Driver rejected the WaveSize(32) compute pipeline.
Command Result
cargo test --locked --offline -j 2 -p victory-shader --lib paired_lanes_permute_shift_and_write_lanes_of_both_halves -- --nocapture --test-threads=1 1 passed on RTX hardware
cargo test --locked --offline -j 2 -p victory-shader -- --nocapture --test-threads=1 243 passed, 0 failed, 2 ignored
cargo test --locked --offline -j 2 -p victory-loader --test load_probe 2 passed, 0 failed
cargo check --locked --offline -j 2 -p victory Finished successfully
cargo xtask policy 201 files OK
cargo build --release --locked --offline -j 2 --manifest-path rust/Cargo.toml Finished successfully
cargo test --release --locked --offline -j 2 --manifest-path rust/Cargo.toml 12 passed, 0 failed
python -m pytest -rs 1665 passed in 74.59s
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools All checks passed

The full shader run also reported four optional compiler-dependent skips, one WARP pipeline skip, and one hardware wave case whose pipeline the device did not accept. The targeted RTX regression ran both forms without skips. Pytest used Python 3.13.15, ANYXBOXX_REQUIRE_RUNTIME=1, and the existing native runtime and TomBox binaries.

Oracle and test data

The synthetic compute shader has 64 active console lanes. Each lane contributes its lane index as data, reads with ds_bpermute_b32 at a byte address plus offset 4, and stores the result to a raw UAV. The in-tree Python interpreter ran the same instruction and addresses independently. The half-wave indexing and wrap rule is specified in section 10.4.4 of the AMD RDNA 2 ISA guide.

Checklist

  • One focused behavior change with a synthetic regression.
  • The readback regression fails on the base and passes with the fix.
  • Commands, adapters, results, and skips are recorded above.
  • Pytest verifies the README language copies.
  • Inputs were built from repository fixtures.
  • The GPL-compatible source is credited in THIRD_PARTY.md and the commit.

AI assistance by Codex for the port, regression, and Windows validation.

**@⁠mauroalvare** on GitHub · 2026-11-26 04:02 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/334) `mauroalvare:codex/victory-bpermute-half` → `main` · +61 −77 · 3 files · 1 commits · open ## Change Neptune treated `ds_bpermute_b32` as a whole-wave read. On a 32-lane host, its paired lowering could fetch the matching lane of the other simulated half. The compute pipeline built by `tools/lancer_victory.ps1` reaches this lowering through `victory_shader::emit::translate`. Use address bits 6:2 as the index within the current 32-lane half. On a native wave64 host, add the caller's half base. On a wave32 host, each paired half uses the same half-local lowering, and the normal split path can handle this instruction without an inter-half exchange. This adapts the native half-mask change from [VIctory #573](https://github.com/Marvisak/VIctory/pull/573) to Neptune's ordinary and paired forms. ## Verification Base `c4c93bdc413191a9dc909998d2d53080a3f0c880`, fix `ecbb041708703a72413263b5249a260b0c90e394`. From `third_party/victory` on Windows: ```powershell $env:VICTORY_DXIL = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll' Remove-Item Env:VICTORY_WARP -ErrorAction SilentlyContinue cargo test --locked --offline -j 2 -p victory-shader --lib bpermute_wave64_stays_in_each_half -- --nocapture --test-threads=1 ``` - On the base with the test added, the RTX 5070 Ti accepted the pipeline. The first runtime-selected dispatch gave lane 32 `0x1` instead of the interpreter's `0x21`. The test failed at readback. - With the fix, SDK validator 1.8.2502.11 accepted both the runtime-selected and paired DXIL. Both pipelines ran on the RTX 5070 Ti (driver 621.40). For each of three addresses, all 64 reads matched the reference in both forms. Lanes 0 and 32 read `(1, 33)`, `(31, 63)`, and `(0, 32)` respectively, including the address wrap after adding the instruction's byte offset. - Forcing WARP with `VICTORY_WARP=1` validated both DXIL containers, then skipped execution when the Microsoft Basic Render Driver rejected the `WaveSize(32)` compute pipeline. | Command | Result | | --- | --- | | `cargo test --locked --offline -j 2 -p victory-shader --lib paired_lanes_permute_shift_and_write_lanes_of_both_halves -- --nocapture --test-threads=1` | 1 passed on RTX hardware | | `cargo test --locked --offline -j 2 -p victory-shader -- --nocapture --test-threads=1` | 243 passed, 0 failed, 2 ignored | | `cargo test --locked --offline -j 2 -p victory-loader --test load_probe` | 2 passed, 0 failed | | `cargo check --locked --offline -j 2 -p victory` | Finished successfully | | `cargo xtask policy` | 201 files OK | | `cargo build --release --locked --offline -j 2 --manifest-path rust/Cargo.toml` | Finished successfully | | `cargo test --release --locked --offline -j 2 --manifest-path rust/Cargo.toml` | 12 passed, 0 failed | | `python -m pytest -rs` | 1665 passed in 74.59s | | `python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools` | All checks passed | The full shader run also reported four optional compiler-dependent skips, one WARP pipeline skip, and one hardware wave case whose pipeline the device did not accept. The targeted RTX regression ran both forms without skips. Pytest used Python 3.13.15, `ANYXBOXX_REQUIRE_RUNTIME=1`, and the existing native runtime and TomBox binaries. ## Oracle and test data The synthetic compute shader has 64 active console lanes. Each lane contributes its lane index as data, reads with `ds_bpermute_b32` at a byte address plus offset 4, and stores the result to a raw UAV. The in-tree Python interpreter ran the same instruction and addresses independently. The half-wave indexing and wrap rule is specified in section 10.4.4 of the [AMD RDNA 2 ISA guide](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content). ## Checklist - [x] One focused behavior change with a synthetic regression. - [x] The readback regression fails on the base and passes with the fix. - [x] Commands, adapters, results, and skips are recorded above. - [x] Pytest verifies the README language copies. - [x] Inputs were built from repository fixtures. - [x] The GPL-compatible source is credited in `THIRD_PARTY.md` and the commit. AI assistance by Codex for the port, regression, and Windows validation.
Select ds_bpermute_b32 sources within the caller's 32-lane half.
Anchor native wave64 reads to their host half and use the same
half-local lowering for each lane of a paired thread. Allow shaders
with half-local permutations to take the exact split wave32 form.

Compare all 64 lanes of both the runtime-selected and paired shaders
against the half-wave rule on a wave32 device.

Source: Marvisak/VIctory #573 (92a23a06a7e422157d902904c41cfcb05158ba29)
Co-authored-by: QB <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:43:25 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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