Formats: read complete XMA bit windows in one step #3672

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3672 into main
andrewpozdnakov7-jpg commented 2026-11-28 05:18:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T05:18:28Z.


XMA's frame bit reader takes a complete five-byte window directly when available. Near the end of a frame it uses the existing zero-padded read. A bit-by-bit test checks all 65 offsets of a generated buffer, including windows that cross the last byte and the offset at the end.

Across 288 generated stereo frames at four sample rates and three transform modes, all 301,056 PCM samples matched, including the flush output. In 17 alternating runs per case on the local Windows CPU, the complete decode medians were 1.05–1.12x the baseline.

The formats suite reported 47 passed and five ignored. Strict formats Clippy and the asset policy passed.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding this change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5536983985 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3672). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T05:18:28Z. --- XMA's frame bit reader takes a complete five-byte window directly when available. Near the end of a frame it uses the existing zero-padded read. A bit-by-bit test checks all 65 offsets of a generated buffer, including windows that cross the last byte and the offset at the end. Across 288 generated stereo frames at four sample rates and three transform modes, all 301,056 PCM samples matched, including the flush output. In 17 alternating runs per case on the local Windows CPU, the complete decode medians were 1.05–1.12x the baseline. The formats suite reported 47 passed and five ignored. Strict formats Clippy and the asset policy passed. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding this change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 05:21:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T05:21:13Z.


Windows CI passed at f88e0e4, including Clippy on both build configurations and the repository test job. The 65 bit-offset checks and the generated PCM comparison in the description apply to this head.

I also combined this with the short-code lookup. In that stack the extra speedup was smaller, with complete decode medians of 1.00–1.05x. Several timing ranges overlapped. The next step is maintainer review.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding this change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7234615894 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3672#issuecomment-7234615894). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T05:21:13Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46111509177/job/140875851368) passed at `f88e0e4`, including Clippy on both build configurations and the repository test job. The 65 bit-offset checks and the generated PCM comparison in the description apply to this head. I also combined this with [the short-code lookup](https://github.com/Marvisak/VIctory/pull/3671#issuecomment-7234607890). In that stack the extra speedup was smaller, with complete decode medians of 1.00–1.05x. Several timing ranges overlapped. The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding this change into another commit. AI-assisted with OpenAI Codex.
Headache3318 commented 2026-11-28 05:29:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-28T05:29:28Z.


Independent Linux verification of this head (correctness only — the speed numbers below are the author's, not reproduced).

Tree: head f88e0e4dc5caf62d05f9baa503b8bdf87d28d487, base 63bcca43c6a00a758510398fa43096ce7e4f7df0, single commit, only crates/victory-formats/src/xma.rs.
Environment: Arch Linux x86_64, rustc 1.98.1 (48a229cea 2026-09-01), cargo test --locked -p victory-formats (native Linux, no wine, no GPU).

Results

  • head: ok. 47 passed; 0 failed; 5 ignored — xma::tests::frame_bit_window_matches_bit_by_bit_reading ... ok
  • base 63bcca4: ok. 46 passed; 0 failed; 5 ignored — the delta is exactly the one new equivalence test, and nothing on base fails on this host, so nothing is hidden behind it.
  • Your reported 47 passed / 5 ignored reproduces exactly on Linux.

Is the new test load-bearing for the fast path? I checked rather than assumed. Mutated only the fast-path return to a wrong shift (v << (24 + pos % 8) → v << (25 + pos % 8)), fallback untouched: the test panics with bit offset 0. Restoring the one token makes it green again. So the equivalence test genuinely exercises the five-byte window (offsets that take it) and would catch a wrong fast path, while offsets near the buffer end go through the padded fallback it also covers.

Perf claim: on this host the suite's total time is 0.30 s both at head and base (three alternating release runs each), too coarse to confirm the 1.05–1.12× decode medians; treating those as your Windows measurements, not reproduced here. The correctness evidence does not depend on them.

Nothing blocking from the Linux side. AI-assisted (Hermes Agent).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7234701195 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3672#issuecomment-7234701195). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-28T05:29:28Z. --- Independent Linux verification of this head (correctness only — the speed numbers below are the author's, not reproduced). **Tree:** head `f88e0e4dc5caf62d05f9baa503b8bdf87d28d487`, base `63bcca43c6a00a758510398fa43096ce7e4f7df0`, single commit, only `crates/victory-formats/src/xma.rs`. **Environment:** Arch Linux x86_64, rustc 1.98.1 (48a229cea 2026-09-01), `cargo test --locked -p victory-formats` (native Linux, no wine, no GPU). **Results** - head: `ok. 47 passed; 0 failed; 5 ignored` — `xma::tests::frame_bit_window_matches_bit_by_bit_reading ... ok` - base `63bcca4`: `ok. 46 passed; 0 failed; 5 ignored` — the delta is exactly the one new equivalence test, and nothing on base fails on this host, so nothing is hidden behind it. - Your reported 47 passed / 5 ignored reproduces exactly on Linux. **Is the new test load-bearing for the fast path?** I checked rather than assumed. Mutated only the fast-path return to a wrong shift (`v << (24 + pos % 8)` → `v << (25 + pos % 8)`), fallback untouched: the test panics with `bit offset 0`. Restoring the one token makes it green again. So the equivalence test genuinely exercises the five-byte window (offsets that take it) and would catch a wrong fast path, while offsets near the buffer end go through the padded fallback it also covers. **Perf claim:** on this host the suite's total time is 0.30 s both at head and base (three alternating release runs each), too coarse to confirm the 1.05–1.12× decode medians; treating those as your Windows measurements, not reproduced here. The correctness evidence does not depend on them. Nothing blocking from the Linux side. AI-assisted (Hermes Agent).
cloph-dsp commented 2026-11-28 10:43:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T10:43:08Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3672 at head f88e0e4dc5caf62d05f9baa503b8bdf87d28d487, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-formats --lib -- xma::tests::frame_bit_window_matches_bit_by_bit_reading --exact --test-threads=1 --quiet → 1 passed, 0 failed, 51 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check 63bcca4 HEAD clean (1 file, +21/-1).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only XMA format test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7238076690 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3672#issuecomment-7238076690). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T10:43:08Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3672 at head `f88e0e4dc5caf62d05f9baa503b8bdf87d28d487`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-formats --lib -- xma::tests::frame_bit_window_matches_bit_by_bit_reading --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 51 filtered, exit 0. - `git grep -F` for the test name on the base returned no match (test is new on this PR); `git diff --check 63bcca4 HEAD` clean (1 file, +21/-1). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only XMA format test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
Headache3318 commented 2026-11-28 11:04:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-28T11:04:30Z.


@cloph-dsp thanks — Windows and Linux now agree at f88e0e4: your one-test replay + our Linux run (full crate: 47/0/5 at head, 46/0/5 at base, delta exactly the new equivalence test) leave no divergence. Also on the Linux side we proved the test load-bearing: corrupting only the fast-path shift (v << (24 + pos % 8) → v << (25 + …)) makes it panic at bit offset 0, and restoring the token turns it green. Two hosts, two platforms, one verdict: LGTM. (AI-assisted, Hermes Agent)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7238309937 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3672#issuecomment-7238309937). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-28T11:04:30Z. --- @cloph-dsp thanks — Windows and Linux now agree at `f88e0e4`: your one-test replay + our Linux run (full crate: 47/0/5 at head, 46/0/5 at base, delta exactly the new equivalence test) leave no divergence. Also on the Linux side we proved the test load-bearing: corrupting only the fast-path shift (`v << (24 + pos % 8)` → `v << (25 + …)`) makes it panic at `bit offset 0`, and restoring the token turns it green. Two hosts, two platforms, one verdict: LGTM. (AI-assisted, Hermes Agent)
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/3672:upstream-pr/3672'
git switch 'upstream-pr/3672'

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