Shaders: fix ds_bpermute_b32 lane selection on Wave32 hosts #1019

Closed
invismann wants to merge 2 commits from upstream-pr/1019 into main
invismann commented 2026-11-28 11:14:17 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by invismann on 2026-11-28T11:14:17Z.


RDNA2 ds_bpermute_b32 gathers within the caller's 32-lane half and produces zero when the source lane is inactive. Treating it as a cross-half operation can reject a valid Wave64 shader on Wave32 hosts. Computing a source index across all 64 lanes can also read the wrong value.

Wrap the index within the caller's half, account for active source lanes, and allow this gather in independent host Wave32 halves.

Validation

  • The synthetic regression translates for both host wave widths and checks wrapped indices and inactive sources.
  • RTX 4090 GPU readbacks pass on Wave32 with both 64- and 128-thread groups.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5539537037 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1019). Originally posted by [invismann](https://github.com/invismann) on 2026-11-28T11:14:17Z. --- RDNA2 `ds_bpermute_b32` gathers within the caller's 32-lane half and produces zero when the source lane is inactive. Treating it as a cross-half operation can reject a valid Wave64 shader on Wave32 hosts. Computing a source index across all 64 lanes can also read the wrong value. Wrap the index within the caller's half, account for active source lanes, and allow this gather in independent host Wave32 halves. ## Validation - The synthetic regression translates for both host wave widths and checks wrapped indices and inactive sources. - RTX 4090 GPU readbacks pass on Wave32 with both 64- and 128-thread groups.
Dukestar69 commented 2026-11-28 11:44:01 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T11:44:01Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests (RTX 5090, Wave32 host):
    • cargo test -p victory-shader --lib emit::wave64_tests:: passed (14 passed; 0 failed, including the new backward_permute_wraps_within_its_half_and_zeros_inactive_sources GPU test).
    • cargo test -p victory-shader --lib emit::tests:: passed (22 passed; 0 failed; 1 ignored, including a_backward_permute_reads_the_lane_its_address_names).
  • Lint: cargo clippy -p victory-shader --lib -- -D warnings passed with 0 warnings.

Great NVIDIA/Wave32 correctness fix for ds_bpermute_b32 lane selection and inactive-source zeroing. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6097584379 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1019#pullrequestreview-6097584379). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T11:44:01Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests (RTX 5090, Wave32 host)**: - `cargo test -p victory-shader --lib emit::wave64_tests::` passed (`14 passed; 0 failed`, including the new `backward_permute_wraps_within_its_half_and_zeros_inactive_sources` GPU test). - `cargo test -p victory-shader --lib emit::tests::` passed (`22 passed; 0 failed; 1 ignored`, including `a_backward_permute_reads_the_lane_its_address_names`). - **Lint**: `cargo clippy -p victory-shader --lib -- -D warnings` passed with 0 warnings. Great NVIDIA/Wave32 correctness fix for `ds_bpermute_b32` lane selection and inactive-source zeroing. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Bj0rnis commented 2026-11-28 13:29:15 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Bj0rnis on 2026-11-28T13:29:15Z.


Independent RTX 5070 Ti 16 GB (Blackwell, Wave32 host) headless verification of 0f5e7e4 (Windows 11, Ryzen 7 9800X3D, 32 GB RAM, driver 621.24, Rust 1.98.1):

  • Clean merge-tree against main (63b902f).
  • cargo test --release --locked -p victory-shader --lib -- --test-threads=1: 294 passed, 0 failed, 5 ignored (245.04 s), including the new GPU readback regression emit::wave64_tests::backward_permute_wraps_within_its_half_and_zeros_inactive_sources (ok) and all other wave64_tests on Blackwell Wave32.
  • Wave32 shader corpus (victory.exe shaders, VICTORY_HOST_WAVE=32): 25,760 translated / 225 failed (92 s) — matches main (63b902f) with 0 regressions.
  • cargo xtask policy: 294 files ok; cargo build --release --locked -p victory succeeded cleanly.

Not tested: live gameplay workload. No game data, shader hashes, logs, or captures attached.

AI-assisted test run and summary.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7239969075 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1019#issuecomment-7239969075). Originally posted by [Bj0rnis](https://github.com/Bj0rnis) on 2026-11-28T13:29:15Z. --- Independent RTX 5070 Ti 16 GB (Blackwell, Wave32 host) headless verification of `0f5e7e4` (Windows 11, Ryzen 7 9800X3D, 32 GB RAM, driver `621.24`, Rust 1.98.1): - **Clean merge-tree** against `main` (`63b902f`). - **`cargo test --release --locked -p victory-shader --lib -- --test-threads=1`:** **294 passed, 0 failed, 5 ignored** (`245.04 s`), including the new GPU readback regression `emit::wave64_tests::backward_permute_wraps_within_its_half_and_zeros_inactive_sources` (`ok`) and all other `wave64_tests` on Blackwell Wave32. - **Wave32 shader corpus (`victory.exe shaders`, `VICTORY_HOST_WAVE=32`):** `25,760` translated / `225` failed (`92 s`) — matches `main` (`63b902f`) with 0 regressions. - **`cargo xtask policy`:** **294 files ok**; `cargo build --release --locked -p victory` succeeded cleanly. *Not tested:* live gameplay workload. No game data, shader hashes, logs, or captures attached. *AI-assisted test run and summary.*
Exopus-0x65f7ad0 commented 2026-11-28 13:39:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Exopus-0x65f7ad0 on 2026-11-28T13:39:49Z.


On a second NVIDIA architecture: RTX 5060 Ti 8 GB (Blackwell, 10de:2d04), Windows 11 26300, native D3D12. 63b902f + this PR.

cargo test --release --locked -p victory-shader --lib backward_permute_wraps_within_its_half_and_zeros_inactive_sources → passed.

The GPU readbacks you ran on the 4090 aren't in the PR, so I couldn't repeat those. If you push the readback test (even #[ignore]), I'll run it on this Blackwell card.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7240095938 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1019#issuecomment-7240095938). Originally posted by [Exopus-0x65f7ad0](https://github.com/Exopus-0x65f7ad0) on 2026-11-28T13:39:49Z. --- On a second NVIDIA architecture: RTX 5060 Ti 8 GB (Blackwell, `10de:2d04`), Windows 11 26300, native D3D12. `63b902f` + this PR. `cargo test --release --locked -p victory-shader --lib backward_permute_wraps_within_its_half_and_zeros_inactive_sources` → **passed**. The GPU readbacks you ran on the 4090 aren't in the PR, so I couldn't repeat those. If you push the readback test (even `#[ignore]`), I'll run it on this Blackwell card.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!1019
No description provided.