Shader tests: translate BCPack's signed nibble split and check every input #2656

Open
github-bot wants to merge 1 commit from github-bot/gh-2656 into main AGit
Owner

@⁠Dathinel on GitHub · 2026-11-25 17:39 UTC · original
Dathinel:shader-tests/victory-bcpack-nibbles → main · +54 −0 · 1 files · 1 commits · open

Translates the BCPack signed residual pair into a synthetic console compute shader. It gathers alternating bits from a byte, zigzag-decodes each half and packs the pair in either order. The test exercises all 256 bytes in both orders. The expected values come from a test-local copy of the private formats helper; I verified the two Rust function bodies match on base 13f91ca.

On Windows, cargo test --locked -p victory-shader --features host --lib bcpack_nibble_split -- --nocapture passed on the RTX 3050 Laptop and WARP (512 cases per backend, 23.85 s). The staged asset-policy check passed. Only the focused test was run.

AI-assisted. Claude Code wrote the original synthetic shader and reviewed the port; Codex ported it and ran the checks.

**@⁠Dathinel** on GitHub · 2026-11-25 17:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2656) `Dathinel:shader-tests/victory-bcpack-nibbles` → `main` · +54 −0 · 1 files · 1 commits · open Translates the BCPack signed residual pair into a synthetic console compute shader. It gathers alternating bits from a byte, zigzag-decodes each half and packs the pair in either order. The test exercises all 256 bytes in both orders. The expected values come from a test-local copy of the private formats helper; I verified the two Rust function bodies match on base `13f91ca`. On Windows, `cargo test --locked -p victory-shader --features host --lib bcpack_nibble_split -- --nocapture` passed on the RTX 3050 Laptop and WARP (512 cases per backend, 23.85 s). The staged asset-policy check passed. Only the focused test was run. AI-assisted. Claude Code wrote the original synthetic shader and reviewed the port; Codex ported it and ran the checks.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:20 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:54 UTC · original

Reviewed: the shader body faithfully re-implements bcpack::nibbles (bit-gather halves, zigzag to signed, odd/even order flag) and checks all 256 byte values × 2 orders against the reference — a real end-to-end check of the translation chain, not just the math. Test-only change; CI green expected.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2656#issuecomment-7170174064) Reviewed: the shader body faithfully re-implements `bcpack::nibbles` (bit-gather halves, zigzag to signed, odd/even order flag) and checks all 256 byte values × 2 orders against the reference — a real end-to-end check of the translation chain, not just the math. Test-only change; CI green expected.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:13 UTC · original

Independent verification of head 68e09ee6e84d521698e504b3dfda833500a111a9 on origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca (test-only PR; merges cleanly, fast-forward).

Environment: Windows 11 Pro 10.0.26100, WARP (d3d10warp 10.0.26100.9818) only, rustc/cargo 1.98.1 (per rust-toolchain.toml), DXC 1.8.2502.11 / dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0 x64). VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 set for every run; victory-gpu tests were only run with --features diagnostics (without it the crate opens the default adapter). Limits: no physical GPU, no game files, no title-driven runs; this says nothing about behaviour on real hardware.

  • Focused: cargo test -j 4 --locked -p victory-shader bcpack_nibble_split with WARP + dxil.dll on PATH -> emit::valu_tests::bcpack_nibble_split_matches_the_formats_function 1 passed (512 cases: every byte, both orders; bit-exact compare of the packed 32-bit result).
  • Full crate: 268 passed, 3 failed, 3 ignored. origin/main baseline: 267 passed, 3 failed, 3 ignored. The same three fail in both: synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out}. They are lane/wave tests that fail on WARP; unrelated to this PR.
  • clippy -p victory-shader --all-targets [--all-features] -- -D warnings: clean.
  • No production change, so no revert control. Instead: (a) origin/main has no such test (0 matches); (b) nibbles_reference is textually identical to the formats crate's nibbles; (c) mutation check: changing the shader's zigzag shift amount (vop3(0x116, 9, 129, ..) -> 130) makes the test fail (nibbles[4, 0, 0, 0]: got 0, want 1), so the shader body is really being compared.
  • Nits: the formats function is private, so the doc comment's victory_formats::bcpack::nibbles is a copy that can drift without any check (victory-shader does not depend on victory-formats); and the failure message says hardware: even when the run was on WARP.

AI disclosure: independent verification by Claude Code / Claude Sonnet 5.5, run for a user; no game files, dumps or hashes involved.

**@⁠oni-swr** on GitHub · 2026-11-25 18:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2656#issuecomment-7170612657) **Independent verification of head `68e09ee6e84d521698e504b3dfda833500a111a9`** on `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca` (test-only PR; merges cleanly, fast-forward). **Environment:** Windows 11 Pro 10.0.26100, WARP (d3d10warp 10.0.26100.9818) only, rustc/cargo 1.98.1 (per rust-toolchain.toml), DXC 1.8.2502.11 / dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0 x64). `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` set for every run; `victory-gpu` tests were only run with `--features diagnostics` (without it the crate opens the default adapter). **Limits:** no physical GPU, no game files, no title-driven runs; this says nothing about behaviour on real hardware. - Focused: `cargo test -j 4 --locked -p victory-shader bcpack_nibble_split` with WARP + dxil.dll on PATH -> `emit::valu_tests::bcpack_nibble_split_matches_the_formats_function` 1 passed (512 cases: every byte, both orders; bit-exact compare of the packed 32-bit result). - Full crate: 268 passed, 3 failed, 3 ignored. `origin/main` baseline: 267 passed, 3 failed, 3 ignored. The same three fail in both: `synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out}`. They are lane/wave tests that fail on WARP; unrelated to this PR. - clippy `-p victory-shader --all-targets [--all-features] -- -D warnings`: clean. - **No production change, so no revert control.** Instead: (a) `origin/main` has no such test (0 matches); (b) `nibbles_reference` is textually identical to the formats crate's `nibbles`; (c) mutation check: changing the shader's zigzag shift amount (`vop3(0x116, 9, 129, ..)` -> `130`) makes the test fail (`nibbles[4, 0, 0, 0]`: got 0, want 1), so the shader body is really being compared. - Nits: the formats function is private, so the doc comment's `victory_formats::bcpack::nibbles` is a copy that can drift without any check (`victory-shader` does not depend on `victory-formats`); and the failure message says `hardware:` even when the run was on WARP. AI disclosure: independent verification by Claude Code / Claude Sonnet 5.5, run for a user; no game files, dumps or hashes involved.
Author
Owner

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

Automated triage for the maintainers.

Needs work. The new test in crates/victory-shader/src/emit/valu_tests.rs checks a hand-written shader against a copy of the private bcpack::nibbles helper. VIctory never runs that helper as console code, so the test mostly checks that the hand-written shader matches the copy. The translator behaviour it touches (v_bfe_u32, v_lshl_or_b32, v_lshrrev_b32, v_xor_b32, v_cndmask_b32) is basic and already exercised by instruction-level tests such as bfe_signed_and_unsigned_match_rdna2. The copied helper can also drift from the formats crate unnoticed, since victory-shader does not depend on it.

What would change the verdict: rework it as a test of a specific instruction edge case that the existing valu_tests.rs/semantics_tests.rs cases do not cover, named after the instruction, with expected values from the public RDNA ISA rather than a copied CPU helper. A failure on main before a fix would make the value obvious.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2656#issuecomment-7176225882) <!-- victory-triage v1 head=68e09ee6e84d521698e504b3dfda833500a111a9 verdict=needs-work at=2026-11-25T22:21:30Z --> Automated triage for the maintainers. **Needs work.** The new test in `crates/victory-shader/src/emit/valu_tests.rs` checks a hand-written shader against a copy of the private `bcpack::nibbles` helper. VIctory never runs that helper as console code, so the test mostly checks that the hand-written shader matches the copy. The translator behaviour it touches (`v_bfe_u32`, `v_lshl_or_b32`, `v_lshrrev_b32`, `v_xor_b32`, `v_cndmask_b32`) is basic and already exercised by instruction-level tests such as `bfe_signed_and_unsigned_match_rdna2`. The copied helper can also drift from the formats crate unnoticed, since `victory-shader` does not depend on it. What would change the verdict: rework it as a test of a specific instruction edge case that the existing `valu_tests.rs`/`semantics_tests.rs` cases do not cover, named after the instruction, with expected values from the public RDNA ISA rather than a copied CPU helper. A failure on `main` before a fix would make the value obvious. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2656/head:github-bot/gh-2656'
git switch 'github-bot/gh-2656'

Merge

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