Shader tests: BCPack's zigzag decode as console code matches the formats function #2591

Open
Dathinel wants to merge 1 commit from upstream-pr/2593 into main
Dathinel commented 2026-11-25 16:22:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T16:22:39Z.


Adds one synthetic test to emit/valu_tests.rs: BCPack's zigzag decode (zz in crates/victory-formats/src/bcpack.rs) written by hand as console code, translated by the emitter and run on the GPU, compared with the formats crate's function for every symbol.

  • Test only: one file, +36 lines, no production change, no new dependency. The reference is a copy of zz because victory-shader does not depend on victory-formats.
  • It checks a nine-instruction chain end to end (v_lshlrev_b32, v_add_nc_u32, v_bfe_u32, v_lshrrev_b32, v_cmp_ne_u32, v_cndmask_b32, v_xor_b32, v_and_b32) against a CPU function the repository already owns instead of hand-computed constants. Mnemonics in the comments were checked against the decoder.
  • Cases: all 256 symbols at widths 0 to 9, 16 and 31 (3,072). Widths of 8 and above cover the mask's truncation to a byte.

It is the first of a few small translations of the BCPack helpers to console code, one test per PR so each can be judged alone.

Tested

RTX 3050 Laptop (Ampere, 32-lane waves, driver 610.62), Windows 11 26200, Rust 1.98.1 MSVC, on main 67e8ae1:

  • cargo test --locked -p victory-shader --features host --lib bcpack_zigzag -- --test-threads=1: 1 passed (hardware and WARP).
  • cargo clippy --locked -p victory-shader --all-targets --all-features -- -D warnings: clean.
  • cargo fmt --all -- --check: no diff in the added lines. (With my rustfmt 1.98.1 it reports existing diffs in many files on main, earlier parts of this file included; this PR does not reformat them.)
  • The pre-commit asset-policy hook ran on the commit: asset policy: 1 files ok.
  • Earlier run of the same program on 940d32f with the D3D12 debug layer enabled by a local patch: 3,072/3,072 on both backends. Negative control, not included: with v_xnor_b32 in place of v_xor_b32 only the 256 width-0 cases match.
  • Not run: the whole workspace suite.

AI-assisted (Claude Code); synthetic data only.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6608803320 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2593). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T16:22:39Z. --- Adds one synthetic test to `emit/valu_tests.rs`: BCPack's zigzag decode (`zz` in `crates/victory-formats/src/bcpack.rs`) written by hand as console code, translated by the emitter and run on the GPU, compared with the formats crate's function for every symbol. - Test only: one file, +36 lines, no production change, no new dependency. The reference is a copy of `zz` because `victory-shader` does not depend on `victory-formats`. - It checks a nine-instruction chain end to end (`v_lshlrev_b32`, `v_add_nc_u32`, `v_bfe_u32`, `v_lshrrev_b32`, `v_cmp_ne_u32`, `v_cndmask_b32`, `v_xor_b32`, `v_and_b32`) against a CPU function the repository already owns instead of hand-computed constants. Mnemonics in the comments were checked against the decoder. - Cases: all 256 symbols at widths 0 to 9, 16 and 31 (3,072). Widths of 8 and above cover the mask's truncation to a byte. It is the first of a few small translations of the BCPack helpers to console code, one test per PR so each can be judged alone. ## Tested RTX 3050 Laptop (Ampere, 32-lane waves, driver 610.62), Windows 11 26200, Rust 1.98.1 MSVC, on `main` `67e8ae1`: - `cargo test --locked -p victory-shader --features host --lib bcpack_zigzag -- --test-threads=1`: 1 passed (hardware and WARP). - `cargo clippy --locked -p victory-shader --all-targets --all-features -- -D warnings`: clean. - `cargo fmt --all -- --check`: no diff in the added lines. (With my rustfmt 1.98.1 it reports existing diffs in many files on `main`, earlier parts of this file included; this PR does not reformat them.) - The pre-commit asset-policy hook ran on the commit: `asset policy: 1 files ok`. - Earlier run of the same program on `940d32f` with the D3D12 debug layer enabled by a local patch: 3,072/3,072 on both backends. Negative control, not included: with `v_xnor_b32` in place of `v_xor_b32` only the 256 width-0 cases match. - Not run: the whole workspace suite. AI-assisted (Claude Code); synthetic data only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fyernald commented 2026-11-25 17:04:47 +00:00 (Migrated from github.com)

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

Review: APPROVED


Checked on real NVIDIA hardware: RTX 3080 (617.42), Windows 10 (19045), plus WARP, main 67e8ae1 + #486 + #2596 (without #2596 the suite crashes on NVIDIA, #2571). cargo test -p victory-shader --lib --locked -- --test-threads=1 gives 267 passed, 3 failed, the same as the base. The 3 are the #1835 failures. The new probes agree with the model on both adapters.

zz_reference is identical to the private victory_formats::bcpack::zz (bcpack.rs:499), and victory-shader doesn't depend on victory-formats, so a copy is the right call. Maybe add a comment naming the line it mirrors, so that a change to zz gets carried over.

<!-- greyfinch-sync:Marvisak/VIctory:review:6061679341 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2593#pullrequestreview-6061679341). Originally posted by [fyernald](https://github.com/fyernald) on 2026-11-25T17:01:24Z. **Review:** APPROVED --- Checked on real NVIDIA hardware: **RTX 3080 (617.42), Windows 10 (19045)**, plus WARP, `main` `67e8ae1` + #486 + #2596 (without #2596 the suite crashes on NVIDIA, #2571). `cargo test -p victory-shader --lib --locked -- --test-threads=1` gives 267 passed, 3 failed, the same as the base. The 3 are the #1835 failures. The new probes agree with the model on both adapters. `zz_reference` is identical to the private `victory_formats::bcpack::zz` (`bcpack.rs:499`), and `victory-shader` doesn't depend on `victory-formats`, so a copy is the right call. Maybe add a comment naming the line it mirrors, so that a change to `zz` gets carried over.
Marvisak commented 2026-11-25 23:06:02 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: it conflicts in crates/victory-shader/src/emit/valu_tests.rs. No content review was done this time; it will be reviewed once it is rebased onto current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176131970 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2593#issuecomment-7176131970). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:15:22Z. --- <!-- victory-triage v1 head=f202300ef0bbe78107267c89c5d4bc13012fe359 verdict=needs-rebase at=2026-11-25T22:15:25Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: it conflicts in `crates/victory-shader/src/emit/valu_tests.rs`. No content review was done this time; it will be reviewed once it is rebased onto current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2593:upstream-pr/2593'
git switch 'upstream-pr/2593'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2593'
git switch 'upstream-pr/2593'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2593'
git switch 'upstream-pr/2593'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2593'
git switch 'main'
git merge --squash 'upstream-pr/2593'
git switch 'main'
git merge --ff-only 'upstream-pr/2593'
git switch 'main'
git merge 'upstream-pr/2593'
git push origin 'main'
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!2591
No description provided.