Avoid publishing a silent XMA output block after a whole-frame skip #2709

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

@⁠VlREX on GitHub · 2026-11-25 18:35 UTC · original
VlREX:fix/xma-empty-output → main · +19 −3 · 1 files · 1 commits · open

A successful decoder step can consume a frame while dropping every sample due to the configured subframe skip. The ring writer previously padded an empty queue with 128 zero samples and advanced the write cursor. Yield to the next decoder pass when that step leaves the queue empty. This also avoids spinning on looping streams with no output. The synthetic mono ring test produced 2944 samples instead of 2816 before the fix. All nine audio module tests passed in an isolated Windows GNU run with the real XMA decoder. No game assets were used.

**@⁠VlREX** on GitHub · 2026-11-25 18:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709) `VlREX:fix/xma-empty-output` → `main` · +19 −3 · 1 files · 1 commits · open A successful decoder step can consume a frame while dropping every sample due to the configured subframe skip. The ring writer previously padded an empty queue with 128 zero samples and advanced the write cursor. Yield to the next decoder pass when that step leaves the queue empty. This also avoids spinning on looping streams with no output. The synthetic mono ring test produced 2944 samples instead of 2816 before the fix. All nine audio module tests passed in an isolated Windows GNU run with the real XMA decoder. No game assets were used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:31 +00:00
Author
Owner

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

Correct - a fully-skipped frame advancing the decoder without samples should not publish a 128-sample silent block. The empty-queue re-check keeps the ring writable for the next pass, and the loop is still bounded since decode() returns false when input exhausts.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709#issuecomment-7171484635) Correct - a fully-skipped frame advancing the decoder without samples should not publish a 128-sample silent block. The empty-queue re-check keeps the ring writable for the next pass, and the loop is still bounded since decode() returns false when input exhausts.
Author
Owner

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

Independent WARP/CPU verification

PR head: e52a80d34c8b1b2a4562899811e266e75c8f7c5f
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 (+1 new test, and the shared check_decoded_ring helper now also runs the original test).
  • cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings → clean.
  • Negative control: reverting the pump hunk fails the new skipping_a_whole_xma_frame_does_not_publish_a_silent_block (assert at audio.rs:1255) and, in the same run, three other xma tests that I believe failed as a cascade (shared test lock poisoned by the first panic); I did not isolate those.
    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. The pump change returns when decode made progress but produced no samples, so the ring is not advanced with a silent block. Residual risk: if a stream keeps producing empty decodes, each pump call makes at most one decode step, i.e. it relies on being called again; the test covers this with two pumps. Test strength is good (exact produced count adjusted by the skip).

Not tested: physical hardware GPU, retail game run, release build.
AI use: Claude Code (Claude Sonnet 5.5). Claim: #1633

**@⁠oni-swr** on GitHub · 2026-11-25 18:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709#issuecomment-7171558881) ## Independent WARP/CPU verification **PR head:** `e52a80d34c8b1b2a4562899811e266e75c8f7c5f` **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 (+1 new test, and the shared `check_decoded_ring` helper now also runs the original test). - `cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings` → clean. - **Negative control:** reverting the `pump` hunk fails the new `skipping_a_whole_xma_frame_does_not_publish_a_silent_block` (assert at audio.rs:1255) and, in the same run, three other xma tests that I believe failed as a cascade (shared test lock poisoned by the first panic); I did not isolate those. 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. The `pump` change returns when `decode` made progress but produced no samples, so the ring is not advanced with a silent block. Residual risk: if a stream keeps producing empty decodes, each `pump` call makes at most one decode step, i.e. it relies on being called again; the test covers this with two pumps. Test strength is good (exact `produced` count adjusted by the skip). **Not tested:** physical hardware GPU, retail game run, release build. **AI use:** Claude Code (Claude Sonnet 5.5). Claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633
Author
Owner

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

Independent Windows 11 verification and review of e52a80d (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 skipping_a_whole_xma_frame_does_not_publish_a_silent_block), 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

  • Checking !decode(context, voice) || voice.pcm.is_empty() in pump() prevents publishing a zero-filled 128-sample block when a whole-frame skip empties voice.pcm (safe because Decoder::decode emits 512 * channels and flush emits 256 * channels, both multiples of SAMPLES_PER_BLOCK = 128). Clean and ready to merge.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709#issuecomment-7172580576) Independent Windows 11 verification and review of `e52a80d` (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 `skipping_a_whole_xma_frame_does_not_publish_a_silent_block`), 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 - Checking `!decode(context, voice) || voice.pcm.is_empty()` in `pump()` prevents publishing a zero-filled 128-sample block when a whole-frame skip empties `voice.pcm` (safe because `Decoder::decode` emits `512 * channels` and `flush` emits `256 * channels`, both multiples of `SAMPLES_PER_BLOCK = 128`). Clean and ready to merge.
Author
Owner

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

Automated triage for the maintainers.

Merge candidate (recommend a look). In pump (crates/victory-hle/src/modules/audio.rs), a decode step that succeeds without queuing samples (a frame dropped entirely by the configured subframe skip, or an input switch) used to fall through and publish a block of 128 zero samples, advancing the title's write cursor. Now pump returns and leaves the ring writable. I checked that this cannot stall: the decoder thread runs pump at least every 2 ms (park_timeout in wake_decoder), and decode returns false once input is exhausted. The cost is one decode step per pass while frames are being skipped. The test reuses the existing ring test with a four-subframe skip and checks the exact produced count, which fails on main.

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


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709#issuecomment-7176286795) <!-- victory-triage v1 head=e52a80d34c8b1b2a4562899811e266e75c8f7c5f verdict=merge-candidate at=2026-11-25T22:24:00Z --> Automated triage for the maintainers. **Merge candidate (recommend a look).** In `pump` (`crates/victory-hle/src/modules/audio.rs`), a decode step that succeeds without queuing samples (a frame dropped entirely by the configured subframe skip, or an input switch) used to fall through and publish a block of 128 zero samples, advancing the title's write cursor. Now `pump` returns and leaves the ring writable. I checked that this cannot stall: the decoder thread runs `pump` at least every 2 ms (`park_timeout` in `wake_decoder`), and `decode` returns false once input is exhausted. The cost is one decode step per pass while frames are being skipped. The test reuses the existing ring test with a four-subframe skip and checks the exact produced count, which fails on main. CI: `check` passing on this head. Merges cleanly with #2708, #2710 and #2714. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 14:30 UTC · original · edited 2026-11-26 16:55 UTC

NVIDIA full-suite run, to go with the reports above by fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head e52a80d (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 first run, in a batch of back-to-back PR runs, gave 773 passed, 1 failed: frame::tests::waits_end_on_ticks_and_count_frames, a timing test. The 774/0 above is a solo rerun on the same head, where it passes. It looks timing-sensitive rather than caused by this PR: it also failed on #2371 earlier while two suites ran at once.
  • The new tests ran and passed: skipping_a_whole_xma_frame_does_not_publish_a_silent_block.
  • --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.
**@⁠futurepro62** on GitHub · 2026-11-26 14:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709#issuecomment-7194920083) · edited 2026-11-26 16:55 UTC NVIDIA full-suite run, to go with the reports above by fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head `e52a80d` (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 first run, in a batch of back-to-back PR runs, gave 773 passed, 1 failed: `frame::tests::waits_end_on_ticks_and_count_frames`, a timing test. The 774/0 above is a solo rerun on the same head, where it passes. It looks timing-sensitive rather than caused by this PR: it also failed on #2371 earlier while two suites ran at once. - The new tests ran and passed: `skipping_a_whole_xma_frame_does_not_publish_a_silent_block`. - `--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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 16:05 UTC · original · approved these changes

Reviewed e52a80d34c8b1b2a4562899811e266e75c8f7c5f (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 (rustc 1.98.1 MSVC).

Audit

  • crates/victory-hle/src/modules/audio.rs:509, :518: returning from pump() when (!decode(context, voice) || voice.pcm.is_empty()) prevents publishing a spurious 128-sample zero block and advancing the ring write cursor whenever a decode step consumes input without queuing samples (whole-frame subframe skips, loop-truncated skips, bad frames, or input-buffer switches). Because decode and flush produce multiples of SAMPLES_PER_BLOCK * channels, both mono and stereo remain block-aligned, and yielding on an empty decode prevents spinning inside pump() on looping zero-output streams while wake_decoder drives the next pass.

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-hle -p victory-formats --all-targets -- -D warnings (default & --all-features)
  • cargo test -p victory-formats --lib: 46 passed, 0 failed, 5 ignored
  • cargo test -p victory-hle --lib -- modules::audio::: 9/9 passed (including skipping_a_whole_xma_frame_does_not_publish_a_silent_block).
  • Additional probe verified skip_subframes = 1..=4 and confirmed that after the first xma().pump() with skip_subframes = 4, the write cursor remains 0, the ring remains writable (1), produced stays 0, and ring memory (0x55 sentinel) is untouched.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709#pullrequestreview-6077245292) · **approved these changes** Reviewed `e52a80d34c8b1b2a4562899811e266e75c8f7c5f` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 x64 (`rustc 1.98.1` MSVC). ### Audit - `crates/victory-hle/src/modules/audio.rs:509`, `:518`: returning from `pump()` when `(!decode(context, voice) || voice.pcm.is_empty())` prevents publishing a spurious 128-sample zero block and advancing the ring write cursor whenever a decode step consumes input without queuing samples (whole-frame subframe skips, loop-truncated skips, bad frames, or input-buffer switches). Because `decode` and `flush` produce multiples of `SAMPLES_PER_BLOCK * channels`, both mono and stereo remain block-aligned, and yielding on an empty decode prevents spinning inside `pump()` on looping zero-output streams while `wake_decoder` drives the next pass. ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-hle -p victory-formats --all-targets -- -D warnings` (default & `--all-features`) - `cargo test -p victory-formats --lib`: **46 passed, 0 failed, 5 ignored** - `cargo test -p victory-hle --lib -- modules::audio::`: **9/9 passed** (including `skipping_a_whole_xma_frame_does_not_publish_a_silent_block`). - Additional probe verified `skip_subframes = 1..=4` and confirmed that after the first `xma().pump()` with `skip_subframes = 4`, the write cursor remains `0`, the ring remains writable (`1`), `produced` stays `0`, and ring memory (`0x55` sentinel) is untouched.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 18:12 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Returning early when voice.pcm.is_empty() after decode avoids emitting a spurious silent block on a whole-frame skip (or input switch) while keeping the output ring writable for the next pump.
  • cargo test -p victory-hle --lib modules::audio:: -- --test-threads=1: 9 passed, 0 failed (including skipping_a_whole_xma_frame_does_not_publish_a_silent_block).
  • 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).

**@⁠Dukestar69** on GitHub · 2026-11-26 18:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2709#pullrequestreview-6078829894) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Returning early when `voice.pcm.is_empty()` after `decode` avoids emitting a spurious silent block on a whole-frame skip (or input switch) while keeping the output ring writable for the next pump. - `cargo test -p victory-hle --lib modules::audio:: -- --test-threads=1`: 9 passed, 0 failed (including `skipping_a_whole_xma_frame_does_not_publish_a_silent_block`). - `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).
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/2709/head:github-bot/gh-2709'
git switch 'github-bot/gh-2709'

Merge

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