Shaders: hardware test for v_alignbit/alignbyte, v_bfi, v_bfm and v_bcnt #1379

Closed
LouisRiverstone wants to merge 1 commit from upstream-pr/1379 into main
LouisRiverstone commented 2026-11-24 17:40:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LouisRiverstone on 2026-11-24T17:40:01Z.


v_alignbit_b32, v_alignbyte_b32, v_bfi_b32, v_bfm_b32 and v_bcnt_u32_b32 (VOP3 0x14e, 0x14f, 0x14a, 0x363, 0x364) are lowered in lower.rs, but no hardware test ran them. The align forms are the least obvious: the shift amount is masked (5 bits, or 2 bits scaled by 8) and a shift of 0 must not pull in the high dword.

New test v_align_bfi_bfm_and_bcnt_match_rdna2 runs all 216 ordered triples of {0, 1, 5, 31, 0x80000001, 0xFFFFFFFF} through each opcode. Expected values come from 64-bit shifts and plain masks in Rust.

Test only, no production change.

Verify: cargo test -p victory-shader v_align_bfi_bfm (Windows, hardware GPU or WARP). I type-checked it with clippy for x86_64-pc-windows-msvc, but could not run it locally: the shader test module is Windows-only.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587816538 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1379). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-11-24T17:40:01Z. --- `v_alignbit_b32`, `v_alignbyte_b32`, `v_bfi_b32`, `v_bfm_b32` and `v_bcnt_u32_b32` (VOP3 0x14e, 0x14f, 0x14a, 0x363, 0x364) are lowered in `lower.rs`, but no hardware test ran them. The align forms are the least obvious: the shift amount is masked (5 bits, or 2 bits scaled by 8) and a shift of 0 must not pull in the high dword. New test `v_align_bfi_bfm_and_bcnt_match_rdna2` runs all 216 ordered triples of `{0, 1, 5, 31, 0x80000001, 0xFFFFFFFF}` through each opcode. Expected values come from 64-bit shifts and plain masks in Rust. Test only, no production change. **Verify:** `cargo test -p victory-shader v_align_bfi_bfm` (Windows, hardware GPU or WARP). I type-checked it with clippy for `x86_64-pc-windows-msvc`, but could not run it locally: the shader test module is Windows-only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
catminou4 commented 2026-11-24 18:05:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:52:27Z.

Review: APPROVED


Hardware test only: v_alignbit/alignbyte, v_bfi, v_bfm, v_bcnt (VOP3). I verified v_alignbit against the ISA/LLVM definition: D = (concat(S0,S1) >> S2[4:0]) low dword with S0=MSB — the test's operand order matches. alignbyte's (c & 3) * 8 byte shift and bfi's (mask & a) | (~mask & b) are right. Windows-only execution. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host/diff_tests) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:review:6044526531 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1379#pullrequestreview-6044526531). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T17:52:27Z. **Review:** APPROVED --- Hardware test only: v_alignbit/alignbyte, v_bfi, v_bfm, v_bcnt (VOP3). I verified v_alignbit against the ISA/LLVM definition: D = (concat(S0,S1) >> S2[4:0]) low dword with S0=MSB — the test's operand order matches. alignbyte's (c & 3) * 8 byte shift and bfi's (mask & a) | (~mask & b) are right. Windows-only execution. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p victory-shader --locked`. Shader execution tests (valu_tests/host/diff_tests) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed.
nullmarsh commented 2026-11-24 18:06:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by nullmarsh on 2026-11-24T18:00:34Z.


Ran on RDNA2 hardware through vkd3d-proton on a Steam Deck (not native Windows): AMD Van Gogh, RADV 26.1.99, SteamOS 3.8.28, Proton 11.0-3 (wine-11.0) with its vkd3d-proton 212991fc. Windows MSVC test binary (rustc 1.100.0) built from head d6c7078 on main ffe310e.

  • v_align_bfi_bfm_and_bcnt_match_rdna2 passes: v_alignbit_b32, v_alignbyte_b32, v_bfi_b32, v_bfm_b32 and v_bcnt_u32_b32 over all 216 triples.
  • victory-shader lib tests: 120 passed, 1 failed, 1 ignored (main on the same host: 119/1/1). The one failure, stub_pipeline_is_created, fails on main too (likely vkd3d-proton accepting the zero DXIL digest the test expects refused; environment, not this PR).
  • No hangs. A pass means the translated DXIL gives these values on RDNA2 through vkd3d-proton/RADV; it isn't a console measurement.

Not tested: native Windows AMD drivers; WARP (this setup has none, so the WARP leg ran on RADV too).

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140024146 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1379#issuecomment-7140024146). Originally posted by [nullmarsh](https://github.com/nullmarsh) on 2026-11-24T18:00:34Z. --- Ran on RDNA2 hardware through vkd3d-proton on a Steam Deck (not native Windows): AMD Van Gogh, RADV 26.1.99, SteamOS 3.8.28, Proton 11.0-3 (wine-11.0) with its vkd3d-proton 212991fc. Windows MSVC test binary (rustc 1.100.0) built from head `d6c7078` on main `ffe310e`. - `v_align_bfi_bfm_and_bcnt_match_rdna2` passes: v_alignbit_b32, v_alignbyte_b32, v_bfi_b32, v_bfm_b32 and v_bcnt_u32_b32 over all 216 triples. - victory-shader lib tests: 120 passed, 1 failed, 1 ignored (main on the same host: 119/1/1). The one failure, `stub_pipeline_is_created`, fails on main too (likely vkd3d-proton accepting the zero DXIL digest the test expects refused; environment, not this PR). - No hangs. A pass means the translated DXIL gives these values on RDNA2 through vkd3d-proton/RADV; it isn't a console measurement. Not tested: native Windows AMD drivers; WARP (this setup has none, so the WARP leg ran on RADV too). AI-assisted (Claude Code, Claude Opus 5.5); no game data.
marquezinii commented 2026-11-24 20:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T19:13:03Z.


Native Windows NVIDIA data point: RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1, head d6c7078. cargo test -p victory-shader --lib -- --test-threads=1 --nocapture gives 121 passed, 0 failed, 1 ignored. v_align_bfi_bfm_and_bcnt_match_rdna2 passes on the hardware adapter and WARP, with nothing skipped on the hardware adapter.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7141770931 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1379#issuecomment-7141770931). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T19:13:03Z. --- Native Windows NVIDIA data point: RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1, head `d6c7078`. `cargo test -p victory-shader --lib -- --test-threads=1 --nocapture` gives 121 passed, 0 failed, 1 ignored. `v_align_bfi_bfm_and_bcnt_match_rdna2` passes on the hardware adapter and WARP, with nothing skipped on the hardware adapter.
wwwwwwww3333333 commented 2026-11-24 20:03:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-24T19:13:55Z.


Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head d6c7078 on main ffe310e (clean merge).

cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignored (main alone: 120 passed). v_align_bfi_bfm_and_bcnt_match_rdna2 ran on the hardware adapter and then on WARP, and passed on both. The earlier RDNA2 runs on this PR went through vkd3d-proton on Linux; this one is AMD's own D3D12 driver.

Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7141793495 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1379#issuecomment-7141793495). Originally posted by [wwwwwwww3333333](https://github.com/wwwwwwww3333333) on 2026-11-24T19:13:55Z. --- Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head d6c7078 on main ffe310e (clean merge). `cargo test -p victory-shader --lib -- --test-threads=1`: **121 passed, 0 failed**, 1 ignored (main alone: 120 passed). `v_align_bfi_bfm_and_bcnt_match_rdna2` ran on the hardware adapter and then on WARP, and passed on both. The earlier RDNA2 runs on this PR went through vkd3d-proton on Linux; this one is AMD's own D3D12 driver. Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
mercuryVM commented 2026-11-24 21:02:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T20:15:36Z.

Review: APPROVED


Tested d6c7078 on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 633 passed, 0 failed (on our fork main), with victory-shader single-threaded. v_align_bfi_bfm_and_bcnt_match_rdna2 passes on the hardware device for all 216 triples of each of the 5 opcodes.

  • The reference functions match the RDNA2 ISA:
    • alignbit: shift masked to 5 bits.
    • alignbyte: 2 bits scaled by 8.
    • bfi: (m & a) | (!m & b).
    • bfm: ((1 << (a & 31)) - 1) << (b & 31).
    • bcnt: popcount plus b.
  • The value set covers the edge cases that matter: a shift of 0, a shift of 31, the sign bit and all-ones.
  • Test-only, so it can't change translation.

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6046644804 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1379#pullrequestreview-6046644804). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T20:15:36Z. **Review:** APPROVED --- Tested d6c7078 on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 633 passed, 0 failed (on our fork main), with victory-shader single-threaded. `v_align_bfi_bfm_and_bcnt_match_rdna2` passes on the hardware device for all 216 triples of each of the 5 opcodes. - The reference functions match the RDNA2 ISA: - `alignbit`: shift masked to 5 bits. - `alignbyte`: 2 bits scaled by 8. - `bfi`: `(m & a) | (!m & b)`. - `bfm`: `((1 << (a & 31)) - 1) << (b & 31)`. - `bcnt`: popcount plus `b`. - The value set covers the edge cases that matter: a shift of 0, a shift of 31, the sign bit and all-ones. - Test-only, so it can't change translation. Merged into our fork's main. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 01:08:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:39:16Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

v_alignbit, v_alignbyte, v_bfi, v_bfm and v_bcnt (0x14E, 0x14F, 0x14A, 0x363, 0x364) are all in main's semantics_tests.rs integer_probes, with wider shift and field inputs.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148737052 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1379#issuecomment-7148737052). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:39:16Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. v_alignbit, v_alignbyte, v_bfi, v_bfm and v_bcnt (0x14E, 0x14F, 0x14A, 0x363, 0x364) are all in main's semantics_tests.rs `integer_probes`, with wider shift and field inputs. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

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
Marvisak/VIctory!1379
No description provided.