Shader tests: run v_perm_b32 on the GPU #1811

Open
github-bot wants to merge 2 commits from github-bot/gh-1811 into main AGit
Owner

@⁠n-romanovich on GitHub · 2026-11-24 22:56 UTC · original
n-romanovich:test/valu-perm-b32 → main · +78 −0 · 1 files · 2 commits · open

Adds an end-to-end synthetic GPU/WARP execution test (v_perm_b32_matches_rdna2) in crates/victory-shader/src/emit/valu_tests.rs.

Exercises both dynamic (vgpr) and inline-constant selector lowering paths across byte selection (0..7), sign-extension (8..11, both bit polarities), 12 (0x00), and >= 13 (0xFF).

AI-assisted; verified with cargo test -p victory-shader --locked (121 passed, 1 ignored) and cargo clippy -p victory-shader --all-targets --locked on Windows 11 / RTX 5060 Ti + WARP, plus independent subagent review.

**@⁠n-romanovich** on GitHub · 2026-11-24 22:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811) `n-romanovich:test/valu-perm-b32` → `main` · +78 −0 · 1 files · 2 commits · open Adds an end-to-end synthetic GPU/WARP execution test (`v_perm_b32_matches_rdna2`) in `crates/victory-shader/src/emit/valu_tests.rs`. Exercises both dynamic (`vgpr`) and inline-constant selector lowering paths across byte selection (`0..7`), sign-extension (`8..11`, both bit polarities), `12` (`0x00`), and `>= 13` (`0xFF`). AI-assisted; verified with `cargo test -p victory-shader --locked` (121 passed, 1 ignored) and `cargo clippy -p victory-shader --all-targets --locked` on Windows 11 / RTX 5060 Ti + WARP, plus independent subagent review.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:45:20 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 22:56 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-24 22:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#issuecomment-7146823427) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:11 UTC · original · edited 2026-11-25 23:21 UTC

Update, head d899f22 (with the literal-selector cases): cargo test -p victory-shader --lib v_perm_b32 -- --test-threads=1, 3 runs: v_perm_b32_matches_rdna2 passes each time, on the RTX 3070 and on WARP (the test runs both). Control: the same test copied onto main f3578e3 (main lacks it) also passes 3 of 3, so main's lowering already gives these values; this PR adds the coverage.


NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, aa2a55f (on main 70564ae). v_perm_b32_matches_rdna2 passes.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 23:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#issuecomment-7147110082) · edited 2026-11-25 23:21 UTC **Update, head `d899f22`** (with the literal-selector cases): `cargo test -p victory-shader --lib v_perm_b32 -- --test-threads=1`, 3 runs: `v_perm_b32_matches_rdna2` passes each time, on the RTX 3070 and on WARP (the test runs both). Control: the same test copied onto `main` `f3578e3` (main lacks it) also passes 3 of 3, so main's lowering already gives these values; this PR adds the coverage. --- NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `aa2a55f` (on `main` `70564ae`). `v_perm_b32_matches_rdna2` passes. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 01:53 UTC · original

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 84bbefc applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 144 passed, 0 failed, 2 ignored. All tests pass. The new v_perm_b32_matches_rdna2 test is GPU-specific (requires dxil.dll/WARP) and is skipped on Linux.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 4 pre-existing errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 01:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#issuecomment-7150078650) Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `84bbefc` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 144 passed, 0 failed, 2 ignored. All tests pass. The new `v_perm_b32_matches_rdna2` test is GPU-specific (requires dxil.dll/WARP) and is skipped on Linux. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 4 pre-existing errors in test code (fail identically on main `ccfb029`). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:27 UTC · original · edited 2026-11-26 00:22 UTC

Automated triage for the maintainers.

Merge candidate. v_perm_b32_matches_rdna2 in crates/victory-shader/src/emit/valu_tests.rs runs v_perm_b32 (VOP3 0x344) on the host GPU and WARP in three ways: with a run-time selector, with every selector in dyn_cases as a 32-bit literal (0xFF plus the dword), and with the inline constants -1 (0xC1) and 12 (0x8C). ref_perm matches the ISA's selector table. main has no value test for this opcode.

On your reply: the requested literal-selector loop is in d899f22 and covers all six dyn_cases rows, so it reaches the constant-selector branch of the lowering in lower.rs. The merge with main leaves the PR's diff as a single appended test.

CI: two check results are listed, one passing and one failing. The failure is most likely the run before the merge; worth a glance before merging.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#issuecomment-7154808816) · edited 2026-11-26 00:22 UTC <!-- victory-triage v1 head=d899f2249b017968bb2fd87fa6f5291cee4eaf45 verdict=merge-candidate at=2026-11-26T00:22:11Z --> Automated triage for the maintainers. **Merge candidate.** `v_perm_b32_matches_rdna2` in `crates/victory-shader/src/emit/valu_tests.rs` runs `v_perm_b32` (VOP3 0x344) on the host GPU and WARP in three ways: with a run-time selector, with every selector in `dyn_cases` as a 32-bit literal (`0xFF` plus the dword), and with the inline constants -1 (0xC1) and 12 (0x8C). `ref_perm` matches the ISA's selector table. `main` has no value test for this opcode. On your reply: the requested literal-selector loop is in `d899f22` and covers all six `dyn_cases` rows, so it reaches the constant-selector branch of the lowering in `lower.rs`. The merge with `main` leaves the PR's diff as a single appended test. CI: two `check` results are listed, one passing and one failing. The failure is most likely the run before the merge; worth a glance before merging. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:02 UTC · original

Automated triage for the maintainers, second look (a review against main, with the PR built and tested).

v_perm_b32 has no value test on main, so this is welcome; it can be merged after one addition. Most of the title's uses take the selector as a literal, and the lowering has a separate constant branch for that, which the test does not reach. In crates/victory-shader/src/emit/valu_tests.rs v_perm_b32_matches_rdna2, please also run each selector of dyn_cases (or at least 0x07060504, 0x0B0A0908, 0x00070205 and 0xFF0D0C04) as a literal: let mut w = vop3(0x344, 0, vgpr(1), vgpr(2), 0xFF).to_vec(); w.push(sel); build_valu_cs(&w), checked against ref_perm(src0, src1, sel). The -1 and 12 inline cases can stay. With that addition the test passes on an RX 6700 XT and on WARP. It also needs a rebase: it conflicts with main in valu_tests.rs after today's merges.

Push the change and it will be reviewed again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 22:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#issuecomment-7175855782) Automated triage for the maintainers, second look (a review against `main`, with the PR built and tested). `v_perm_b32` has no value test on `main`, so this is welcome; it can be merged after one addition. Most of the title's uses take the selector as a literal, and the lowering has a separate constant branch for that, which the test does not reach. In `crates/victory-shader/src/emit/valu_tests.rs` `v_perm_b32_matches_rdna2`, please also run each selector of `dyn_cases` (or at least 0x07060504, 0x0B0A0908, 0x00070205 and 0xFF0D0C04) as a literal: `let mut w = vop3(0x344, 0, vgpr(1), vgpr(2), 0xFF).to_vec(); w.push(sel); build_valu_cs(&w)`, checked against `ref_perm(src0, src1, sel)`. The -1 and 12 inline cases can stay. With that addition the test passes on an RX 6700 XT and on WARP. It also needs a rebase: it conflicts with `main` in `valu_tests.rs` after today's merges. Push the change and it will be reviewed again. Thank you for the contribution.
Author
Owner

@⁠n-romanovich on GitHub · 2026-11-25 22:22 UTC · original

@⁠Marvisak, pushed d899f22 - ready for re-review.

**@⁠n-romanovich** on GitHub · 2026-11-25 22:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#issuecomment-7176287712) @⁠Marvisak, pushed d899f22 - ready for re-review.
Author
Owner

@⁠n-romanovich on GitHub · 2026-11-25 22:57 UTC · original

@⁠Marvisak Updated test/valu-perm-b32 (d899f22):

  • Merged main to resolve the valu_tests.rs conflict.
  • Added the literal-selector loop in v_perm_b32_matches_rdna2 covering every selector in dyn_cases (0x03020100, 0x07060504, 0x00070205, 0x0B0A0908, and 0xFF0D0C04) via vop3(0x344, 0, vgpr(1), vgpr(2), 0xFF) + sel, checked against ref_perm.
  • Kept the -1 (0xC1) and 12 (0x8C) inline-constant cases.

v_perm_b32_matches_rdna2 passes locally and CI check passes.

**@⁠n-romanovich** on GitHub · 2026-11-25 22:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#issuecomment-7176982238) @⁠Marvisak Updated `test/valu-perm-b32` (`d899f22`): - Merged `main` to resolve the `valu_tests.rs` conflict. - Added the literal-selector loop in `v_perm_b32_matches_rdna2` covering every selector in `dyn_cases` (`0x03020100`, `0x07060504`, `0x00070205`, `0x0B0A0908`, and `0xFF0D0C04`) via `vop3(0x344, 0, vgpr(1), vgpr(2), 0xFF)` + `sel`, checked against `ref_perm`. - Kept the `-1` (`0xC1`) and `12` (`0x8C`) inline-constant cases. `v_perm_b32_matches_rdna2` passes locally and CI `check` passes.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 23:04 UTC · original · approved these changes

Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae), cargo test -p victory-shader --locked → 118 passed, 0 failed. GPU execution tests (valu_tests/host) are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.

GPU test: v_perm_b32 matches_rdna2 — Windows-gated.

**@⁠catminou4** on GitHub · 2026-11-24 23:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#pullrequestreview-6048810916) · **approved these changes** Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae), cargo test -p victory-shader --locked → 118 passed, 0 failed. GPU execution tests (valu_tests/host) are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests. GPU test: v_perm_b32 matches_rdna2 — Windows-gated.
Author
Owner

@⁠Melow-code on GitHub · 2026-11-24 23:07 UTC · original · approved these changes

The ref_perm matches the lowering in lower.rs exactly, including the detail that selectors 8..11 repeat the sign of bytes 1 and 3 (not 0 and 2). The inline-constant path is exercised: 0xC1 (−1, all 0xFF) and 0x8C (12, the zero constant) are verified against resource::inline.

The source pair 0x8765_4321 / 0x7EAB_CD01 was chosen so that bytes 1 and 3 of each source carry opposite signs — every sign-repeat selector gets a definite value.

Nit: in the constants case, byte 0 of the selector word is 0x04 (byte 0 of src0), not a constant, though the comment lists only 12/13/255. Harmless since the expected value comes from ref_perm.

**@⁠Melow-code** on GitHub · 2026-11-24 23:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#pullrequestreview-6048839958) · **approved these changes** The ref_perm matches the lowering in lower.rs exactly, including the detail that selectors 8..11 repeat the sign of bytes 1 and 3 (not 0 and 2). The inline-constant path is exercised: 0xC1 (−1, all 0xFF) and 0x8C (12, the zero constant) are verified against resource::inline. The source pair 0x8765_4321 / 0x7EAB_CD01 was chosen so that bytes 1 and 3 of each source carry opposite signs — every sign-repeat selector gets a definite value. Nit: in the constants case, byte 0 of the selector word is 0x04 (byte 0 of src0), not a constant, though the comment lists only 12/13/255. Harmless since the expected value comes from ref_perm.
Author
Owner

@⁠Melow-code on GitHub · 2026-11-25 11:54 UTC · original · approved these changes

Review: PR #1811 — GPU test for v_perm_b32

Author: n-romanovich. One test in valu_tests.rs, 64 lines. Fetch: git fetch upstream pull/1811/head:pr1811.

Verdict: mergeable as is

The opcode checks against the tree: v_perm_b32 = 0x344 (gfx10/opcodes.rs 738). The reference ref_perm matches the semantics the tree's own lowering implements (lower.rs 6738, the "Byte i of the result is byte S of {src0, src1} (src1 the low dword)" comment), which is the ground truth this repository already ships:

  • selector bytes 0..3: byte N of src1 (the low dword of {src0, src1});
  • 4..7: byte N of src0;
  • 8: src1 bit 15, 9: src1 bit 31, 10: src0 bit 15, 11: src0 bit 31 (the sign repeats of bytes 1 and 3 of each source — not of bytes 0 and 2, a detail the test gets right and a naive reading of the ISA would not);
  • 12: 0x00; anything above: 0xFF.

The inline-constant encodings check against resource::inline (resource.rs 2112): 0xC1 = 193 → (192 - 193) as u32 = 0xFFFF_FFFF (the "−1" selector, every field ≥ 13 → all 0xFF), and 0x8C = 140 → 12 (the zero constant). Both are exercised, so the selector-through-inline-constant path of the lowering is covered too.

The dynamic cases cover: the src1 identity (0x0302_0100), the src0 identity (0x0706_0504), a mixed-byte gather across both sources, the four sign-repeat selectors with a value pair whose bytes 1 and 3 carry opposite signs in each source, and a pair that flips those signs (0x1234_8000 / 0x8000_7FFF) so a sign bug shows as a byte difference, not a whole-dword one. The constants case adds selectors 4, 12, 13 and 255 in one word.

Notes (non-blocking)

  1. In the last dynamic case the comment lists "12 (0x00), 13 (0xFF), 255 (0xFF)" but byte 0 of that selector word is 0x04 (byte 0 of src0), not a constant. Harmless; the expected value comes from ref_perm either way.
  2. The source pair 0x8765_4321 / 0x7EAB_CD01 was chosen so that src0's bytes 1 and 3 carry signs 0 and 1 while src1's carry 1 and 0 — every sign-repeat selector is exercised with a definite value on both sources. Nice touch worth keeping if the test ever grows more selectors.
  3. Style matches the module. Good to merge.
**@⁠Melow-code** on GitHub · 2026-11-25 11:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#pullrequestreview-6057118752) · **approved these changes** # Review: PR #1811 — GPU test for v_perm_b32 Author: n-romanovich. One test in valu_tests.rs, 64 lines. Fetch: `git fetch upstream pull/1811/head:pr1811`. ## Verdict: mergeable as is The opcode checks against the tree: `v_perm_b32` = 0x344 (gfx10/opcodes.rs 738). The reference `ref_perm` matches the semantics the tree's own lowering implements (lower.rs 6738, the "Byte i of the result is byte S of {src0, src1} (src1 the low dword)" comment), which is the ground truth this repository already ships: - selector bytes 0..3: byte N of src1 (the low dword of {src0, src1}); - 4..7: byte N of src0; - 8: src1 bit 15, 9: src1 bit 31, 10: src0 bit 15, 11: src0 bit 31 (the sign repeats of bytes 1 and 3 of each source — not of bytes 0 and 2, a detail the test gets right and a naive reading of the ISA would not); - 12: 0x00; anything above: 0xFF. The inline-constant encodings check against `resource::inline` (resource.rs 2112): 0xC1 = 193 → `(192 - 193) as u32` = 0xFFFF_FFFF (the "−1" selector, every field ≥ 13 → all 0xFF), and 0x8C = 140 → 12 (the zero constant). Both are exercised, so the selector-through-inline-constant path of the lowering is covered too. The dynamic cases cover: the src1 identity (0x0302_0100), the src0 identity (0x0706_0504), a mixed-byte gather across both sources, the four sign-repeat selectors with a value pair whose bytes 1 and 3 carry opposite signs in each source, and a pair that flips those signs (0x1234_8000 / 0x8000_7FFF) so a sign bug shows as a byte difference, not a whole-dword one. The constants case adds selectors 4, 12, 13 and 255 in one word. ## Notes (non-blocking) 1. In the last dynamic case the comment lists "12 (0x00), 13 (0xFF), 255 (0xFF)" but byte 0 of that selector word is 0x04 (byte 0 of src0), not a constant. Harmless; the expected value comes from ref_perm either way. 2. The source pair 0x8765_4321 / 0x7EAB_CD01 was chosen so that src0's bytes 1 and 3 carry signs 0 and 1 while src1's carry 1 and 0 — every sign-repeat selector is exercised with a definite value on both sources. Nice touch worth keeping if the test ever grows more selectors. 3. Style matches the module. Good to merge.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 19:13 UTC · original · approved these changes

Verified locally merged onto origin/main (63bcca43, Windows 11 x64, Rust 1.98.1 MSVC, RTX 5090 & WARP):

  • cargo test --locked -p victory-shader --lib v_perm_b32_matches_rdna2 (VICTORY_WARP=0 and VICTORY_WARP=1) — 1 passed, 0 failed on both backends
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features) — 0 warnings
  • cargo xtask policy — ok (191 files ok)

Review notes

  • Verified v_perm_b32 (0x344) encodings and ref_perm against RDNA2 semantics (0..=3 from src1, 4..=7 from src0, 8..=11 sign extensions of src1[15]/src1[31]/src0[15]/src0[31], 12 -> 0x00, 13..=255 -> 0xFF), exercising both the dynamic v3 path and the inline-constant (0xC1, 0x8C) / 32-bit literal (0xFF + sel) constant-selector paths in lower.rs.
  • Minor non-blocking formatting nit: rustfmt --edition 2024 --check flags the added one-line if match arms and closure wrapping in v_perm_b32_matches_rdna2 (valu_tests.rs:2298-2355).
**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1811#pullrequestreview-6079375650) · **approved these changes** Verified locally merged onto `origin/main` (`63bcca43`, Windows 11 x64, Rust 1.98.1 MSVC, RTX 5090 & WARP): - `cargo test --locked -p victory-shader --lib v_perm_b32_matches_rdna2` (`VICTORY_WARP=0` and `VICTORY_WARP=1`) — **1 passed, 0 failed** on both backends - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings - `cargo xtask policy` — ok (`191 files ok`) ### Review notes - Verified `v_perm_b32` (`0x344`) encodings and `ref_perm` against RDNA2 semantics (`0..=3` from `src1`, `4..=7` from `src0`, `8..=11` sign extensions of `src1[15]`/`src1[31]`/`src0[15]`/`src0[31]`, `12` -> `0x00`, `13..=255` -> `0xFF`), exercising both the dynamic `v3` path and the inline-constant (`0xC1`, `0x8C`) / 32-bit literal (`0xFF` + `sel`) constant-selector paths in `lower.rs`. - Minor non-blocking formatting nit: `rustfmt --edition 2024 --check` flags the added one-line `if` match arms and closure wrapping in `v_perm_b32_matches_rdna2` (`valu_tests.rs:2298-2355`).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1811/head:github-bot/gh-1811'
git switch 'github-bot/gh-1811'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1811'
git switch 'github-bot/gh-1811'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1811'
git switch 'github-bot/gh-1811'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1811'
git switch 'main'
git merge --squash 'github-bot/gh-1811'
git switch 'main'
git merge --ff-only 'github-bot/gh-1811'
git switch 'main'
git merge 'github-bot/gh-1811'
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!1811
No description provided.