Audio: XMA decoding keeps up while frames are slow (MMCSS thread, the mixer never waits for a decode) #2786

Open
0xkn0wh3r3 wants to merge 6 commits from upstream-pr/2788 into main
0xkn0wh3r3 commented 2026-11-25 20:23:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T20:23:13Z.


Audio could cut out while world frames take about a second each. VIctory doesn't drive the audio device: the title mixes on its own time-critical thread and writes to the host's WASAPI. Our part is XMA decoding, on one thread, into output rings of at most 31 blocks of 256 bytes (about 83 ms of mono at 48 kHz).

Two things on our side could let a ring run dry while frames are slow. One commit for each, both in crates/victory-hle/src/modules/audio.rs. A third commit, resuming a voice whose input ran out, was dropped after review (reverted in 2314c249) and is left to #1880.

Changes

1. The decoding thread is scheduled like a host audio engine's (raise_priority, called when the "victory XMA decoder" thread starts).

  • It ran at normal priority. During slow world frames it competed with bulk work: DirectStorage's workers (one per core) and submission preparation.
  • It now registers with MMCSS as "Pro Audio" (AvSetMmThreadCharacteristicsW). If that fails it falls back to THREAD_PRIORITY_TIME_CRITICAL, then THREAD_PRIORITY_HIGHEST.
  • It logs once which one it got (XMA decoder: MMCSS "Pro Audio", or XMA decoder: no MMCSS with the error and the priority).
  • It only works while a ring has room, so it cannot hog a core.

2. The read-advance command never waits for a decode (Slot, pump, fill_block, advance_read).

  • The title sends command 18 (read-advance) from its time-critical mixer thread. It took the same per-voice mutex that pump held while it decoded until the ring was full.
  • A decoding thread preempted while holding that lock stalled the mixer, and with it every voice. A Windows SRW lock does not raise the holder's priority.
  • Each context now has two locks:
    • voice: the decoder, its samples and its trace;
    • ring: only the read block and "writable", which both sides change, plus the take counts.
  • advance_read takes only ring.
  • pump holds voice one block at a time (at most one frame's decode), so enable and disable wait for one frame at most.
  • fill_block takes ring only after writing a block, to decide whether the ring is full.
  • What is written, and when the ring counts as full, are unchanged.

Overlap with other PRs

  • #1880 (refill XMA rings from a decoded reserve on the title's thread) resumes an ended voice, which this PR leaves to it, and raises the decoder to time-critical without MMCSS, as part of a larger rework.
    • Of the two priority changes, only one should survive.
    • Commit 2 is not in #1880, but it touches the same pump, so they will conflict textually.
  • #2444, #2709, #2714 change pump and decode for other bugs; there is no functional overlap, but #2444 and #2709 rewrite the same pump loop, so expect rebase conflicts.
  • #443 and #237 don't overlap.

Tests

  • read_advance_does_not_wait_for_decoding holds the voice lock as a decode does and sends command 18 from another thread.
    • It returns at once, and the next pass fills up to the new read block.
    • With the old single lock, the test fails at its 5 s timeout.
  • cargo test -p victory-hle: lib 153 passed, 0 failed; the other test binaries pass.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean, with and without --features diagnostics.

Not verified

  • Not run with the title (no game data here), so whether audio now holds through slow frames is unverified. The priority log line, and the take counts in the "XMA voice disabled" debug line (VICTORY_LOG=victory_hle::modules::audio=debug), will show what happened.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5498567299 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T20:23:13Z. --- Audio could cut out while world frames take about a second each. VIctory doesn't drive the audio device: the title mixes on its own time-critical thread and writes to the host's WASAPI. Our part is XMA decoding, on one thread, into output rings of at most 31 blocks of 256 bytes (about 83 ms of mono at 48 kHz). Two things on our side could let a ring run dry while frames are slow. One commit for each, both in `crates/victory-hle/src/modules/audio.rs`. A third commit, resuming a voice whose input ran out, was dropped after review (reverted in 2314c249) and is left to #1880. ## Changes **1. The decoding thread is scheduled like a host audio engine's** (`raise_priority`, called when the "victory XMA decoder" thread starts). - It ran at normal priority. During slow world frames it competed with bulk work: DirectStorage's workers (one per core) and submission preparation. - It now registers with MMCSS as "Pro Audio" (`AvSetMmThreadCharacteristicsW`). If that fails it falls back to `THREAD_PRIORITY_TIME_CRITICAL`, then `THREAD_PRIORITY_HIGHEST`. - It logs once which one it got (`XMA decoder: MMCSS "Pro Audio"`, or `XMA decoder: no MMCSS` with the error and the priority). - It only works while a ring has room, so it cannot hog a core. **2. The read-advance command never waits for a decode** (`Slot`, `pump`, `fill_block`, `advance_read`). - The title sends command 18 (read-advance) from its time-critical mixer thread. It took the same per-voice mutex that `pump` held while it decoded until the ring was full. - A decoding thread preempted while holding that lock stalled the mixer, and with it every voice. A Windows SRW lock does not raise the holder's priority. - Each context now has two locks: - `voice`: the decoder, its samples and its trace; - `ring`: only the read block and "writable", which both sides change, plus the take counts. - `advance_read` takes only `ring`. - `pump` holds `voice` one block at a time (at most one frame's decode), so enable and disable wait for one frame at most. - `fill_block` takes `ring` only after writing a block, to decide whether the ring is full. - What is written, and when the ring counts as full, are unchanged. ## Overlap with other PRs - **#1880** (refill XMA rings from a decoded reserve on the title's thread) resumes an ended voice, which this PR leaves to it, and raises the decoder to time-critical without MMCSS, as part of a larger rework. - Of the two priority changes, only one should survive. - Commit 2 is not in #1880, but it touches the same `pump`, so they will conflict textually. - **#2444, #2709, #2714** change `pump` and `decode` for other bugs; there is no functional overlap, but #2444 and #2709 rewrite the same `pump` loop, so expect rebase conflicts. - #443 and #237 don't overlap. ## Tests - `read_advance_does_not_wait_for_decoding` holds the voice lock as a decode does and sends command 18 from another thread. - It returns at once, and the next pass fills up to the new read block. - With the old single lock, the test fails at its 5 s timeout. - `cargo test -p victory-hle`: lib 153 passed, 0 failed; the other test binaries pass. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean, with and without `--features diagnostics`. ## Not verified - Not run with the title (no game data here), so whether audio now holds through slow frames is unverified. The priority log line, and the take counts in the "XMA voice disabled" debug line (`VICTORY_LOG=victory_hle::modules::audio=debug`), will show what happened.
kotekompotek commented 2026-11-25 21:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:40:32Z.


Right threading model: MMCSS 'Pro Audio' with the graceful fallback chain (time-critical -> normal) is the correct way to keep XMA decoding ahead of the mixer on busy systems, and decoupling the mixer's read from the in-flight decode (ring + never-wait) kills the stall. Ended voices resuming on new input (ended=false in decode) fixes the real silence-after-stream-restart bug. Non-Windows stub keeps the build portable.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7174022081 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#issuecomment-7174022081). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T20:40:32Z. --- Right threading model: MMCSS 'Pro Audio' with the graceful fallback chain (time-critical -> normal) is the correct way to keep XMA decoding ahead of the mixer on busy systems, and decoupling the mixer's read from the in-flight decode (ring + never-wait) kills the stall. Ended voices resuming on new input (ended=false in decode) fixes the real silence-after-stream-restart bug. Non-Windows stub keeps the build portable.
oni-swr commented 2026-11-25 21:03:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T20:58:47Z.


WARP/CPU verification of head b9bf1b6afa2b18811ed8e3141432245cead0a808

Environment: Windows 11 x64, rustc/cargo 1.98.1, WARP/CPU only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), no physical GPU, no game files. DXIL validation with Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11. PR head merged cleanly onto origin/main 13f91caee2.

Tests (cargo test --no-fail-fast -p victory-hle)

  • origin/main baseline: lib 146 passed, plus fidelityfx 1 and no_dll_planting 1; 0 failed.
  • With this PR: lib 148 passed, fidelityfx 1, no_dll_planting 1; 0 failed (+2: read_advance_does_not_wait_for_decoding, a_voice_that_ran_out_resumes_on_new_input). The two new tests passed on 5 consecutive extra runs (no flakiness seen).

Negative control (each applied alone, then reverted)

  • advance_read also takes the voice lock (the old behaviour): read_advance_does_not_wait_for_decoding fails (after its 5 s timeout), the other test passes.
  • Ended voice never resumes: a_voice_that_ran_out_resumes_on_new_input fails, the other passes.

Lint: cargo clippy --all-targets -- -D warnings clean. cargo fmt --check: no new hunks (audio.rs 3 on main, 2 with the PR). Note: cargo fmt --check is already red on origin/main here (891 hunks, none from these PRs), so I compared per-file hunk counts against that baseline.

Review: read the full diff. The split into a voice lock (held per block) and a ring lock (taken after it, never during a decode) is consistent, and the lock order is respected in disable and fill_block; reading "writable" without the ring lock is sound because only the decoder clears it and the read-advance only sets it. Not covered here: the MMCSS / thread-priority path (raise_priority) is not exercised by any test, and I ran no audio device. No game files, dumps, shader names, or retail hashes.

AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7174446505 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#issuecomment-7174446505). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T20:58:47Z. --- **WARP/CPU verification of head `b9bf1b6afa2b18811ed8e3141432245cead0a808`** **Environment:** Windows 11 x64, rustc/cargo 1.98.1, WARP/CPU only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), no physical GPU, no game files. DXIL validation with Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11. PR head merged cleanly onto origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. **Tests (`cargo test --no-fail-fast -p victory-hle`)** - `origin/main` baseline: lib 146 passed, plus `fidelityfx` 1 and `no_dll_planting` 1; 0 failed. - With this PR: lib 148 passed, `fidelityfx` 1, `no_dll_planting` 1; 0 failed (+2: `read_advance_does_not_wait_for_decoding`, `a_voice_that_ran_out_resumes_on_new_input`). The two new tests passed on 5 consecutive extra runs (no flakiness seen). **Negative control** (each applied alone, then reverted) - `advance_read` also takes the voice lock (the old behaviour): `read_advance_does_not_wait_for_decoding` fails (after its 5 s timeout), the other test passes. - Ended voice never resumes: `a_voice_that_ran_out_resumes_on_new_input` fails, the other passes. **Lint:** `cargo clippy --all-targets -- -D warnings` clean. `cargo fmt --check`: no new hunks (`audio.rs` 3 on main, 2 with the PR). Note: `cargo fmt --check` is already red on `origin/main` here (891 hunks, none from these PRs), so I compared per-file hunk counts against that baseline. **Review:** read the full diff. The split into a `voice` lock (held per block) and a `ring` lock (taken after it, never during a decode) is consistent, and the lock order is respected in `disable` and `fill_block`; reading "writable" without the ring lock is sound because only the decoder clears it and the read-advance only sets it. Not covered here: the MMCSS / thread-priority path (`raise_priority`) is not exercised by any test, and I ran no audio device. No game files, dumps, shader names, or retail hashes. AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).
fuzeofficlal commented 2026-11-25 22:04:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:05:21Z.


Reviewed and tested b9bf1b6a on Windows 11 (rustc 1.98.1 MSVC) against main (13f91ca).

Concurrency bug found in fill_block (audio.rs:588-599): empty ring can be marked full and permanently stall a voice

In commit b15cc7a (Slot { voice, ring }), fill_block publishes the updated write block before acquiring ring:

context.set_field(0, 27, 5, write); // line 589: unlocked
let _ring = lock(ring);             // line 591
if write == context.field(9, 0, 5) % size {
    context.set_field(1, 31, 1, 0); // marks ring full
}

If the mixer thread consumes that newly written block between lines 589 and 591 and calls advance_read, advance_read moves read forward to equal write (leaving the ring empty) and sets writable = 1. When fill_block then acquires ring at line 591, it observes write == read and clears writable = 0, marking an empty ring as full and stalling the voice indefinitely (the mixer sees read == write so it will never issue another ADVANCE_XMA_READ).

Moving let _ring = lock(ring); just above line 589 (still after decode(), so mixer advance_read still never blocks on decoding) closes that window completely.

Minor note on commit b9bf1b6 (resuming ended voices, audio.rs:605-618)

When an ended voice resumes on new valid input, voice.ended and voice.decoder are reset, but any leftover partial-block samples in voice.pcm (< 128) or unconsumed voice.skip from the previous stream are kept instead of cleared/re-read from word 1[26:24]. Worth double-checking whether a resumed voice should start with a fresh pcm/skip.

Verification & merge compatibility

  • cargo test --locked -p victory-hle (3 consecutive runs): 3/3 passed (148 passed, 0 failed unit + fidelityfx + no_dll_planting, including both new tests).
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings (default & --features diagnostics): 0 warnings; cargo xtask policy: 184 files ok.
  • Merge-tree: clean vs 13f91ca, #2708, #2714; conflicts in audio.rs with #2709 and #2710.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7174596102 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#issuecomment-7174596102). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:05:21Z. --- Reviewed and tested `b9bf1b6a` on Windows 11 (`rustc 1.98.1` MSVC) against `main` (`13f91ca`). ### Concurrency bug found in `fill_block` (`audio.rs:588-599`): empty ring can be marked full and permanently stall a voice In commit `b15cc7a` (`Slot { voice, ring }`), `fill_block` publishes the updated `write` block *before* acquiring `ring`: ```rust context.set_field(0, 27, 5, write); // line 589: unlocked let _ring = lock(ring); // line 591 if write == context.field(9, 0, 5) % size { context.set_field(1, 31, 1, 0); // marks ring full } ``` If the mixer thread consumes that newly written block between lines 589 and 591 and calls `advance_read`, `advance_read` moves `read` forward to equal `write` (leaving the ring **empty**) and sets `writable = 1`. When `fill_block` then acquires `ring` at line 591, it observes `write == read` and clears `writable = 0`, marking an **empty** ring as full and stalling the voice indefinitely (the mixer sees `read == write` so it will never issue another `ADVANCE_XMA_READ`). Moving `let _ring = lock(ring);` just above line 589 (still after `decode()`, so mixer `advance_read` still never blocks on decoding) closes that window completely. ### Minor note on commit `b9bf1b6` (resuming ended voices, `audio.rs:605-618`) When an ended voice resumes on new valid input, `voice.ended` and `voice.decoder` are reset, but any leftover partial-block samples in `voice.pcm` (`< 128`) or unconsumed `voice.skip` from the previous stream are kept instead of cleared/re-read from `word 1[26:24]`. Worth double-checking whether a resumed voice should start with a fresh `pcm`/`skip`. ### Verification & merge compatibility - `cargo test --locked -p victory-hle` (3 consecutive runs): **3/3 passed** (`148 passed, 0 failed` unit + `fidelityfx` + `no_dll_planting`, including both new tests). - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` (default & `--features diagnostics`): **0 warnings**; `cargo xtask policy`: **184 files ok**. - Merge-tree: clean vs `13f91ca`, `#2708`, `#2714`; conflicts in `audio.rs` with `#2709` and `#2710`.
0xkn0wh3r3 commented 2026-11-25 22:04:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T21:35:52Z.


@fuzeofficlal thanks, that window is real. Fixed in 36d80c3: fill_block now takes the ring lock before it moves the write block, still after the decode, so a read-advance still never waits for decoding. A read-advance can't land between publishing the block and the full check any more.

On the resumed voice:

  • Samples in pcm: what's left there is the ended stream's flushed tail, which would have played had the title refilled in time, so it's kept.
  • skip: a leftover skip can only survive a stream that ended before its first frames were decoded. Re-reading word 1[26:24] on resume would treat a late refill as a new stream start. I don't know which the hardware does, so it's unchanged.

cargo test -p victory-hle (148 lib, including both new tests), clippy and policy pass. @oni-swr @kotekompotek thanks for the WARP run, the negative controls and the review.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175288585 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#issuecomment-7175288585). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T21:35:52Z. --- @fuzeofficlal thanks, that window is real. Fixed in 36d80c3: `fill_block` now takes the ring lock before it moves the write block, still after the decode, so a read-advance still never waits for decoding. A read-advance can't land between publishing the block and the full check any more. On the resumed voice: - **Samples in `pcm`:** what's left there is the ended stream's flushed tail, which would have played had the title refilled in time, so it's kept. - **`skip`:** a leftover skip can only survive a stream that ended before its first frames were decoded. Re-reading word 1[26:24] on resume would treat a late refill as a new stream start. I don't know which the hardware does, so it's unchanged. `cargo test -p victory-hle` (148 lib, including both new tests), clippy and policy pass. @oni-swr @kotekompotek thanks for the WARP run, the negative controls and the review.
upstream-sync changed title from [PR #2788] Audio: XMA decoding keeps up while frames are slow (MMCSS thread, mixer never waits for a decode, ended voices resume) to [PR #2788] Audio: XMA decoding keeps up while frames are slow (MMCSS thread, the mixer never waits for a decode) 2026-11-26 00:02:30 +00:00
Marvisak commented 2026-11-26 00:03:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:20:53Z.


Automated triage for the maintainers.

Merge candidate (recommending a look, not an approval). Thanks for dropping commit 3: the diff since the last review (6b73b07..2314c24) only removes the resume-an-ended-voice path (Voice::new, resumes, the word-2 reset), so decode behaves as on main for ended voices and that case is left to #1880. What remains in crates/victory-hle/src/modules/audio.rs: the per-context lock split (Slot with voice and ring; advance_read takes only ring, pump holds voice one block at a time, lock order voice then ring), with read_advance_does_not_wait_for_decoding covering it, and raise_priority registering the decoder thread with MMCSS "Pro Audio" and falling back to time-critical/highest, which changes host scheduling only. No Cargo.toml change. It merges cleanly and CI check is passing. Only one of this and #1880's priority change should land.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177437661 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#issuecomment-7177437661). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:20:53Z. --- <!-- victory-triage v1 head=2314c2490616e561056bc6f2d2b28bbe91279dcf verdict=merge-candidate at=2026-11-26T02:19:25Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not an approval). Thanks for dropping commit 3: the diff since the last review (`6b73b07`..`2314c24`) only removes the resume-an-ended-voice path (`Voice::new`, `resumes`, the word-2 reset), so `decode` behaves as on `main` for ended voices and that case is left to #1880. What remains in `crates/victory-hle/src/modules/audio.rs`: the per-context lock split (`Slot` with `voice` and `ring`; `advance_read` takes only `ring`, `pump` holds `voice` one block at a time, lock order voice then ring), with `read_advance_does_not_wait_for_decoding` covering it, and `raise_priority` registering the decoder thread with MMCSS "Pro Audio" and falling back to time-critical/highest, which changes host scheduling only. No Cargo.toml change. It merges cleanly and CI `check` is passing. Only one of this and #1880's priority change should land. --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 00:03:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T00:01:24Z.


Thanks. Commit 3, resuming an ended voice, is reverted in 2314c249, and that case is left to #1880, which is now credited in the description. The PR is now the lock split and the decoding thread's scheduling only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178309917 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#issuecomment-7178309917). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T00:01:24Z. --- Thanks. Commit 3, resuming an ended voice, is reverted in 2314c249, and that case is left to #1880, which is now credited in the description. The PR is now the lock split and the decoding thread's scheduling only.
Dukestar69 commented 2026-11-26 03:50:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:50:53Z.

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 read_advance_does_not_wait_for_decoding).
  • 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:6068306040 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#pullrequestreview-6068306040). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T03:50:53Z. **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 `read_advance_does_not_wait_for_decoding`). - `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 14:01:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T13:42:26Z.


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 2314c24 (on its base 842b0cb).

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: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: read_advance_does_not_wait_for_decoding.
  • --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:7193724978 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#issuecomment-7193724978). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T13:42:26Z. --- 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 `2314c24` (on its base `842b0cb`). **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`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `read_advance_does_not_wait_for_decoding`. - `--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.
Desamodeth commented 2026-11-26 21:45:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-26T21:45:31Z.

Review: COMMENTED


Independent CPU-only head-to-head Release benchmark and PCM/concurrency verification against main (63bcca43) and competing PR #1880 (3de75792), testing exact head 2314c249 merged cleanly onto main (Windows 11 x64, Ryzen 7 9800X3D, rustc 1.98.1 MSVC, synthetic XMA streams only, no GPU/WARP).

Baseline checks (clean merge onto 63bcca43)

  • cargo test --locked -p victory-hle --lib modules::audio:: -- --test-threads=1: 9 passed, 0 failed (including read_advance_does_not_wait_for_decoding)
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings & cargo xtask policy: clean (191 files ok)

PCM & concurrency integrity

  • Sequential bit-exact PCM (64-frame stereo = 66,048 samples, FNV-1a 0x29b87c8ab9c1311d; looping mono with start/loop skips = 19,584 samples, 0x6deafbf1c8a3834d): 100% bit-exact match across main, #2788, and #1880.
  • Concurrent stress (80 full stereo streams / 5.28M samples per branch, varying partial/full takes 1..=avail while decoder continuously pumps): 0 PCM mismatches, 0 stalls on all three — confirms 36d80c3's ring-lock placement before updating write holds under sustained concurrent partial takes.

Deterministic heap memory (exact, counting GlobalAlloc)

Metric main (63bcca43) #2788 (2314c249) #1880 (3de75792)
Idle Xma (512 voices, excl. SHAPE contexts) 7,405,568 B 7,413,760 B (+8,192 B, +16 B/slot) 7,405,568 B (0 B)
Active steady-state (16 stereo voices) 32,768 B 32,768 B (0 B) 131,072 B (+98,304 B, 4.0×)
Peak during 16-voice pump 34,855 B 34,855 B (0 B) 133,159 B (+98,304 B, 3.8×)
Post-disable retained (16 voices) 0 B 0 B 0 B

Interleaved Release timings (10 runs each: 5× M/#2788/#1880 + 5× #1880/#2788/M, medians)

Workload main #2788 #1880
T1a 16v burst ADVANCE_XMA_READ p50 / p95 / p99 / max (µs) 0.10 / 12.60 / 22.40 / 35.75 0.10 / 0.10 / 0.10 / 0.25 (-99.6% p99) 6.70 / 16.90 / 20.50 / 59.80
T1a Ring immediately full after advance 0.0% 0.0% 100.0%
T1b Same-voice mid-decode ADVANCE_XMA_READ p50 / p99 / max (µs) 22.50 / 33.35 / 42.05 0.10 / 0.15 / 0.20 (-99.6% p99) 18.90 / 29.30 / 88.75
T2 Uncontended ADVANCE_XMA_READ 4 blk (ns/call) 34.70 34.95 (+0.7%) 1,466.20 (42.3× slower)
T3 Uncontended 16×16-blk stream adv+pump (µs/round) 341.26 341.66 (+0.12%) 337.26 (-1.17%)
T4 Full-ring 16/512 scan (ns/pass) 4,133.85 4,535.50 (+9.7% / +402 ns) 4,074.35 (-1.4%)

Takeaway

The lock split in #2788 delivers the claimed decoupling: contended ADVANCE_XMA_READ tail latency drops from 22–42 µs down to 0.10–0.25 µs (>99% reduction) with +0.12% uncontended streaming overhead and 0 B extra per-active-voice heap, whereas #1880 still stalls on the shared voice lock under mid-decode contention and adds 42× uncontended mixer-thread latency plus +6 KiB per active stereo voice. The only measurable regressions in #2788 are +8 KiB idle for 512 Slots and +402 ns/pass (+9.7%) on full-ring 512-slot scans (which is orthogonal to active-voice scanning). Note: these are synthetic CPU microbenchmarks (not OS-scheduler preemption under live DirectStorage load or game FPS).

AI-assisted with Gemini 4 Neon

<!-- greyfinch-sync:Marvisak/VIctory:review:6080813231 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2788#pullrequestreview-6080813231). Originally posted by [Desamodeth](https://github.com/Desamodeth) on 2026-11-26T21:45:31Z. **Review:** COMMENTED --- Independent CPU-only head-to-head Release benchmark and PCM/concurrency verification against `main` (`63bcca43`) and competing PR #1880 (`3de75792`), testing exact head `2314c249` merged cleanly onto `main` (Windows 11 x64, Ryzen 7 9800X3D, `rustc 1.98.1` MSVC, synthetic XMA streams only, no GPU/WARP). ### Baseline checks (clean merge onto `63bcca43`) - `cargo test --locked -p victory-hle --lib modules::audio:: -- --test-threads=1`: **9 passed, 0 failed** (including `read_advance_does_not_wait_for_decoding`) - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` & `cargo xtask policy`: clean (`191 files ok`) ### PCM & concurrency integrity - **Sequential bit-exact PCM** (64-frame stereo = `66,048` samples, FNV-1a `0x29b87c8ab9c1311d`; looping mono with start/loop skips = `19,584` samples, `0x6deafbf1c8a3834d`): **100% bit-exact match** across `main`, #2788, and #1880. - **Concurrent stress** (80 full stereo streams / 5.28M samples per branch, varying partial/full takes `1..=avail` while decoder continuously pumps): **0 PCM mismatches, 0 stalls** on all three — confirms `36d80c3`'s ring-lock placement before updating `write` holds under sustained concurrent partial takes. ### Deterministic heap memory (exact, counting `GlobalAlloc`) | Metric | `main` (`63bcca43`) | **#2788 (`2314c249`)** | #1880 (`3de75792`) | |---|---:|---:|---:| | Idle `Xma` (512 voices, excl. SHAPE contexts) | `7,405,568 B` | `7,413,760 B` (**+8,192 B**, +16 B/slot) | `7,405,568 B` (0 B) | | Active steady-state (16 stereo voices) | `32,768 B` | `32,768 B` (**0 B**) | `131,072 B` (**+98,304 B**, 4.0×) | | Peak during 16-voice pump | `34,855 B` | `34,855 B` (**0 B**) | `133,159 B` (**+98,304 B**, 3.8×) | | Post-disable retained (16 voices) | `0 B` | `0 B` | `0 B` | ### Interleaved Release timings (10 runs each: 5× `M/#2788/#1880` + 5× `#1880/#2788/M`, medians) | Workload | `main` | **#2788** | #1880 | |---|---:|---:|---:| | **T1a** 16v burst `ADVANCE_XMA_READ` p50 / p95 / p99 / max (µs) | 0.10 / 12.60 / 22.40 / 35.75 | **0.10 / 0.10 / 0.10 / 0.25** (**-99.6% p99**) | 6.70 / 16.90 / 20.50 / 59.80 | | **T1a** Ring immediately full after advance | 0.0% | 0.0% | 100.0% | | **T1b** Same-voice mid-decode `ADVANCE_XMA_READ` p50 / p99 / max (µs) | 22.50 / 33.35 / 42.05 | **0.10 / 0.15 / 0.20** (**-99.6% p99**) | 18.90 / 29.30 / 88.75 | | **T2** Uncontended `ADVANCE_XMA_READ` 4 blk (ns/call) | 34.70 | **34.95** (+0.7%) | 1,466.20 (**42.3× slower**) | | **T3** Uncontended 16×16-blk stream `adv+pump` (µs/round) | 341.26 | **341.66** (+0.12%) | 337.26 (-1.17%) | | **T4** Full-ring 16/512 scan (ns/pass) | 4,133.85 | **4,535.50** (+9.7% / +402 ns) | 4,074.35 (-1.4%) | ### Takeaway The lock split in #2788 delivers the claimed decoupling: contended `ADVANCE_XMA_READ` tail latency drops from 22–42 µs down to **0.10–0.25 µs** (>99% reduction) with **+0.12%** uncontended streaming overhead and **0 B** extra per-active-voice heap, whereas #1880 still stalls on the shared voice lock under mid-decode contention and adds 42× uncontended mixer-thread latency plus +6 KiB per active stereo voice. The only measurable regressions in #2788 are **+8 KiB** idle for 512 `Slot`s and **+402 ns/pass (+9.7%)** on full-ring 512-slot scans (which is orthogonal to active-voice scanning). Note: these are synthetic CPU microbenchmarks (not OS-scheduler preemption under live DirectStorage load or game FPS). *AI-assisted with Gemini 4 Neon*
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/2788:upstream-pr/2788'
git switch 'upstream-pr/2788'

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