Audio: refill XMA rings from a decoded reserve on the title's thread #1878
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1880"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by beamdotdev on 2026-11-25T00:00:49Z.
Audio was choppy: XMA rings ran dry under load.
Why
What
ADVANCE_XMA_READcopies from that reserve into the freed blocks at once, on the title's thread; the decoding thread then tops the reserve up.THREAD_PRIORITY_TIME_CRITICAL. It works only while a ring has room or a reserve is short, so it cannot hog a core.imdct_half's pre/post rotations are computed once per transform size instead of per channel and subframe (bit-identical output).Testing
cargo test -p victory-hle audioandcargo test -p victory-formats xmapass; clippy is clean on both crates.xma_contexts_decode_into_their_output_ringsnow also covers the refill from the reserve on read-advance and resuming after input runs out.VICTORY_AUDIO_CAPTURE(diagnostics build) can record before/after.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:37:37Z.
Automated triage for the maintainers.
The reserve-and-refill part (
fillcalled fromADVANCE_XMA_READ, plus the decoding thread topping up two frames ahead) is a reasonable way to keep XMA rings from running dry. However, the PR also changes what the emulated XMA context does, and gives no evidence for it. Indecodeincrates/victory-hle/src/modules/audio.rs, a voice whose input ran out now resumes when new input arrives, from a cold decoder, with context dword 2 zeroed (context.set(2, 0)). Enabling only clears the error bits (set_field(2, 26, 6, 0)inXma::enable), so the comment "as enabling does" does not match the code, and the read offset is reset too. A partial block now waits for more input instead of being padded. Whether the hardware resumes a context that ran out, and from where, is the kind of runtime behaviour that needs a reference: the title's own handling of that state, or public documentation. The description also says the change has not been heard in a title. To move forward: give evidence for the resume semantics (or split them out, so the reserve and the thread priority can be judged alone), and attach a before/afterVICTORY_AUDIO_CAPTUREcomparison or a listening report from the title.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by beamdotdev on 2026-11-25T02:05:53Z.
Rebased onto main (
8fb0b28). The IMDCT rotation cache is dropped from this PR: main's own (#172) covers it. One test from main that builds a Voice now uses the renamed field. victory-hle tests: 142 pass; the one failure, dstorage::a_page_list_filled_after_its_request_starts, fails on main too.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:17:16Z.
Review: COMMENTED
Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.
XMA ring refill from a decoded reserve on the title's thread — moves decode work off the audio callback path; sensible if the reserve bounds are right. Windows-only verification needed.
Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-26T21:45:32Z.
Review: COMMENTED
Independent Windows Release CPU-only benchmark and PCM/concurrency verification of exact head
3de75792merged ontomain(63bcca43), compared head-to-head againstmainand #2788 (2314c249) (Ryzen 7 9800X3D,rustc 1.98.1MSVC, synthetic XMA streams only, no GPU/WARP; full table in the #2788 review).cargo test --locked -p victory-hle --lib modules::audio::(8 passed),clippy -D warnings, andcargo xtask policypass cleanly. Sequential stereo/looping-mono PCM is 100% bit-exact withmain, and 80 concurrent stereo streams had 0 mismatches / 0 stalls.ADVANCE_XMA_READcalls leave the ring immediately full from the 2-frame reserve (vs 0% onmain/ #2788), and total uncontended 16×16-blockadv+pumpthroughput is essentially unchanged (337.26vs341.26 µs/round).mainand #2788 (10 interleaved forward+reverse runs):ADVANCE_XMA_READstill blocks on the shared voice lock whilepump()decodes ring + reserve frames: same-voice mid-decode p50/p99/max is 18.90 / 29.30 / 88.75 µs (vs22.50 / 33.35 / 42.05 µsonmainand 0.10 / 0.15 / 0.20 µs on #2788); 16-voice burst p95/max is 16.90 / 59.80 µs (vs12.60 / 35.75 µsonmainand 0.10 / 0.25 µs on #2788).ADVANCE_XMA_READis 42.3× slower on the mixer thread:1,466.20 ns/callvs34.70 ns/callonmain(34.95 nson #2788) due to synchronousfill()copying blocks viaheap_bytes+VecDeque::pop_front.131,072 Blive /133,159 Bpeak for 16 active stereo voices vs32,768 B/34,855 Bonmainand #2788 (+6,144 B per active stereo voice because the 2-frame reserve pushesVecDequecapacity to 4,096i16= 8 KiB; drops to0 Bon disable).AI-assisted with Gemini 4 Neon
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.