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

Open
Dathinel wants to merge 1 commit from upstream-pr/2676 into main
Dathinel commented 2026-11-25 17:57:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T17:57:49Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6610518065 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2676). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T17:57:49Z. --- 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.
cloph-dsp commented 2026-11-25 19:06:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T18:12:59Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170602031 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7170602031). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T18:12:59Z. --- 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).
kotekompotek commented 2026-11-25 19:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:35:27Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171118863 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7171118863). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:35:27Z. --- 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.
fuzeofficlal commented 2026-11-25 20:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:19:42Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7172143428 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7172143428). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T19:19:42Z. --- 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.
Marvisak commented 2026-11-25 23:06:10 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176230764 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2676#issuecomment-7176230764). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:20:00Z. --- <!-- 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 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/2676:upstream-pr/2676'
git switch 'upstream-pr/2676'

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