Shader tests: translate XMA float samples to signed PCM16 #2698

Open
Dathinel wants to merge 1 commit from upstream-pr/2700 into main
Dathinel commented 2026-11-25 18:27:22 +00:00 (Migrated from github.com)

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


Translates the XMA decoder's float-to-PCM16 conversion into a synthetic console compute shader. Ties round away from zero, out-of-range samples saturate, and NaN converts to zero.

The GPU test covers 66 inputs, including adjacent floats on either side of half-integer thresholds, both signs of quiet and signaling NaNs, and infinities. Its expected values use exact scaling in f64 and Rust's saturating integer cast. I also compiled the private XMA helper from base 13f91ca and compared it with that oracle on 262,154 CPU inputs.

On Windows, cargo test --locked -p victory-shader --features host --lib xma_sample_to_i16_handles_ties_and_saturation -- --nocapture passed on the RTX 3050 Laptop and WARP in 3.83 s. Four local mutations failed on hardware: removing the NaN fix, rounding either sign of tie toward zero, and lowering the positive saturation limit by one. Targeted Clippy, formatting of the new code and the staged asset check passed. The full workspace suite was not run.

AI-assisted. Claude Code wrote the original synthetic shader and reviewed this port. Codex ported it, added the independent oracle and ran the checks.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5496884689 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2700). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T18:27:22Z. --- Translates the XMA decoder's float-to-PCM16 conversion into a synthetic console compute shader. Ties round away from zero, out-of-range samples saturate, and NaN converts to zero. The GPU test covers 66 inputs, including adjacent floats on either side of half-integer thresholds, both signs of quiet and signaling NaNs, and infinities. Its expected values use exact scaling in f64 and Rust's saturating integer cast. I also compiled the private XMA helper from base `13f91ca` and compared it with that oracle on 262,154 CPU inputs. On Windows, `cargo test --locked -p victory-shader --features host --lib xma_sample_to_i16_handles_ties_and_saturation -- --nocapture` passed on the RTX 3050 Laptop and WARP in 3.83 s. Four local mutations failed on hardware: removing the NaN fix, rounding either sign of tie toward zero, and lowering the positive saturation limit by one. Targeted Clippy, formatting of the new code and the staged asset check passed. The full workspace suite was not run. AI-assisted. Claude Code wrote the original synthetic shader and reviewed this port. Codex ported it, added the independent oracle and ran the checks.
kotekompotek commented 2026-11-25 19:06:40 +00:00 (Migrated from github.com)

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


Thorough - the edge coverage (both sides of every half-integer tie, qNaN/sNaN both signs, infinities) plus four documented mutations on hardware give real confidence. Exact f64 scaling for the oracle is the right choice since f32 can't represent all i16 boundaries.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171554563 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2700#issuecomment-7171554563). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:54:01Z. --- Thorough - the edge coverage (both sides of every half-integer tie, qNaN/sNaN both signs, infinities) plus four documented mutations on hardware give real confidence. Exact f64 scaling for the oracle is the right choice since f32 can't represent all i16 boundaries.
oni-swr commented 2026-11-25 19:06:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T18:56:55Z.


Independent WARP/CPU verification (claim: Marvisak/VIctory#1633)

  • PR head: a684dbd41c2e7743ba6ed5118f08171ee5b21eab / origin/main: 13f91caee25f2fdf2c062be5f7a27f058e51cbca
  • State: OPEN, non-draft; git merge-tree --write-tree origin/main <head> merges cleanly; no prior oni-swr comment on this head.
  • Environment: Windows 11 Pro 10.0.26200, VICTORY_WARP=1 + VICTORY_D3D12_WARP=1 (WARP only, no physical GPU, no game files/dumps/retail hashes), dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0, via VICTORY_DXIL), rustc 1.98.1 (48a229cea 2026-09-01), debug profile, --locked.

Commands / results (baseline = origin/main, same environment)

cargo test -p victory-shader --locked
cargo test -p victory-gpu --locked
cargo clippy -p victory-shader --locked --all-targets
  • victory-shader: 268 passed / 3 failed / 3 ignored (+1, same 3 baseline failures). New test emit::valu_tests::xma_sample_to_i16_handles_ties_and_saturation ok.
  • victory-gpu: 195 / 0 / 1 (unchanged).
  • clippy: 0 warnings, 0 errors (baseline 0).
  • victory-shader baseline: 267 passed / 3 failed / 3 ignored. The 3 failures also fail on origin/main under WARP (identical set, not caused by this PR): 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. Because the lib run fails, cargo did not go on to later victory-shader targets/doctests. victory-gpu baseline: 195 passed / 0 failed / 1 ignored.

Negative control: test-only PR; the baseline lacks the test (267 vs 268 passed).

Code review: Test-only. Reference is (f64(sample) * 32768).round() as i16 (ties away from zero, saturating, NaN -> 0), exact for finite f32; cases include +-0, +-inf, NaN/sNaN payloads, denormals, max/min, and values just below/at/above each tie incl. the saturation edge. Strong coverage; no bugs found.

Not tested: physical GPU hardware (RX 7800 XT or any), retail game run, release build, other crates.

AI use: Claude Code (Claude Sonnet 5.5) ran the commands and reviewed the diff; the results above are from the actual runs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171618799 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2700#issuecomment-7171618799). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T18:56:55Z. --- **Independent WARP/CPU verification** (claim: Marvisak/VIctory#1633) - PR head: `a684dbd41c2e7743ba6ed5118f08171ee5b21eab` / `origin/main`: `13f91caee25f2fdf2c062be5f7a27f058e51cbca` - State: OPEN, non-draft; `git merge-tree --write-tree origin/main <head>` merges cleanly; no prior `oni-swr` comment on this head. - Environment: Windows 11 Pro 10.0.26200, `VICTORY_WARP=1` + `VICTORY_D3D12_WARP=1` (WARP only, no physical GPU, no game files/dumps/retail hashes), `dxil.dll` 1.8.2502.11 (Windows SDK 10.0.26100.0, via `VICTORY_DXIL`), rustc 1.98.1 (48a229cea 2026-09-01), debug profile, `--locked`. **Commands / results** (baseline = `origin/main`, same environment) ``` cargo test -p victory-shader --locked cargo test -p victory-gpu --locked cargo clippy -p victory-shader --locked --all-targets ``` - victory-shader: 268 passed / 3 failed / 3 ignored (+1, same 3 baseline failures). New test `emit::valu_tests::xma_sample_to_i16_handles_ties_and_saturation` ok. - victory-gpu: 195 / 0 / 1 (unchanged). - clippy: 0 warnings, 0 errors (baseline 0). - victory-shader baseline: 267 passed / 3 failed / 3 ignored. The 3 failures also fail on `origin/main` under WARP (identical set, not caused by this PR): `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`. Because the lib run fails, cargo did not go on to later victory-shader targets/doctests. victory-gpu baseline: 195 passed / 0 failed / 1 ignored. **Negative control:** test-only PR; the baseline lacks the test (267 vs 268 passed). **Code review:** Test-only. Reference is `(f64(sample) * 32768).round() as i16` (ties away from zero, saturating, NaN -> 0), exact for finite f32; cases include +-0, +-inf, NaN/sNaN payloads, denormals, max/min, and values just below/at/above each tie incl. the saturation edge. Strong coverage; no bugs found. **Not tested:** physical GPU hardware (RX 7800 XT or any), retail game run, release build, other crates. **AI use:** Claude Code (Claude Sonnet 5.5) ran the commands and reviewed the diff; the results above are from the actual runs.
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:20:23Z.


Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + dxil.dll verification and review of a684dbd4 (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_sample_to_i16_handles_ties_and_saturation -- --nocapture: 1 passed, 0 failed (dxil.dll validation + RTX 5090 hardware + WARP all executed cleanly).

Review Notes

  • Matches victory-formats/src/xma.rs::to_i16 across all 66 inputs (exact half ties, next_down/next_up, ±0.0, ±1.0, ±inf, subnormals, qNaN/sNaN -> 0, saturation) with exact assert_eq! assertions.
  • Clean zero-conflict 3-way git merge-tree across #2676, #2681, #2685, #2687, and #2700.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7172158660 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2700#issuecomment-7172158660). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T19:20:23Z. --- Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + `dxil.dll` verification and review of `a684dbd4` (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_sample_to_i16_handles_ties_and_saturation -- --nocapture`: **1 passed, 0 failed** (`dxil.dll` validation + RTX 5090 hardware + WARP all executed cleanly). ### Review Notes - Matches `victory-formats/src/xma.rs::to_i16` across all 66 inputs (exact half ties, `next_down`/`next_up`, `±0.0`, `±1.0`, `±inf`, subnormals, `qNaN`/`sNaN -> 0`, saturation) with exact `assert_eq!` assertions. - Clean zero-conflict 3-way `git merge-tree` across #2676, #2681, #2685, #2687, and #2700.
Marvisak commented 2026-11-25 23:06:08 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs work. The test is correct (the oracle is exact f64 scaling with a saturating cast, and the tie and NaN inputs are well chosen) and CI passes, but it is not clear what it adds:

  • It does not test the XMA float-to-PCM16 conversion in crates/victory-formats/src/xma.rs. That code runs on the CPU and is never translated. The test hand-writes a GFX10 sequence and checks it against its own oracle, so the name and comment describe something the test does not do.
  • The instructions it uses (v_mul_f32, v_trunc_f32, v_add/sub_f32, v_cmp_ge/le/u_f32, v_cndmask_b32, v_min/max_f32, v_cvt_i32_f32) are already probed opcode by opcode, including NaN and saturation edges, in crates/victory-shader/src/emit/semantics_tests.rs.

What would change the verdict: name the translator path this sequence covers that the existing probes miss, and word the test around that path. See also #2685 and #2687 (same pattern); one PR covering the untested paths would be easier to review.

CI: check passing on this head.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176204049 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2700#issuecomment-7176204049). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:18:43Z. --- <!-- victory-triage v1 head=a684dbd41c2e7743ba6ed5118f08171ee5b21eab verdict=needs-work at=2026-11-25T22:19:00Z --> Automated triage for the maintainers. **Needs work.** The test is correct (the oracle is exact f64 scaling with a saturating cast, and the tie and NaN inputs are well chosen) and CI passes, but it is not clear what it adds: - It does not test the XMA float-to-PCM16 conversion in `crates/victory-formats/src/xma.rs`. That code runs on the CPU and is never translated. The test hand-writes a GFX10 sequence and checks it against its own oracle, so the name and comment describe something the test does not do. - The instructions it uses (`v_mul_f32`, `v_trunc_f32`, `v_add/sub_f32`, `v_cmp_ge/le/u_f32`, `v_cndmask_b32`, `v_min/max_f32`, `v_cvt_i32_f32`) are already probed opcode by opcode, including NaN and saturation edges, in `crates/victory-shader/src/emit/semantics_tests.rs`. What would change the verdict: name the translator path this sequence covers that the existing probes miss, and word the test around that path. See also #2685 and #2687 (same pattern); one PR covering the untested paths would be easier to review. CI: `check` passing on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
cloph-dsp commented 2026-11-27 15:48:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T15:48:29Z.


Independent CPU-only verification on Windows / Rust 1.100.0 / MSVC.

  • PR head: a684dbd41c2e7743ba6ed5118f08171ee5b21eab, merge base 13f91caee25f2fdf2c062be5f7a27f058e51cbca.
  • Command: cargo test --locked -p victory-shader --lib -- emit::valu_tests::xma_sample_to_i16_handles_ties_and_saturation --exact --test-threads=1 --quiet
  • Result: test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 273 filtered out, exit 0.
  • Negative control: git grep -F -c xma_sample_to_i16_handles_ties_and_saturation 13f91cae -- . → exit 1 / 0 hits; present on PR head.
  • git diff --check 13f91cae HEAD → exit 0.
  • Caveat: only the named shader-lowering test was replayed; the WARP/hardware fallback path, full crate suite and real XMA audio data were not exercised.
  • GPU/driver: N/A (CPU-only test). No game data, assets, extracted shaders or DRM involved.
  • AI-assisted: Hy4 flash.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7222505917 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2700#issuecomment-7222505917). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T15:48:29Z. --- Independent CPU-only verification on Windows / Rust 1.100.0 / MSVC. - PR head: `a684dbd41c2e7743ba6ed5118f08171ee5b21eab`, merge base `13f91caee25f2fdf2c062be5f7a27f058e51cbca`. - Command: `cargo test --locked -p victory-shader --lib -- emit::valu_tests::xma_sample_to_i16_handles_ties_and_saturation --exact --test-threads=1 --quiet` - Result: `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 273 filtered out`, exit 0. - Negative control: `git grep -F -c xma_sample_to_i16_handles_ties_and_saturation 13f91cae -- .` → exit 1 / 0 hits; present on PR head. - `git diff --check 13f91cae HEAD` → exit 0. - Caveat: only the named shader-lowering test was replayed; the WARP/hardware fallback path, full crate suite and real XMA audio data were not exercised. - GPU/driver: N/A (CPU-only test). No game data, assets, extracted shaders or DRM involved. - AI-assisted: Hy4 flash.
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/2700:upstream-pr/2700'
git switch 'upstream-pr/2700'

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