Skip to content

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

Open
Dathinel wants to merge 1 commit into
Marvisak:mainfrom
Dathinel:shader-tests/bcpack-zz
Open

Dathinel wants to merge 1 commit into
Marvisak:mainfrom
Dathinel:shader-tests/bcpack-zz

Conversation

@Dathinel

Copy link
Copy Markdown
Contributor

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

…ats function

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@fyernald fyernald left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants