XAudio2: keep XMA2 skip_packets == 0xFF EOF sentinel from decrementing #1581

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

@⁠b3IKK on GitHub · 2026-11-24 17:54 UTC · original
b3IKK:xma2/skip-packets-eof-sentinel → main · +29 −1 · 1 files · 1 commits · open

Addresses XCL-BT-016 from #1488.

In XMA2 packet headers, PacketSkipCount == 0xFF (255) is the end-of-stream sentinel meaning no further packets belong to that stream. Decoder::advance_stream decremented every stream's skip_packets unconditionally (s.skip_packets.saturating_sub(1)), so after 255 packets of sibling streams in a multi-stream XMA2 track, a finished stream's counter reached 0 and stole subsequent packets belonging to still-active streams.

This skips decrementing s.skip_packets when it equals 0xFF.

What is in it

  • crates/xcl/src/hle/xma2/mod.rs: preserve skip_packets == 0xFF in Decoder::advance_stream; add unit test eof_skip_packets_sentinel_255_is_never_decremented (verified failing before the fix with 254 != 255).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (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): 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware; 1 no heap windows — heap_window_out_of_memory_falls_back_to_the_switch_form)
  • cargo test -p xcl --lib xma2: 10 passed, 0 failed (eof_skip_packets_sentinel_255_is_never_decremented failed before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: da1b46c255816e4f2057ba5b5aee4409e930921d
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1647 (PresentX 1647)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14601 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: verified XCL-BT-016 from #1488, wrote the fix and unit test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
**@⁠b3IKK** on GitHub · 2026-11-24 17:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1581) `b3IKK:xma2/skip-packets-eof-sentinel` → `main` · +29 −1 · 1 files · 1 commits · open Addresses `XCL-BT-016` from #1488. In XMA2 packet headers, `PacketSkipCount == 0xFF` (255) is the end-of-stream sentinel meaning no further packets belong to that stream. `Decoder::advance_stream` decremented every stream's `skip_packets` unconditionally (`s.skip_packets.saturating_sub(1)`), so after 255 packets of sibling streams in a multi-stream XMA2 track, a finished stream's counter reached `0` and stole subsequent packets belonging to still-active streams. This skips decrementing `s.skip_packets` when it equals `0xFF`. **What is in it** - `crates/xcl/src/hle/xma2/mod.rs`: preserve `skip_packets == 0xFF` in `Decoder::advance_stream`; add unit test `eof_skip_packets_sentinel_255_is_never_decremented` (verified failing before the fix with `254 != 255`). **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`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`): 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`; 1 `no heap windows` — `heap_window_out_of_memory_falls_back_to_the_switch_form`) - `cargo test -p xcl --lib xma2`: 10 passed, 0 failed (`eof_skip_packets_sentinel_255_is_never_decremented` failed before the fix) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: da1b46c255816e4f2057ba5b5aee4409e930921d gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1647 (PresentX 1647) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14601 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: verified `XCL-BT-016` from #1488, wrote the fix and unit test, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
In XMA2 packet headers, PacketSkipCount == 0xFF (255) is the
end-of-stream sentinel meaning no further packets belong to that
stream. Decoder::advance_stream decremented every stream's
`skip_packets` unconditionally, so after 255 packets of sibling streams
in a multi-stream XMA2 track, a finished stream's counter reached 0 and
stole subsequent packets belonging to still-active streams.

Skip decrementing `s.skip_packets` when it equals `0xFF`. Addresses
XCL-BT-016 in #1488.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:12 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 18:53 UTC · original

Full-suite run, since this PR has no test report yet. Tested exact head da1b46c (on its base 9e3831e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 776 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: eof_skip_packets_sentinel_255_is_never_decremented.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • heap_window_out_of_memory_falls_back_to_the_switch_form was skipped with --skip. It fails on main 9e3831e too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWS unset). Reported as #1651.

Not tested

  • a release build, a game (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-24 18:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/1581#issuecomment-7141287034) Full-suite run, since this PR has no test report yet. Tested exact head `da1b46c` (on its base `9e3831e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form`: **776 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `eof_skip_packets_sentinel_255_is_never_decremented`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **777 passed, 0 failed, 41 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `heap_window_out_of_memory_falls_back_to_the_switch_form` was skipped with `--skip`. It fails on main `9e3831e` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (`XCL_HEAP_WINDOWS` unset). Reported as #1651. **Not tested** - a release build, a game (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

@⁠DavidM1911 on GitHub · 2026-11-24 20:02 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 20:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/1581#issuecomment-7142965070) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:14 UTC · original

Empirical test report (da1b46c2)

Hardware / environment

  • PR #1581 commit da1b46c255816e4f2057ba5b5aee4409e930921d.
  • Windows 11 Enterprise Evaluation x64 build 26200.9974. Assigned host hardware: AMD Ryzen 7 3800X and Intel Arc A770 16 GiB (driver 32.0.101.9175). The CPU-only test did not use the GPU.
  • rustc --version returned rustc 1.100.0 (0ef1bc386 2026-11-09).
  • DXC --version returned dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47).

Commands and results

  • cargo test --workspace --no-run completed with exit code 0 and compiled the workspace test executables. Test counts are inapplicable to this compile-only command.
  • The command below exited 0 with 1 passed / 0 failed / 0 ignored / 0 skipped. The test harness filtered out 748 other library tests.
$env:XCL_ADAPTER = 'NONE_CPU_ONLY'; $env:RUST_TEST_NOCAPTURE = '1'; cargo test -p xcl --lib hle::xma2::tests::eof_skip_packets_sentinel_255_is_never_decremented -- --exact --nocapture 2>&1 | Tee-Object -FilePath 'L:\XclTooling\neon-slot-6\tmp\pr1581-focused.log'

Both commands ran directly, outside Invoke-ArcTest.ps1, with zero Arc GPU mutex hold. The focused counts came from the test summary and the case-sensitive SKIPPED marker in the captured output.

Observed behavior

The XMA2 regression test passed. Across 300 stream advances, the finished stream kept its 0xFF end-of-stream sentinel and the active stream stayed selected. The active stream also stayed selected when its own skip counter was set to 1. The test uses an in-memory decoder and requires no audio endpoint. There were no audio endpoint skips.

Not tested

Coverage was limited to workspace test compilation and the PR's focused CPU regression test. The full GPU workspace suite and game smoke runs were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1581-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/1581#issuecomment-7153587988) ### Empirical test report (da1b46c2) **Hardware / environment** - PR #1581 commit `da1b46c255816e4f2057ba5b5aee4409e930921d`. - Windows 11 Enterprise Evaluation x64 build 26200.9974. Assigned host hardware: AMD Ryzen 7 3800X and Intel Arc A770 16 GiB (driver 32.0.101.9175). The CPU-only test did not use the GPU. - `rustc --version` returned `rustc 1.100.0 (0ef1bc386 2026-11-09)`. - DXC `--version` returned `dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47)`. **Commands and results** - `cargo test --workspace --no-run` completed with exit code 0 and compiled the workspace test executables. Test counts are inapplicable to this compile-only command. - The command below exited 0 with 1 passed / 0 failed / 0 ignored / 0 skipped. The test harness filtered out 748 other library tests. ```powershell $env:XCL_ADAPTER = 'NONE_CPU_ONLY'; $env:RUST_TEST_NOCAPTURE = '1'; cargo test -p xcl --lib hle::xma2::tests::eof_skip_packets_sentinel_255_is_never_decremented -- --exact --nocapture 2>&1 | Tee-Object -FilePath 'L:\XclTooling\neon-slot-6\tmp\pr1581-focused.log' ``` Both commands ran directly, outside `Invoke-ArcTest.ps1`, with zero Arc GPU mutex hold. The focused counts came from the test summary and the case-sensitive `SKIPPED ` marker in the captured output. **Observed behavior** The XMA2 regression test passed. Across 300 stream advances, the finished stream kept its `0xFF` end-of-stream sentinel and the active stream stayed selected. The active stream also stayed selected when its own skip counter was set to `1`. The test uses an in-memory decoder and requires no audio endpoint. There were no audio endpoint skips. **Not tested** Coverage was limited to workspace test compilation and the PR's focused CPU regression test. The full GPU workspace suite and game smoke runs were omitted. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1581-focused.log` and published.
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/1581/head:github-bot/gh-1581'
git switch 'github-bot/gh-1581'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1581'
git switch 'github-bot/gh-1581'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1581'
git switch 'github-bot/gh-1581'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1581'
git switch 'main'
git merge --squash 'github-bot/gh-1581'
git switch 'main'
git merge --ff-only 'github-bot/gh-1581'
git switch 'main'
git merge 'github-bot/gh-1581'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.