Shaders: lower v_permlane16/v_permlanex16 and honor their EXEC and FI/BC flags (reopens #1014, #1737) #3587

Open
github-bot wants to merge 9 commits from github-bot/gh-3587 into main AGit
Owner

@⁠zed6000 on GitHub · 2026-11-27 19:24 UTC · original
zed6000:revive-permlane → main · +616 −1 · 4 files · 9 commits · open

This reopens #1737 by @⁠jaschinski97-ops (permlane EXEC and FI/BC flags), together with the v_permlane16_b32 / v_permlanex16_b32 lowering from #1014 by @⁠bartikele that it builds on. Both were closed on 2026-11-26 without being merged. The change is still needed on main: one program the title runs in the intro is refused with emit: v_permlanex16_b32.

The branch is @⁠steven-seagull27's fast-forward of #1737 onto main 63bcca4, from their comment on #1737. All original commits and authors are kept. It adds the divergent FI=0 readback fixture, the two ds_bpermute regressions found at the merge conflict, the permlane code in its own module (which keeps lower.rs under the size limit), and their fix that refuses scalar branches it can't prove host-uniform.

Measured on an RX 7900 XTX (driver 32.0.32029.2010), Windows 11:

  • Shader census of the shipped shaders.rpf (translate --validate --list, 26,084 programs), compared with main 63bcca4 program by program: +1, 0 lost. The one is that v_permlanex16_b32 refusal.
  • cargo test -p victory-shader --lib --locked: 311 passed, 0 failed.
  • In the game, as part of the tested set in #3347, the intro runs with 0 dropped draws.

I'm happy to hand this back if any of the original authors wants to continue it. AI-assisted (Claude Code); counts only, no game data.

**@⁠zed6000** on GitHub · 2026-11-27 19:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/3587) `zed6000:revive-permlane` → `main` · +616 −1 · 4 files · 9 commits · open This reopens #1737 by @⁠jaschinski97-ops (permlane EXEC and FI/BC flags), together with the `v_permlane16_b32` / `v_permlanex16_b32` lowering from #1014 by @⁠bartikele that it builds on. Both were closed on 2026-11-26 without being merged. The change is still needed on `main`: one program the title runs in the intro is refused with `emit: v_permlanex16_b32`. The branch is @⁠steven-seagull27's fast-forward of #1737 onto `main` `63bcca4`, from their comment on #1737. All original commits and authors are kept. It adds the divergent FI=0 readback fixture, the two `ds_bpermute` regressions found at the merge conflict, the permlane code in its own module (which keeps `lower.rs` under the size limit), and their fix that refuses scalar branches it can't prove host-uniform. **Measured** on an RX 7900 XTX (driver 32.0.32029.2010), Windows 11: - **Shader census** of the shipped `shaders.rpf` (`translate --validate --list`, 26,084 programs), compared with `main` `63bcca4` program by program: **+1, 0 lost**. The one is that `v_permlanex16_b32` refusal. - `cargo test -p victory-shader --lib --locked`: 311 passed, 0 failed. - In the game, as part of the tested set in #3347, the intro runs with 0 dropped draws. I'm happy to hand this back if any of the original authors wants to continue it. AI-assisted (Claude Code); counts only, no game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:29:12 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 20:10 UTC · original

Independent verification of #3587 (head 733f9e8584e2a35cbf0f1e066a2077ad3502f039, base main 63bcca43). Claimed on #1633. AI-assisted: Claude Code (Claude Sonnet 5.5). Counts only, no game data.

Setup: Windows 11 (26100), rustc 1.98.1, VICTORY_WARP=1 and VICTORY_D3D12_WARP=1, WARP d3d10warp.dll 10.0.26100.9818, dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100). No physical GPU used. Note: a dxil.dll from SDK 19041 crashes the test binary with STATUS_ACCESS_VIOLATION on both base and head, so use a newer one.

Tests (cargo test -p victory-shader --lib --locked -j 4):

  • base 63bcca43: 298 passed, 4 failed, 3 ignored (305 tests).
  • head: 307 passed, 4 failed, 3 ignored (314 tests, +9 new, all 9 pass).
  • The same 4 fail on base and on head (all in emit::synthetic_tests: a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out). They are not caused by this PR and are probably WARP-specific.
  • Control (only the PR's test hunks on base): 6 of the 9 new tests fail on base (refused: v_permlanex16_b32, or the FI "outside the host branch" refusal missing). 3 still pass on base: permlane16_lowers (does not discriminate; the simple case already lowers on base), and permlane_rows_and_inactive_sources / permlane_fi_zero_under_divergent_exec (see the caveat below).
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings on head: clean.
  • lower.rs on head: 521,003 bytes (limit 524,288), OK.

Caveat (important): on this WARP the host reports waves 4..4, so the two execution tests print "GPU checks skipped". Row selection, FI/BC and EXEC behaviour at run time were therefore NOT executed here. They rest on the author's RX 7900 XTX run. What I verified is that the lowering is accepted, DXIL validates, and the refusals trigger.

Review of the diff (reading only, not run here):

  • src1/src2 nibble order: lanes 0-7 take src1, lanes 8-15 take src2, shift (lane&7)*4. Matches the RDNA2 ISA.
  • Rows: permlane16 stays in the lane's own 16-row; permlanex16 XORs with 16, so it crosses the two rows of an aligned 32-lane half. On wave64 each 32-lane half stays separate.
  • OPSEL[0]=FI and OPSEL[1]=BC. FI=0: the source lane is checked with a ballot that includes the console EXEC guard; an inactive source gives 0 with BC=1, else the old destination value. FI=1: a plain lane read, refused when the instruction is not reached by every host lane. Abs, neg and the other opsel bits are refused.
  • Inactive destination lanes: the write goes through write_i(..., guard).
  • Not proven (read only): the mapping of console wave32 onto a wave64 host in lane_index() was not exercised here.
  • Cosmetic: the matches! line added in lower.rs is over 100 columns (not rustfmt-formatted) and there is a stray blank line after TWO_PI. cargo fmt --check on the crate is already not clean on base, so this is not new.

Overlap with other open PRs:

  • #98: it already conflicts with main in emit/wave.rs, and with #3587 as well. #3587 does not touch wave.rs, so #3587 does not cause it. Both lower v_permlane16/v_permlanex16, so they overlap in purpose (#98 only in whole-wave sections).
  • #2997: no textual conflict with #3587 (git merge-tree is clean). But the merged lower.rs would be 524,420 bytes, 132 over the 524,288 limit. If that limit is enforced by cargo xtask policy (it appears to be, MAX_FILE_SIZE in xtask/src/policy.rs, not run here), whichever lands second would need to move code out of lower.rs.

Verdict: the new tests pass and the control confirms 6 of 9 are meaningful on base; no correctness defect found in the lowering by reading, but the run-time behaviour was not exercised on this WARP.

**@⁠oni-swr** on GitHub · 2026-11-27 20:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/3587#issuecomment-7227245255) Independent verification of #3587 (head `733f9e8584e2a35cbf0f1e066a2077ad3502f039`, base `main` `63bcca43`). Claimed on #1633. AI-assisted: Claude Code (Claude Sonnet 5.5). Counts only, no game data. **Setup:** Windows 11 (26100), rustc 1.98.1, `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1`, WARP `d3d10warp.dll` 10.0.26100.9818, `dxil.dll` 1.8.2502.11 (Windows SDK 10.0.26100). No physical GPU used. Note: a `dxil.dll` from SDK 19041 crashes the test binary with STATUS_ACCESS_VIOLATION on both base and head, so use a newer one. **Tests** (`cargo test -p victory-shader --lib --locked -j 4`): - base `63bcca43`: 298 passed, 4 failed, 3 ignored (305 tests). - head: 307 passed, 4 failed, 3 ignored (314 tests, +9 new, all 9 pass). - The same 4 fail on base and on head (all in `emit::synthetic_tests`: `a_mask_joined_with_data_at_a_uniform_loop_is_its_number`, `gathers_at_a_level_match_the_hardware`, `permutes_mask_high_address_bits_and_divergent_branches`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`). They are not caused by this PR and are probably WARP-specific. - **Control** (only the PR's test hunks on base): 6 of the 9 new tests fail on base (refused: `v_permlanex16_b32`, or the FI "outside the host branch" refusal missing). 3 still pass on base: `permlane16_lowers` (does not discriminate; the simple case already lowers on base), and `permlane_rows_and_inactive_sources` / `permlane_fi_zero_under_divergent_exec` (see the caveat below). - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` on head: clean. - `lower.rs` on head: 521,003 bytes (limit 524,288), OK. **Caveat (important):** on this WARP the host reports waves 4..4, so the two execution tests print "GPU checks skipped". Row selection, FI/BC and EXEC behaviour at run time were therefore NOT executed here. They rest on the author's RX 7900 XTX run. What I verified is that the lowering is accepted, DXIL validates, and the refusals trigger. **Review of the diff** (reading only, not run here): - src1/src2 nibble order: lanes 0-7 take src1, lanes 8-15 take src2, shift `(lane&7)*4`. Matches the RDNA2 ISA. - Rows: permlane16 stays in the lane's own 16-row; permlanex16 XORs with 16, so it crosses the two rows of an aligned 32-lane half. On wave64 each 32-lane half stays separate. - OPSEL[0]=FI and OPSEL[1]=BC. FI=0: the source lane is checked with a ballot that includes the console EXEC guard; an inactive source gives 0 with BC=1, else the old destination value. FI=1: a plain lane read, refused when the instruction is not reached by every host lane. Abs, neg and the other opsel bits are refused. - Inactive destination lanes: the write goes through `write_i(..., guard)`. - Not proven (read only): the mapping of console wave32 onto a wave64 host in `lane_index()` was not exercised here. - Cosmetic: the `matches!` line added in `lower.rs` is over 100 columns (not rustfmt-formatted) and there is a stray blank line after `TWO_PI`. `cargo fmt --check` on the crate is already not clean on base, so this is not new. **Overlap with other open PRs:** - #98: it already conflicts with `main` in `emit/wave.rs`, and with #3587 as well. #3587 does not touch `wave.rs`, so #3587 does not cause it. Both lower `v_permlane16`/`v_permlanex16`, so they overlap in purpose (#98 only in whole-wave sections). - #2997: no textual conflict with #3587 (`git merge-tree` is clean). But the merged `lower.rs` would be 524,420 bytes, 132 over the 524,288 limit. If that limit is enforced by `cargo xtask policy` (it appears to be, `MAX_FILE_SIZE` in `xtask/src/policy.rs`, not run here), whichever lands second would need to move code out of `lower.rs`. Verdict: the new tests pass and the control confirms 6 of 9 are meaningful on base; no correctness defect found in the lowering by reading, but the run-time behaviour was not exercised on this WARP.
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 21:05 UTC · original

Verified on AMD Radeon 780M (RDNA3, supports both wave32 and wave64), Windows 11, head 733f9e8.

Before (main 63bcca4 + this PR's permlane_tests.rs): 0/8 passed. Lowering fails before any check runs (lower permlane expect panics, and the rejection tests get a different error than the expected Unsupported).

After: 9/9 passed, 5 of 5 runs. Hardware readback from the first run:

wave divergent EXEC result
32 no 0/51200 wrong, 400 dispatches
64 no 0/51200 wrong, 400 dispatches
32 yes 0/25600 wrong, 200 dispatches
64 yes 0/25600 wrong, 200 dispatches

Full suite (victory-shader + victory-gpu --features diagnostics): 560 passed, 0 failed.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 21:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/3587#issuecomment-7228116713) Verified on AMD Radeon 780M (RDNA3, supports both wave32 and wave64), Windows 11, head 733f9e8. **Before (main 63bcca4 + this PR's `permlane_tests.rs`):** 0/8 passed. Lowering fails before any check runs (`lower permlane` expect panics, and the rejection tests get a different error than the expected `Unsupported`). **After:** 9/9 passed, 5 of 5 runs. Hardware readback from the first run: | wave | divergent EXEC | result | |---|---|---| | 32 | no | 0/51200 wrong, 400 dispatches | | 64 | no | 0/51200 wrong, 400 dispatches | | 32 | yes | 0/25600 wrong, 200 dispatches | | 64 | yes | 0/25600 wrong, 200 dispatches | Full suite (`victory-shader` + `victory-gpu --features diagnostics`): 560 passed, 0 failed. AI-assisted (Claude).
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/3587/head:github-bot/gh-3587'
git switch 'github-bot/gh-3587'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3587'
git switch 'github-bot/gh-3587'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3587'
git switch 'github-bot/gh-3587'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3587'
git switch 'main'
git merge --squash 'github-bot/gh-3587'
git switch 'main'
git merge --ff-only 'github-bot/gh-3587'
git switch 'main'
git merge 'github-bot/gh-3587'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3587
No description provided.