XAudio2: an XMA voice reports no bytes required, as the docs say #1149

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

@⁠emirduran707 on GitHub · 2026-11-24 12:34 UTC · original
emirduran707:xma-bytes-required → main · +57 −1 · 1 files · 1 commits · open

XMA source voices play through a Windows PCM16 voice. XCL's callback wrapper passed that voice's OnVoiceProcessingPassStart BytesRequired (the PCM16 it needs) on to the title. Microsoft's documentation of IXAudio2VoiceCallback::OnVoiceProcessingPassStart says that for xWMA and XMA data BytesRequired is always zero. A title that streams just in time from this value sees its XMA voice as starving and submits more data than it needs.

The voice state now records whether the title submits XMA, and only then passes 0 on. Opus voices, which the documentation does not cover, keep the count as before.

What is in it

  • crates/xcl/src/hle/xaudio2.rs: DecodedVoiceState remembers whether the voice is XMA; the pass-start wrapper reports 0 for it. Test decoded_voice_reports_no_bytes_required_to_the_title (XMA reports 0, an Opus voice still reports the PCM count).

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on 41c4305: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • the new test fails without the change and passes with it; the first suite run had one failure in placed_title_textures_share_vram_and_preserve_pixels (the cubemap reuse flake of #718, two other tests then failed on its poisoned lock); cargo test -p xcl --lib hle::d3d12x:: then passed 3 times in a row on this head, and the whole suite again (the counts above)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19650 MB

this PR:

xcl-smoke v1
commit: 41c43053b10628515a0f528263b7fbf42e3190c7
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1563 (PresentX 1563)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19666 MB

Not tested

  • A title that streams XMA from BytesRequired: the smoke title does not show a difference in its run.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 12:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1149) `emirduran707:xma-bytes-required` → `main` · +57 −1 · 1 files · 1 commits · open XMA source voices play through a Windows PCM16 voice. XCL's callback wrapper passed that voice's `OnVoiceProcessingPassStart` `BytesRequired` (the PCM16 it needs) on to the title. Microsoft's documentation of `IXAudio2VoiceCallback::OnVoiceProcessingPassStart` says that for xWMA and XMA data `BytesRequired` is always zero. A title that streams just in time from this value sees its XMA voice as starving and submits more data than it needs. The voice state now records whether the title submits XMA, and only then passes 0 on. Opus voices, which the documentation does not cover, keep the count as before. **What is in it** - `crates/xcl/src/hle/xaudio2.rs`: `DecodedVoiceState` remembers whether the voice is XMA; the pass-start wrapper reports 0 for it. Test `decoded_voice_reports_no_bytes_required_to_the_title` (XMA reports 0, an Opus voice still reports the PCM count). **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on 41c4305: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests - the new test fails without the change and passes with it; the first suite run had one failure in `placed_title_textures_share_vram_and_preserve_pixels` (the cubemap reuse flake of #718, two other tests then failed on its poisoned lock); `cargo test -p xcl --lib hle::d3d12x::` then passed 3 times in a row on this head, and the whole suite again (the counts above) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1541 (PresentX 1541) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19650 MB ``` this PR: ``` xcl-smoke v1 commit: 41c43053b10628515a0f528263b7fbf42e3190c7 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1563 (PresentX 1563) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19666 MB ``` **Not tested** - A title that streams XMA from `BytesRequired`: the smoke title does not show a difference in its run. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
XMA source voices play through a Windows PCM16 voice, and the callback
wrapper passed that voice's OnVoiceProcessingPassStart BytesRequired (the
PCM16 it needs) on to the title. Microsoft's documentation: "For xWMA and
XMA data BytesRequired will always be zero". A title that streams just in
time from this value would see its XMA voice as starving and submit more
than it needs.

The voice state now records whether the title submits XMA, and only then
is 0 passed on. Opus voices, which the documentation does not cover, keep
the count as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:45:07 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 12:44 UTC · original

Independent native XAudio2 2.9 check on Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. I started an empty mono 48 kHz XMA2 voice through XCL and recorded the byte requests delivered to the title callback by the Windows engine.

  • 47efa2e forwarded nonzero PCM demand on all 8 callbacks, with a maximum of 960 bytes.
  • 41c4305 reported zero bytes on all 8 callbacks. The ten stock XAudio2 tests and the scratch test passed together, including the stock XMA2 and Opus voice tests.

Commands were cargo test --offline --locked -p xcl --lib scratch_xma_empty_voice_native_passes_report_zero_bytes -- --nocapture --test-threads=1 on each revision and the same command filtered to hle::xaudio2::tests on the PR. Retail audio was outside this check.

AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch test and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-24 12:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1149#issuecomment-7131862048) Independent native XAudio2 2.9 check on Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. I started an empty mono 48 kHz XMA2 voice through XCL and recorded the byte requests delivered to the title callback by the Windows engine. - [`47efa2e`](https://github.com/ivall/xcl/commit/47efa2ecea0a12934719ae69b81930cf02a4b1c3) forwarded nonzero PCM demand on all 8 callbacks, with a maximum of 960 bytes. - [`41c4305`](https://github.com/ivall/xcl/commit/41c43053b10628515a0f528263b7fbf42e3190c7) reported zero bytes on all 8 callbacks. The ten stock XAudio2 tests and the scratch test passed together, including the stock XMA2 and Opus voice tests. Commands were `cargo test --offline --locked -p xcl --lib scratch_xma_empty_voice_native_passes_report_zero_bytes -- --nocapture --test-threads=1` on each revision and the same command filtered to `hle::xaudio2::tests` on the PR. Retail audio was outside this check. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch test and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 12:50 UTC · original

Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug.

  • cargo test -p xcl --lib xaudio2: 10 passed, 0 failed — XMA2 and Opus source-voice lifetime tests pass with the no-bytes-required reporting.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

**@⁠DavidM1911** on GitHub · 2026-11-24 12:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1149#issuecomment-7132001960) Independent verification on current `main` `384f7f7` (branch already contains it — clean). **Machine:** Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug. - `cargo test -p xcl --lib xaudio2`: **10 passed, 0 failed** — XMA2 and Opus source-voice lifetime tests pass with the no-bytes-required reporting. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-24 13:06 UTC · original

NVIDIA run with the whole suite, since Not tested lists NVIDIA. The two runs above covered the XAudio2 tests and a native XMA2 voice.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (32-lane waves), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), system XAudio2 2.9, Graphics Tools installed; rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug
  • Exact head 41c43053b10628515a0f528263b7fbf42e3190c7, which is on current main 47efa2e (so also the merged result): cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored, the same as yours. xaudio2::tests::decoded_voice_reports_no_bytes_required_to_the_title passed.
  • Fails without the change: with this PR's file and only the pass-start call changed back to ((*vt).pass_start)(obj, bytes), the test fails at xaudio2.rs:1683 with left: 1920, right: 0. The PCM16 byte count reaches the title.
  • hle::xaudio2 tests, 10 runs: 10 of 10 passed (10 each, including the XMA2 and Opus voice lifetime tests)
  • e2e, 3 runs: 3 of 3 passed (the test title's audio voices)
  • SKIPPED (no wave64 on this adapter): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware

Not tested

  • A retail title streaming XMA just in time (none here); release build.

AI use

  • Claude Code (Claude Opus 5.5) ran the build and tests on the machine above, including the check without the change, and wrote this report from the output.
**@⁠fromthemoonx** on GitHub · 2026-11-24 13:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1149#issuecomment-7132354848) NVIDIA run with the whole suite, since **Not tested** lists NVIDIA. The two runs above covered the XAudio2 tests and a native XMA2 voice. **Tested** - NVIDIA GeForce RTX 3060 12 GB (32-lane waves), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), system XAudio2 2.9, Graphics Tools installed; rustc 1.100.0 `stable-x86_64-pc-windows-msvc`; DXC 1.9.2602.17; debug - **Exact head `41c43053b10628515a0f528263b7fbf42e3190c7`**, which is on current `main` `47efa2e` (so also the merged result): `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **742 passed, 0 failed, 41 ignored**, the same as yours. `xaudio2::tests::decoded_voice_reports_no_bytes_required_to_the_title` passed. - **Fails without the change:** with this PR's file and only the pass-start call changed back to `((*vt).pass_start)(obj, bytes)`, the test fails at `xaudio2.rs:1683` with `left: 1920, right: 0`. The PCM16 byte count reaches the title. - `hle::xaudio2` tests, 10 runs: **10 of 10 passed** (10 each, including the XMA2 and Opus voice lifetime tests) - `e2e`, 3 runs: **3 of 3 passed** (the test title's audio voices) - SKIPPED (no wave64 on this adapter): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` **Not tested** - A retail title streaming XMA just in time (none here); release build. **AI use** - Claude Code (Claude Opus 5.5) ran the build and tests on the machine above, including the check without the change, and wrote this report from the output.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 04:33 UTC · original

Windows XAudio2 test report for PR #1149 at 41c43053b10628515a0f528263b7fbf42e3190c7

Setup: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M (driver 30.0.13002.13003), Rust 1.99.0 MSVC. Clean checkout of this PR's exact head.

Tested

  • cargo test --locked -p xcl --lib -j 2 decoded_voice_reports_no_bytes_required_to_the_title -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored. The synthetic callback test covers XMA's zero BytesRequired and the unchanged Opus count.
  • cargo build --locked --workspace -j 2: passed.

Not tested: Full workspace suite, a title that streams XMA based on BytesRequired, paired retail-title smoke, or other audio devices. This is focused Windows verification, not a claim about GPU behavior or world loading. No game data was used.

AI assistance: OpenAI Codex (GPT-6) ran the commands, extracted the test count from the log, and drafted this report.

**@⁠luckyteagirl** on GitHub · 2026-11-25 04:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/1149#issuecomment-7152950215) ### Windows XAudio2 test report for PR #1149 at `41c43053b10628515a0f528263b7fbf42e3190c7` **Setup:** Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M (driver `30.0.13002.13003`), Rust `1.99.0` MSVC. Clean checkout of this PR's exact head. **Tested** - `cargo test --locked -p xcl --lib -j 2 decoded_voice_reports_no_bytes_required_to_the_title -- --test-threads=1 --show-output`: **1 passed, 0 failed, 0 ignored**. The synthetic callback test covers XMA's zero `BytesRequired` and the unchanged Opus count. - `cargo build --locked --workspace -j 2`: passed. **Not tested:** Full workspace suite, a title that streams XMA based on `BytesRequired`, paired retail-title smoke, or other audio devices. This is focused Windows verification, not a claim about GPU behavior or world loading. No game data was used. AI assistance: OpenAI Codex (GPT-6) ran the commands, extracted the test count from the log, and drafted this report.
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/1149/head:github-bot/gh-1149'
git switch 'github-bot/gh-1149'

Merge

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