Shader tests: translate XMA integer log2 across both input words #2685

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

@⁠Dathinel on GitHub · 2026-11-25 18:10 UTC · original
Dathinel:shader-tests/victory-xma-log2 → main · +34 −0 · 1 files · 1 commits · open

Adds a six-instruction synthetic compute shader for the XMA decoder’s integer log2 helper. On a 64-bit host, the shader selects the high word when nonzero, counts leading zeros in the selected word, and maps zero to zero.

The test covers 192 distinct inputs, including both neighbours of every power of two, mixed high and low words, and the unsigned maximum. Expected results use Rust’s integer logarithm with an explicit zero case. I checked that oracle separately against the private XMA helper on 65,536 generated CPU inputs and all power-of-two boundaries.

Tested on Windows with the RTX 3050 Laptop and WARP using cargo test --locked -p victory-shader --features host --lib xma_integer_log2_handles_both_words -- --nocapture. Removing the zero guard returned 32 instead of 0. Forcing the low word returned 63 instead of 32 for 0x1_ffff_ffff. Both mutations failed on hardware. Targeted Clippy, formatting of the added lines and the staged asset-policy check passed. The full workspace suite was not run.

AI-assisted. Claude Code wrote the original single-word translation and reviewed the two-word implementation. Codex implemented the port and ran the checks.

**@⁠Dathinel** on GitHub · 2026-11-25 18:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2685) `Dathinel:shader-tests/victory-xma-log2` → `main` · +34 −0 · 1 files · 1 commits · open Adds a six-instruction synthetic compute shader for the XMA decoder’s integer log2 helper. On a 64-bit host, the shader selects the high word when nonzero, counts leading zeros in the selected word, and maps zero to zero. The test covers 192 distinct inputs, including both neighbours of every power of two, mixed high and low words, and the unsigned maximum. Expected results use Rust’s integer logarithm with an explicit zero case. I checked that oracle separately against the private XMA helper on 65,536 generated CPU inputs and all power-of-two boundaries. Tested on Windows with the RTX 3050 Laptop and WARP using `cargo test --locked -p victory-shader --features host --lib xma_integer_log2_handles_both_words -- --nocapture`. Removing the zero guard returned 32 instead of 0. Forcing the low word returned 63 instead of 32 for `0x1_ffff_ffff`. Both mutations failed on hardware. Targeted Clippy, formatting of the added lines and the staged asset-policy check passed. The full workspace suite was not run. AI-assisted. Claude Code wrote the original single-word translation and reviewed the two-word implementation. Codex implemented the port and ran the checks.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:00 +00:00
Author
Owner

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

Independent verification (review, not a task claim) — covered by the existing claim on #1633.

  • PR head: c54b00ea0fa6ce6185121b3558edf190bfbbbcd0 (OPEN, non-draft, merges cleanly; merge-base == origin/main)
  • origin/main: 13f91caee25f2fdf2c062be5f7a27f058e51cbca
  • Environment: Windows 11, VICTORY_WARP=1, VICTORY_D3D12_WARP=1, dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), WARP only (physical GPU not used), no game files.

Commands and results

  • cargo test --locked -p victory-shader --features host --lib xma_integer_log2_handles_both_words -- --nocapture → 1 passed, 0 failed, 0 ignored. With VICTORY_WARP=1 both the "hardware" and "warp" passes in run_cases go through WARP, so the test really ran and was not skipped.
  • cargo test --locked -p victory-shader --features host (full) → 268 passed, 3 failed, 3 ignored. The same 3 fail on unmodified origin/main (267 passed, 3 failed, 3 ignored), so they are pre-existing WARP failures unrelated to this PR: synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number, synthetic_tests::gathers_at_a_level_match_the_hardware, synthetic_tests::permutes_read_the_lane_named_and_zero_from_lanes_left_out.
  • cargo clippy --locked -p victory-shader --features host --all-targets → clean, no warnings.

Negative control (the PR only adds a test, so I mutated the test shader on the PR head, then restored it)

  • Removing the v_max_u32 v5, v5, 1 zero guard → FAILED: hardware: log2(0x0) left 32, right 0.
  • Selecting the low word always (v_cndmask_b32 v5, v1, v1, vcc) → FAILED: log2(0x1ffffffff) left 63, right 32.

Review notes

  • The shader is correct: select the high word if nonzero, then 31 or 63 minus ffbh of the selected word, with the word clamped to at least 1 so zero maps to 0. This agrees with checked_ilog2().unwrap_or(0).
  • Coverage is good: 192 distinct inputs, both neighbours of every power of two, mixed high/low words and u64::MAX.
  • No production code is changed. I found no bugs.

AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 18:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2685#issuecomment-7170912952) **Independent verification (review, not a task claim)** — covered by the existing claim on #1633. - PR head: `c54b00ea0fa6ce6185121b3558edf190bfbbbcd0` (OPEN, non-draft, merges cleanly; merge-base == `origin/main`) - `origin/main`: `13f91caee25f2fdf2c062be5f7a27f058e51cbca` - Environment: Windows 11, `VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`, `dxil.dll` 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), WARP only (physical GPU not used), no game files. **Commands and results** - `cargo test --locked -p victory-shader --features host --lib xma_integer_log2_handles_both_words -- --nocapture` → 1 passed, 0 failed, 0 ignored. With `VICTORY_WARP=1` both the "hardware" and "warp" passes in `run_cases` go through WARP, so the test really ran and was not skipped. - `cargo test --locked -p victory-shader --features host` (full) → 268 passed, 3 failed, 3 ignored. The same 3 fail on unmodified `origin/main` (267 passed, 3 failed, 3 ignored), so they are pre-existing WARP failures unrelated to this PR: `synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number`, `synthetic_tests::gathers_at_a_level_match_the_hardware`, `synthetic_tests::permutes_read_the_lane_named_and_zero_from_lanes_left_out`. - `cargo clippy --locked -p victory-shader --features host --all-targets` → clean, no warnings. **Negative control** (the PR only adds a test, so I mutated the test shader on the PR head, then restored it) - Removing the `v_max_u32 v5, v5, 1` zero guard → FAILED: `hardware: log2(0x0)` left 32, right 0. - Selecting the low word always (`v_cndmask_b32 v5, v1, v1, vcc`) → FAILED: `log2(0x1ffffffff)` left 63, right 32. **Review notes** - The shader is correct: select the high word if nonzero, then 31 or 63 minus `ffbh` of the selected word, with the word clamped to at least 1 so zero maps to 0. This agrees with `checked_ilog2().unwrap_or(0)`. - Coverage is good: 192 distinct inputs, both neighbours of every power of two, mixed high/low words and `u64::MAX`. - No production code is changed. I found no bugs. AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).
Author
Owner

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

The shader is faithful - high-word selection via cmp+cndmask, max(v,1) so log2(0) maps to 0, and the 63/31 base matching the selected word. Boundary coverage at every power of two plus the mutation results in the description give confidence the ffbh path is really being tested.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2685#issuecomment-7171180367) The shader is faithful - high-word selection via cmp+cndmask, max(v,1) so log2(0) maps to 0, and the 63/31 base matching the selected word. Boundary coverage at every power of two plus the mutation results in the description give confidence the ffbh path is really being tested.
Author
Owner

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

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + dxil.dll verification and review of c54b00ea (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: 0 warnings.
  • cargo test --locked -p victory-shader --features host --lib xma_integer_log2_handles_both_words -- --nocapture: 1 passed, 0 failed (dxil.dll validation + RTX 5090 hardware + WARP all executed cleanly).

Review Notes

  • Matches victory-formats/src/xma.rs::log2 across all 192 inputs (bit powers 0..64 ±1, u64::MAX, mixed high/low words, and 0 -> 0 via v_max_u32) with exact assert_eq! assertions.
  • Clean zero-conflict 3-way git merge-tree across #2676, #2681, #2685, #2687, and #2700.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2685#issuecomment-7172157288) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + `dxil.dll` verification and review of `c54b00ea` (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`: **0 warnings**. - `cargo test --locked -p victory-shader --features host --lib xma_integer_log2_handles_both_words -- --nocapture`: **1 passed, 0 failed** (`dxil.dll` validation + RTX 5090 hardware + WARP all executed cleanly). ### Review Notes - Matches `victory-formats/src/xma.rs::log2` across all 192 inputs (bit powers `0..64` ±1, `u64::MAX`, mixed high/low words, and `0 -> 0` via `v_max_u32`) with exact `assert_eq!` assertions. - Clean zero-conflict 3-way `git merge-tree` across #2676, #2681, #2685, #2687, and #2700.
Author
Owner

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

Automated triage for the maintainers.

Needs work. The test is correct (the expected values come from checked_ilog2, not from the code under test) and CI passes, but it is not clear what it adds:

  • It does not test victory_formats::xma::log2. That helper runs on the CPU and nothing turns it into a shader. The test hand-writes a six-instruction GFX10 sequence and checks it against Rust's ilog2, so the doc comment ("Translate the 64-bit host's victory_formats::xma::log2") describes something the test does not do.
  • The instructions it uses (v_cmp_ne_u32, v_cndmask_b32, v_max_u32, v_ffbh_u32, v_sub_nc_u32) are already probed opcode by opcode, with edge inputs, in crates/victory-shader/src/emit/semantics_tests.rs (e.g. ffbh there).

What would change the verdict: name the translator path this sequence covers that the existing per-opcode probes miss (for example a VCC-from-VOP3 compare feeding v_cndmask with inline constants, if that is uncovered), and word the test around that path instead of the CPU helper. The same applies to the sibling PRs #2687 and #2700; one PR that covers the untested paths would be easier to review than one per helper.

CI: check passing on this head.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2685#issuecomment-7176195007) <!-- victory-triage v1 head=c54b00ea0fa6ce6185121b3558edf190bfbbbcd0 verdict=needs-work at=2026-11-25T22:18:20Z --> Automated triage for the maintainers. **Needs work.** The test is correct (the expected values come from `checked_ilog2`, not from the code under test) and CI passes, but it is not clear what it adds: - It does not test `victory_formats::xma::log2`. That helper runs on the CPU and nothing turns it into a shader. The test hand-writes a six-instruction GFX10 sequence and checks it against Rust's `ilog2`, so the doc comment ("Translate the 64-bit host's `victory_formats::xma::log2`") describes something the test does not do. - The instructions it uses (`v_cmp_ne_u32`, `v_cndmask_b32`, `v_max_u32`, `v_ffbh_u32`, `v_sub_nc_u32`) are already probed opcode by opcode, with edge inputs, in `crates/victory-shader/src/emit/semantics_tests.rs` (e.g. `ffbh` there). What would change the verdict: name the translator path this sequence covers that the existing per-opcode probes miss (for example a VCC-from-VOP3 compare feeding `v_cndmask` with inline constants, if that is uncovered), and word the test around that path instead of the CPU helper. The same applies to the sibling PRs #2687 and #2700; one PR that covers the untested paths would be easier to review than one per helper. CI: `check` passing on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 15:00 UTC · original

Independent verification of head c54b00e on Windows, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-shader --lib -- emit::valu_tests::xma_integer_log2_handles_both_words --exact — 1 passed, 0 failed, 273 filtered.
  • git diff --check against merge base — clean.

CPU-only synthetic instruction case; worktree-local CARGO_TARGET_DIR. AI-assisted (Hy4 flash). GPU/driver N/A. No game data used.

**@⁠cloph-dsp** on GitHub · 2026-11-26 15:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2685#issuecomment-7195639324) Independent verification of head `c54b00e` on Windows, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-shader --lib -- emit::valu_tests::xma_integer_log2_handles_both_words --exact` — 1 passed, 0 failed, 273 filtered. - `git diff --check` against merge base — clean. CPU-only synthetic instruction case; worktree-local `CARGO_TARGET_DIR`. AI-assisted (Hy4 flash). GPU/driver N/A. No game data used.
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/2685/head:github-bot/gh-2685'
git switch 'github-bot/gh-2685'

Merge

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