Shader tests: run v_bfm_b32, v_bcnt_u32_b32, v_ffbl_b32, and v_cvt_pk_u8_f32 on the GPU #1803

Closed
n-romanovich wants to merge 1 commit from upstream-pr/1804 into main
n-romanovich commented 2026-11-24 22:50:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-24T22:50:05Z.


Adds a synthetic GPU/WARP execution test (valu_bit_and_pack_ops_match_rdna2) in crates/victory-shader/src/emit/valu_tests.rs covering four previously untested RDNA2 VALU ops:

  • v_bfm_b32 (0x363), including 5-bit operand masking (32 -> 0, 33 -> 1).
  • v_bcnt_u32_b32 (0x364), including 32-bit accumulator wrap-around.
  • v_ffbl_b32 (0x03a), including 0 -> u32::MAX (-1).
  • v_cvt_pk_u8_f32 (0x15e), including round-to-nearest-even, [0, 255] clamping, 2-bit byte-index masking, and preservation of other bytes in src2.

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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6592982229 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804). Originally posted by [n-romanovich](https://github.com/n-romanovich) on 2026-11-24T22:50:05Z. --- Adds a synthetic GPU/WARP execution test (`valu_bit_and_pack_ops_match_rdna2`) in `crates/victory-shader/src/emit/valu_tests.rs` covering four previously untested RDNA2 VALU ops: - `v_bfm_b32` (`0x363`), including 5-bit operand masking (`32 -> 0`, `33 -> 1`). - `v_bcnt_u32_b32` (`0x364`), including 32-bit accumulator wrap-around. - `v_ffbl_b32` (`0x03a`), including `0 -> u32::MAX` (`-1`). - `v_cvt_pk_u8_f32` (`0x15e`), including round-to-nearest-even, `[0, 255]` clamping, 2-bit byte-index masking, and preservation of other bytes in `src2`. AI-assisted; verified with `cargo test -p victory-shader --locked -- valu_bit_and_pack_ops_match_rdna2` and `cargo clippy -p victory-shader --all-targets --locked` on Windows 11 / RTX 5060 Ti + WARP, plus independent subagent review.
catminou4 commented 2026-11-24 23:05:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:04:20Z.

Review: APPROVED


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_bfm_b32/v_bcnt_u32_b32/v_ffbl_b32/v_cvt_pk* match_rdna2 — Windows-gated valu test; macOS compile+unit green.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048810679 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804#pullrequestreview-6048810679). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:04:20Z. **Review:** APPROVED --- 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_bfm_b32/v_bcnt_u32_b32/v_ffbl_b32/v_cvt_pk* match_rdna2 — Windows-gated valu test; macOS compile+unit green.
DesertGamer commented 2026-11-24 23:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T22:56:38Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146827579 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804#issuecomment-7146827579). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-24T22:56:38Z. --- ### 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.*
upipibi commented 2026-11-24 23:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T23:04:55Z.


NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 3b3c1f5 (on main 70564ae). valu_bit_and_pack_ops_match_rdna2 passes, 2 of 2 runs.

For v_cvt_pk_u8_f32, one more case could be added. AnyPS5 measured it on RDNA2 hardware (their docs/dev/debt/shader.md): it rounds in the FLOAT_MODE f32 round mode (ties to even by default, as tested here), clamps to 0..255, and gives 0 for a NaN source.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146990853 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804#issuecomment-7146990853). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T23:04:55Z. --- NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `3b3c1f5` (on `main` `70564ae`). `valu_bit_and_pack_ops_match_rdna2` passes, 2 of 2 runs. For `v_cvt_pk_u8_f32`, one more case could be added. AnyPS5 measured it on RDNA2 hardware (their `docs/dev/debt/shader.md`): it rounds in the `FLOAT_MODE` f32 round mode (ties to even by default, as tested here), clamps to 0..255, and gives 0 for a NaN source. AI-assisted (Claude Code). Synthetic tests only.
Melow-code commented 2026-11-25 00:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Melow-code on 2026-11-24T23:07:58Z.

Review: APPROVED


Bit/pack ops verified against ISA. Agree with upipibi that a NaN case for v_cvt_pk_u8_f32 would strengthen it, but not blocking.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048847482 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804#pullrequestreview-6048847482). Originally posted by [Melow-code](https://github.com/Melow-code) on 2026-11-24T23:07:58Z. **Review:** APPROVED --- Bit/pack ops verified against ISA. Agree with upipibi that a NaN case for v_cvt_pk_u8_f32 would strengthen it, but not blocking.
Headache3318 commented 2026-11-25 02:06:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:56:19Z.


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

  • cargo test -p victory-shader --locked: 144 passed, 0 failed, 2 ignored. All tests pass. The new valu_bit_and_pack_ops_match_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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150133213 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804#issuecomment-7150133213). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T01:56:19Z. --- Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `61fb2bc` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 144 passed, 0 failed, 2 ignored. All tests pass. The new `valu_bit_and_pack_ops_match_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.
Marvisak commented 2026-11-25 07:03:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:27:19Z.


Automated triage for the maintainers.

Merge candidate. valu_bit_and_pack_ops_match_rdna2 in crates/victory-shader/src/emit/valu_tests.rs runs v_bfm_b32, v_bcnt_u32_b32, v_ffbl_b32 and v_cvt_pk_u8_f32 on the host GPU and WARP. No existing test covers these ops. I checked the opcodes against gfx10/opcodes.rs (0x363, 0x364, 0x03a, 0x15e) and the expected values against the RDNA2 ISA definitions: the 5-bit masks of v_bfm, the wrapping add of v_bcnt, v_ffbl(0) = -1, and round-to-nearest-even, the clamp and the S1[1:0] byte select of v_cvt_pk_u8_f32. The expectations come from the ISA, not from our lowering.

Note: #1810, #1811 and #1812 append to the end of the same file, so whichever merges second will need a trivial rebase.

CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154807178 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804#issuecomment-7154807178). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:27:19Z. --- <!-- victory-triage v1 head=61fb2bc60b33b3123af070a480f9658c3a351370 verdict=merge-candidate at=2026-11-25T07:03:30Z --> Automated triage for the maintainers. **Merge candidate.** `valu_bit_and_pack_ops_match_rdna2` in `crates/victory-shader/src/emit/valu_tests.rs` runs `v_bfm_b32`, `v_bcnt_u32_b32`, `v_ffbl_b32` and `v_cvt_pk_u8_f32` on the host GPU and WARP. No existing test covers these ops. I checked the opcodes against `gfx10/opcodes.rs` (0x363, 0x364, 0x03a, 0x15e) and the expected values against the RDNA2 ISA definitions: the 5-bit masks of `v_bfm`, the wrapping add of `v_bcnt`, `v_ffbl(0) = -1`, and round-to-nearest-even, the clamp and the `S1[1:0]` byte select of `v_cvt_pk_u8_f32`. The expectations come from the ISA, not from our lowering. Note: #1810, #1811 and #1812 append to the end of the same file, so whichever merges second will need a trivial rebase. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:03:09 +00:00
Marvisak commented 2026-11-25 22:04:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:02:26Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because main already tests these with more inputs. In emit/semantics_tests.rs, integers_match_the_hardware runs v_bfm_b32 over 13x13 shift/width pairs and v_bcnt_u32_b32 and v_ffbl_b32 over the edge values, and byte_packing_matches_the_hardware runs v_cvt_pk_u8_f32 over float edges, ties, NaN and every byte select, on hardware and WARP against a CPU model. Every case here is a subset of those. The expected values in this PR are right.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175858614 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1804#issuecomment-7175858614). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:02:26Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because `main` already tests these with more inputs. In `emit/semantics_tests.rs`, `integers_match_the_hardware` runs `v_bfm_b32` over 13x13 shift/width pairs and `v_bcnt_u32_b32` and `v_ffbl_b32` over the edge values, and `byte_packing_matches_the_hardware` runs `v_cvt_pk_u8_f32` over float edges, ties, NaN and every byte select, on hardware and WARP against a CPU model. Every case here is a subset of those. The expected values in this PR are right. If this is mistaken, reply here with what was missed 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!1803
No description provided.