XAudio2: reset XMA2 bit reservoir and skip orphan continuations after packet loss #1450
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1460"
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 ivall/xcl. Originally posted by b3IKK on 2026-11-24T16:27:15Z.
In
xma2::StreamDecoder::decode_packet_step, whenpacket_losswas set (at stream start, afterflush(), or after a decode error) and a continuation packet arrived withnum_bits_prev_frame > 0:save_bits(..., append = true)unconditionally wrote up to 16,352 discarded bits intoself.reservoirand advancedreservoir.bit_pos.if self.packet_losszeroednum_saved_bitsand clearedpacket_losswithout callingreservoir.reset().num_bits_prev_frame,save_bitsappended at the stalereservoir.bit_poswhiledecode_frameread bits0..num_saved_bitsfrom the previous packet's discarded bytes, decoding a phantom frame and corrupting overlap-add state.This only appends/decodes
num_bits_prev_framewhen!self.packet_loss && self.num_saved_bits > 0(otherwise skipping those bits withpgb.skip_bits), and resetsself.reservoirandself.num_saved_bitswheneverdecode_frameconsumes the reservoir orpacket_lossis cleared.What is in it
crates/xcl/src/hle/xma2/mod.rs: skip orphan continuation bits when there is no valid saved prefix; resetreservoirandnum_saved_bitson frame consumption and packet-loss recovery; add unit testpacket_loss_continuation_does_not_desync_reservoir_or_decode_phantom_frame(verified failing before the fix withreservoir.bit_pos == 16352).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 771 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib xma2: 10 passed, 0 failed (packet_loss_continuation_does_not_desync_reservoir_or_decode_phantom_framefailed before the fix)Regression run
main:
PR:
Not tested
AI use
hle/xma2/mod.rs, wrote the fix and unit test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T16:55:57Z.
Full-suite run, since this PR has no test report yet. Tested exact head
0817568(on its baseb7aa9f3).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 771 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.packet_loss_continuation_does_not_desync_reservoir_or_decode_phantom_frame.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 771 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:55Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by S1m0ne1997 on 2026-11-25T15:16:31Z.
Test report for
08175680d04a8b5fec8066bace3e3c43602d915f(this PR's head), for #1607.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09)x86_64-pc-windows-msvc, debug.cargo build --workspace, thencargo test --workspace -- --test-threads=4at the head: 771 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64).Regression run (retail title,
scripts/smoke.ps1 -Seconds 60, release;mainbuilt from the commit in its block, this PR from its head with no changes tocrates/, both run with thescripts/smoke.ps1ofmain, which hashes the name of the game folder)main:
this PR:
Not tested
AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:42:50Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:50:22Z.
Triage (#1607) – head
0817568No other open PR changes XMA2 packet-loss continuations. Main changed this block since (
b4484bc8): it decodes a continuation only when it is complete (continuation_complete) and keeps an incomplete one buffered.Problem: in
xma2/mod.rs:decode_packet_stepthis PR decodes after appending and then callsreservoir.reset()/num_saved_bits = 0, even when the continuation runs past the packet. A frame that spans three packets is then decoded incomplete and its remainder is skipped, and main's testincomplete_continuation_remains_buffered_for_the_next_packetwould fail. The rebase must keepcontinuation_completeand reset only after a complete decode. The skipping of orphan continuations after packet loss (no saved frame start) is not on main.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.