Shader tests: translate the signed BCPack index residual sum #2676

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

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

Adds a synthetic console compute shader for BCPack’s add_index. It aligns the residual and predictor to their own widths, adds modulo 2¹⁶, then sign-extends the result. The test compares the emitted shader with a copy of the private Rust helper, verified identical on base 13f91ca.

170 inputs cover all residual widths 0–16, both directions of signed wraparound, and invalid predictor widths. Width 48 matters: its shift count wraps to zero on the GPU. Removing the predictor-width check passed the earlier cases but returned −1 instead of 0 for that input. Replacing the arithmetic shift with a logical shift also failed on hardware.

cargo test --locked -p victory-shader --features host --lib bcpack_index_residual_sum -- --nocapture passed on the RTX 3050 Laptop and WARP (10.28 s). Targeted Clippy and the staged asset check passed. The full workspace was not run.

AI-assisted. Claude Code wrote the original shader and identified the missing width case during review. Codex ported it and ran the hardware checks.

**@⁠Dathinel** on GitHub · 2026-11-25 17:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2676) `Dathinel:shader-tests/victory-bcpack-add-index` → `main` · +76 −0 · 1 files · 1 commits · open Adds a synthetic console compute shader for BCPack’s `add_index`. It aligns the residual and predictor to their own widths, adds modulo 2¹⁶, then sign-extends the result. The test compares the emitted shader with a copy of the private Rust helper, verified identical on base `13f91ca`. 170 inputs cover all residual widths 0–16, both directions of signed wraparound, and invalid predictor widths. Width 48 matters: its shift count wraps to zero on the GPU. Removing the predictor-width check passed the earlier cases but returned −1 instead of 0 for that input. Replacing the arithmetic shift with a logical shift also failed on hardware. `cargo test --locked -p victory-shader --features host --lib bcpack_index_residual_sum -- --nocapture` passed on the RTX 3050 Laptop and WARP (10.28 s). Targeted Clippy and the staged asset check passed. The full workspace was not run. AI-assisted. Claude Code wrote the original shader and identified the missing width case during review. Codex ported it and ran the hardware checks.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:47 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 18:12 UTC · original

Independent Windows WARP verification of PR #2676 (head 6f3368d), claim PR-2676-BCPACK-INDEX-RESIDUAL-SUM on #1633.

Toolchain: rustc/cargo 1.100.0, Windows MSVC, VICTORY_WARP=1 with dxil.dll from Windows SDK 10.0.26100.0 on PATH. Synthetic inputs only, no game data, no source edits.

  • cargo test --locked -p victory-shader --lib emit::valu_tests::bcpack_index_residual_sum_matches_the_formats_function -- --exact --test-threads=1 -> 1 passed, 0 failed, 273 filtered.
  • Negative control on merge base / current origin/main 13f91ca: the same filter reports 0 tests (the new test is absent).

No bug found. AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-25 18:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7170602031) Independent Windows WARP verification of PR #2676 (head `6f3368d`), claim `PR-2676-BCPACK-INDEX-RESIDUAL-SUM` on #1633. Toolchain: rustc/cargo 1.100.0, Windows MSVC, `VICTORY_WARP=1` with `dxil.dll` from Windows SDK 10.0.26100.0 on PATH. Synthetic inputs only, no game data, no source edits. - `cargo test --locked -p victory-shader --lib emit::valu_tests::bcpack_index_residual_sum_matches_the_formats_function -- --exact --test-threads=1` -> **1 passed**, 0 failed, 273 filtered. - Negative control on merge base / current `origin/main` `13f91ca`: the same filter reports **0 tests** (the new test is absent). No bug found. AI-assisted (Hy4 flash).
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:35 UTC · original

Solid coverage - residual width 0, ref-width out of range, and the width-48 shift-wraparound are exactly the cases a naive port gets wrong; the 48 case specifically forces the validity check to clear refv rather than relying on GPU shift behaviour.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7171118863) Solid coverage - residual width 0, ref-width out of range, and the width-48 shift-wraparound are exactly the cases a naive port gets wrong; the 48 case specifically forces the validity check to clear refv rather than relying on GPU shift behaviour.
Author
Owner

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

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + dxil.dll verification and review of 6f3368dc (on 13f91ca):

Verification (rustc 1.98.1 MSVC, Windows SDK 10.0.26100.0 dxil.dll)

  • cargo xtask policy: 184 files ok.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings and --features host: 0 warnings.
  • cargo test --locked -p victory-shader --features host --lib bcpack_index_residual_sum -- --nocapture: 1 passed, 0 failed (dxil.dll validation + RTX 5090 hardware + WARP all executed cleanly).

Review Notes

  • add_index_reference matches victory-formats/src/bcpack.rs::add_index verbatim across all 170 test cases (bits = 0..=16, out-of-range ref_bits including 48, and signed 16-bit wraparound) with exact u32 equality assertions.
  • Inserts at a disjoint anchor in valu_tests.rs, so it merges cleanly alongside #2681, #2685, #2687, and #2700.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7172143428) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + `dxil.dll` verification and review of `6f3368dc` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC, Windows SDK `10.0.26100.0` `dxil.dll`) - `cargo xtask policy`: **184 files ok**. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` and `--features host`: **0 warnings**. - `cargo test --locked -p victory-shader --features host --lib bcpack_index_residual_sum -- --nocapture`: **1 passed, 0 failed** (`dxil.dll` validation + RTX 5090 hardware + WARP all executed cleanly). ### Review Notes - `add_index_reference` matches `victory-formats/src/bcpack.rs::add_index` verbatim across all 170 test cases (`bits = 0..=16`, out-of-range `ref_bits` including `48`, and signed 16-bit wraparound) with exact `u32` equality assertions. - Inserts at a disjoint anchor in `valu_tests.rs`, so it merges cleanly alongside #2681, #2685, #2687, and #2700.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:20 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::add_index helper. VIctory never runs that helper as console code, so the test mostly checks that the hand-written shader matches the copy, and the copy can drift from the formats crate unnoticed. The one translator property it hits, shift counts taken modulo 32 for v_lshlrev_b32/v_ashrrev_i32 (the width-48 case), is generic instruction semantics. As written, that case passes because the shader's own range check clears the value, not because of the translator.

What would change the verdict: a focused test of the instruction edge case (for example, shift counts of 32 and above for the VALU shifts, if valu_tests.rs/semantics_tests.rs do not already cover them), named after the instruction, with expected values from the public RDNA ISA rather than a copied CPU helper.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7176230764) <!-- victory-triage v1 head=6f3368dcaad164b1aea94d1f6c162b23a76bbc78 verdict=needs-work at=2026-11-25T22:22: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::add_index` helper. VIctory never runs that helper as console code, so the test mostly checks that the hand-written shader matches the copy, and the copy can drift from the formats crate unnoticed. The one translator property it hits, shift counts taken modulo 32 for `v_lshlrev_b32`/`v_ashrrev_i32` (the width-48 case), is generic instruction semantics. As written, that case passes because the shader's own range check clears the value, not because of the translator. What would change the verdict: a focused test of the instruction edge case (for example, shift counts of 32 and above for the VALU shifts, if `valu_tests.rs`/`semantics_tests.rs` do not already cover them), named after the instruction, with expected values from the public RDNA ISA rather than a copied CPU helper. --- _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/2676/head:github-bot/gh-2676'
git switch 'github-bot/gh-2676'

Merge

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