Apply outstanding XMA sample skips to the final overlap #2708

Open
VlREX wants to merge 1 commit from upstream-pr/2710 into main
VlREX commented 2026-11-25 18:37:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-25T18:37:12Z.


A one-frame XMA voice emits 512 samples plus a 256-sample overlap per channel. With a start skip of five subframes (640 samples), the decoder previously queued 256 samples instead of the remaining 128 because flushing bypassed the skip counter. Route flushed samples through the same skip handling as ordinary frame data. A synthetic one-frame test covers skips of four through seven subframes, including an empty tail. Confirmed the five-subframe case failed before the fix. All nine audio module tests pass in an isolated Windows GNU run using the real XMA decoder. This concerns PCM queued by the voice, complementary to the ring-writer fix in #2709.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5497029457 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710). Originally posted by [VlREX](https://github.com/VlREX) on 2026-11-25T18:37:12Z. --- A one-frame XMA voice emits 512 samples plus a 256-sample overlap per channel. With a start skip of five subframes (640 samples), the decoder previously queued 256 samples instead of the remaining 128 because flushing bypassed the skip counter. Route flushed samples through the same skip handling as ordinary frame data. A synthetic one-frame test covers skips of four through seven subframes, including an empty tail. Confirmed the five-subframe case failed before the fix. All nine audio module tests pass in an isolated Windows GNU run using the real XMA decoder. This concerns PCM queued by the voice, complementary to the ring-writer fix in #2709.
kotekompotek commented 2026-11-25 19:06:37 +00:00 (Migrated from github.com)

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


Clean unification - routing the flush tail through append_samples applies the outstanding skip in the same units (skip in subframes, pcm in samples x channels, decrement by skip/channels). The 4..=7 sweep covers the case where the tail is entirely consumed by the skip.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171487940 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#issuecomment-7171487940). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:51:00Z. --- Clean unification - routing the flush tail through append_samples applies the outstanding skip in the same units (skip in subframes, pcm in samples x channels, decrement by skip/channels). The 4..=7 sweep covers the case where the tail is entirely consumed by the skip.
oni-swr commented 2026-11-25 19:06:40 +00:00 (Migrated from github.com)

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


Independent WARP/CPU verification

PR head: fdfd7c25fdf2882507d051382fe6cb8b6e5d04c3
Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, WARP only (VICTORY_WARP=1 + VICTORY_D3D12_WARP=1), dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0), no physical GPU touched, no game files/dumps/retail hashes. CARGO_TARGET_DIR on D:, --locked throughout. origin/main = 13f91caee25f2fdf2c062be5f7a27f058e51cbca; merges cleanly (git merge-tree); open, non-draft, no oni-swr comment on this head.

Commands / results (cargo test --locked -p victory-formats -p victory-hle):

  • Baseline: victory-formats 38/0/5 ignored; victory-hle 146 passed / 0 failed.
  • PR: victory-formats 38/0/5 ignored; victory-hle 147 passed / 0 failed (+a_start_skip_can_reach_into_the_final_overlap).
  • cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings → clean.
  • Negative control: reverting only the tail flush to voice.pcm.extend(tail) makes the new test FAIL at "skip 5 subframes" (audio.rs:1310); the other 146 pass.
    Baseline note: on the very first baseline victory-hle run, dstorage::tests::a_page_list_filled_after_its_request_starts failed once (assertion left==right); it passed 3/3 reruns in isolation and in a full rerun (146/146), so it looks like a flaky pre-existing test unrelated to this PR.

Review: no bugs found. append_samples is the old skip logic factored out (min clamps, whole-sample accounting by channels) and now also applies to the flushed overlap; the loop path's behavior is unchanged. The test sweeps skip = 4..7 subframes across the frame/overlap boundary including a fully-consumed tail (expected 0). The test_voice helper also dedups the loop test. channels is taken before flush — fine.

Not tested: physical hardware GPU, retail game run, release build.
AI use: Claude Code (Claude Sonnet 5.5). Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7171257593

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171559525 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#issuecomment-7171559525). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T18:54:14Z. --- ## Independent WARP/CPU verification **PR head:** `fdfd7c25fdf2882507d051382fe6cb8b6e5d04c3` **Environment:** Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, WARP only (`VICTORY_WARP=1` + `VICTORY_D3D12_WARP=1`), `dxil.dll` 1.8.2502.11 (Windows SDK 10.0.26100.0), no physical GPU touched, no game files/dumps/retail hashes. `CARGO_TARGET_DIR` on D:, `--locked` throughout. `origin/main` = `13f91caee25f2fdf2c062be5f7a27f058e51cbca`; merges cleanly (`git merge-tree`); open, non-draft, no `oni-swr` comment on this head. **Commands / results** (`cargo test --locked -p victory-formats -p victory-hle`): - Baseline: victory-formats 38/0/5 ignored; victory-hle 146 passed / 0 failed. - PR: victory-formats 38/0/5 ignored; victory-hle **147 passed** / 0 failed (+`a_start_skip_can_reach_into_the_final_overlap`). - `cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings` → clean. - **Negative control:** reverting only the tail flush to `voice.pcm.extend(tail)` makes the new test FAIL at "skip 5 subframes" (audio.rs:1310); the other 146 pass. Baseline note: on the very first baseline `victory-hle` run, `dstorage::tests::a_page_list_filled_after_its_request_starts` failed once (assertion left==right); it passed 3/3 reruns in isolation and in a full rerun (146/146), so it looks like a flaky pre-existing test unrelated to this PR. **Review:** no bugs found. `append_samples` is the old skip logic factored out (`min` clamps, whole-sample accounting by `channels`) and now also applies to the flushed overlap; the loop path's behavior is unchanged. The test sweeps skip = 4..7 subframes across the frame/overlap boundary including a fully-consumed tail (expected 0). The `test_voice` helper also dedups the loop test. `channels` is taken before `flush` — fine. **Not tested:** physical hardware GPU, retail game run, release build. **AI use:** Claude Code (Claude Sonnet 5.5). Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7171257593
fuzeofficlal commented 2026-11-25 20:06:21 +00:00 (Migrated from github.com)

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


Independent Windows 11 verification and review of fdfd7c2 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 184 files ok.
  • cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-formats: 38 passed, 0 failed, 5 ignored.
  • cargo test --locked -p victory-hle: 147 passed, 0 failed (lib, including a_start_skip_can_reach_into_the_final_overlap), plus fidelityfx (1) and no_dll_planting (1) clean.
  • 5-way XMA merge compatibility: verified clean zero-conflict sequential git merge-tree across the entire 5-PR stack #2694 + #2708 + #2709 + #2710 + #2714.

Review Notes

  • Reusing Voice::append_samples on decoder.flush(&mut tail) cleanly applies any remaining voice.skip into the 256-sample overlap tail without breaking channel interleaving (tail.len() == 256 * channels), and pairs directly with #2709 for skips >= 5 subframes. Clean and ready to merge.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7172581216 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#issuecomment-7172581216). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T19:38:49Z. --- Independent Windows 11 verification and review of `fdfd7c2` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **184 files ok**. - `cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings`: **0 warnings**. - `cargo test --locked -p victory-formats`: **38 passed, 0 failed, 5 ignored**. - `cargo test --locked -p victory-hle`: **147 passed, 0 failed** (`lib`, including `a_start_skip_can_reach_into_the_final_overlap`), plus `fidelityfx` (1) and `no_dll_planting` (1) clean. - **5-way XMA merge compatibility:** verified clean zero-conflict sequential `git merge-tree` across the entire 5-PR stack **#2694 + #2708 + #2709 + #2710 + #2714**. ### Review Notes - Reusing `Voice::append_samples` on `decoder.flush(&mut tail)` cleanly applies any remaining `voice.skip` into the 256-sample overlap tail without breaking channel interleaving (`tail.len() == 256 * channels`), and pairs directly with #2709 for skips `>= 5` subframes. Clean and ready to merge.
Marvisak commented 2026-11-25 23:06:16 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Merge candidate (recommend a look). The outstanding start skip in crates/victory-hle/src/modules/audio.rs was applied to decoded frames but not to the overlap tail that decode flushes when input runs out. A one-frame voice with a skip of five subframes therefore queued 256 tail samples instead of 128. The skip logic moves unchanged into Voice::append_samples and is used for both, so the loop path behaves exactly as before. The test sweeps skips of four to seven subframes across the frame/tail boundary, including a tail consumed entirely, and fails on main at five. test_voice also removes a duplicated struct literal from the loop test.

CI: check passing on this head. Merges cleanly with #2708, #2709 and #2714.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176293325 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#issuecomment-7176293325). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:23:01Z. --- <!-- victory-triage v1 head=fdfd7c25fdf2882507d051382fe6cb8b6e5d04c3 verdict=merge-candidate at=2026-11-25T22:23:30Z --> Automated triage for the maintainers. **Merge candidate (recommend a look).** The outstanding start skip in `crates/victory-hle/src/modules/audio.rs` was applied to decoded frames but not to the overlap tail that `decode` flushes when input runs out. A one-frame voice with a skip of five subframes therefore queued 256 tail samples instead of 128. The skip logic moves unchanged into `Voice::append_samples` and is used for both, so the loop path behaves exactly as before. The test sweeps skips of four to seven subframes across the frame/tail boundary, including a tail consumed entirely, and fails on main at five. `test_voice` also removes a duplicated struct literal from the loop test. CI: `check` passing on this head. Merges cleanly with #2708, #2709 and #2714. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 05:11:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T05:11:37Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-hle --lib modules::audio::: 9 passed, 0 failed (including new a_start_skip_can_reach_into_the_final_overlap).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068863741 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#pullrequestreview-6068863741). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T05:11:37Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-hle --lib modules::audio::`: **9 passed, 0 failed** (including new `a_start_skip_can_reach_into_the_final_overlap`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 13:04:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T12:09:57Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head fdfd7c2 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: a_start_skip_can_reach_into_the_final_overlap.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7191649785 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#issuecomment-7191649785). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T12:09:57Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head `fdfd7c2` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `a_start_skip_can_reach_into_the_final_overlap`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
fuzeofficlal commented 2026-11-27 02:23:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:23:27Z.

Review: APPROVED


Looks good to me — clean helper extraction that ensures outstanding start/loop sample skips are also applied to the flushed overlap tail at end-of-stream.

Review & Verification Notes

  • crates/victory-hle/src/modules/audio.rs: Voice::append_samples shares the exact same clamping and underflow-free skip accounting across normal decoded frames and decoder.flush(&mut tail), using decoder.channels() (always 1 or 2 per victory_formats::xma::Decoder) and returning !voice.pcm.is_empty() accurately when the tail is partially or completely skipped.
  • Verified locally merged cleanly onto origin/main (63bcca43):
    • cargo xtask policy passes (191 files ok).
    • cargo clippy -p victory-hle (--lib, --tests, and --features diagnostics --lib/--tests, -D warnings) is clean.
    • victory-hle modules::audio passes (9/9, including a_start_skip_can_reach_into_the_final_overlap) under both default and --features diagnostics builds.
<!-- greyfinch-sync:Marvisak/VIctory:review:6082663946 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#pullrequestreview-6082663946). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T02:23:27Z. **Review:** APPROVED --- Looks good to me — clean helper extraction that ensures outstanding start/loop sample skips are also applied to the flushed overlap tail at end-of-stream. ### Review & Verification Notes - `crates/victory-hle/src/modules/audio.rs`: `Voice::append_samples` shares the exact same clamping and underflow-free skip accounting across normal decoded frames and `decoder.flush(&mut tail)`, using `decoder.channels()` (always `1` or `2` per `victory_formats::xma::Decoder`) and returning `!voice.pcm.is_empty()` accurately when the tail is partially or completely skipped. - Verified locally merged cleanly onto `origin/main` (`63bcca43`): - `cargo xtask policy` passes (`191 files ok`). - `cargo clippy -p victory-hle` (`--lib`, `--tests`, and `--features diagnostics` `--lib`/`--tests`, `-D warnings`) is clean. - `victory-hle` `modules::audio` passes (`9/9`, including `a_start_skip_can_reach_into_the_final_overlap`) under both default and `--features diagnostics` builds.
andrewpozdnakov7-jpg commented 2026-11-28 16:34:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T16:34:43Z.


I checked this final-overlap fix together with #3631's channel-aware PCM output on current main (63bcca4). The tested branch 64100a0 preserves both original heads, fdfd7c2 and 92ba3fb.

The original one-frame test passes for start skips of four through seven subframes, including the empty tail. The extra stereo regression starts with a three-frame skip: an initial block consumes two whole left/right pairs, and the next block discards one more pair. The two remaining pairs read back in the expected order with both channels intact.

On Windows, 10 audio-module tests and all 14 active XMA tests passed, including the PCM flush and decoder-reset test. Strict Clippy and the asset policy passed. These checks use generated data.

The next step is author or maintainer review. Please retain the Git author on cherry-pick or rebase, or add a Co-authored-by trailer for andrewpozdnakov7-jpg [email protected] if folding the stereo regression into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242349966 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2710#issuecomment-7242349966). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T16:34:43Z. --- I checked this final-overlap fix together with #3631's channel-aware PCM output on current main (63bcca4). The [tested branch 64100a0](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/64100a080bda4d0b13258ed560d870ce0272494c) preserves both original heads, fdfd7c2 and 92ba3fb. The original one-frame test passes for start skips of four through seven subframes, including the empty tail. The extra stereo regression starts with a three-frame skip: an initial block consumes two whole left/right pairs, and the next block discards one more pair. The two remaining pairs read back in the expected order with both channels intact. On Windows, 10 audio-module tests and all 14 active XMA tests passed, including the PCM flush and decoder-reset test. Strict Clippy and the asset policy passed. These checks use generated data. The next step is author or maintainer review. Please retain the Git author on cherry-pick or rebase, or add a Co-authored-by trailer for andrewpozdnakov7-jpg <[email protected]> if folding the stereo regression into another commit. AI-assisted with OpenAI Codex.
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/2710:upstream-pr/2710'
git switch 'upstream-pr/2710'

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