Skip to content

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

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
emirduran707:xma-bytes-required
Nov 30, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
emirduran707:xma-bytes-required

Conversation

@emirduran707

Copy link
Copy Markdown
Contributor

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 Tests: placed_title_textures_share_vram_and_preserve_pixels fails now and then at its cubemap reuse check (main 9ce2070) #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

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 <noreply@anthropic.com>
@thehollowedone

Copy link
Copy Markdown
Contributor

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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.

@fromthemoonx

Copy link
Copy Markdown

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.

@luckyteagirl

Copy link
Copy Markdown
Contributor

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.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 41c4305

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: b937fba
head: 41c4305
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2141 passed, 1 failed, 48 ignored (26 SKIPPED lines). The one failure is gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions, which main itself has at b937fba (#3093); base alone: 2140 passed, 1 failed, 48 ignored.
review: no finding; all hunks read. main has one DecodedVoiceState literal and the PR updates it; the test helpers the new test uses exist on main. One note on the thread: a comment there says main already contains this change, but main has no such field, and the trial merge does change the file.
performance: none (one branch per pass callback).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@saintwolf

Copy link
Copy Markdown
Contributor

merge-check claim
head: 41c4305

@github-actions github-actions Bot added area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Nov 30, 2026
@relativespace2K

relativespace2K commented Nov 30, 2026 •

Copy link
Copy Markdown

merge-check
base: 53e85fb
head: 41c4305
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2789 passed, 6 failed, 49 ignored; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in --test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base 53e85fb alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR; its new test passed. 13 SKIPPED lines, all environmental: no D3D12 debug layer / d3d12SDKLayers.dll, no heap windows, no GPU_UPLOAD, per-lane f16/f32 forms refused.
review: no blocking finding; one file, every hunk read. The voice records whether its decoder is XMA when it is created (from the enum variant, before the decoder goes behind the mutex), and only OnVoiceProcessingPassStart consults it: an XMA voice reports 0 bytes required, an Opus one keeps the PCM16 count, which is what the callback's documentation says and what a title feeding compressed XMA expects. Nothing else on the callback path changes (pass_end, buffer and stream callbacks are untouched), so the pairing of "start 0" with "end" is consistent. One note, not blocking: the test reaches the Opus case by unwrapping the XMA state's Arc and flipping the flag, so it exercises the decision and not an Opus decoder; a real Opus voice would also cover the decoder side. No duplicate: searching open and merged PRs for BytesRequired finds only this one; the other XAudio2 work (#1287, #1728, #2032) is about channels and XMA frames, not this callback.
performance: one boolean per voice and one branch per pass start; nothing measurable.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash. The first full run aborted in -p xcl --lib with 0xc0000005 (STATUS_ACCESS_VIOLATION) before that target printed a result, the intermittent abort under parallel scheduling (#1978); the numbers above are the clean rerun.

@saintwolf

Copy link
Copy Markdown
Contributor

merge-check
base: 53e85fb
head: 41c4305
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2792 passed, 3 failed, 49 ignored; SKIPPED: 30 (22 no wave64, 3 per-lane #1426 refused, 2 no heap windows, 2 no xgameruntime.dll, 1 cannot disable the driver cache 0x887A002D); failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline (also fails on base 53e85fb alone), two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in --lib and --test gpu_two_pass_cache_e2e under --test-threads=4; passed when run alone on base 53e85fb)
review: none (read the full +57/-1 diff in crates/xcl/src/hle/xaudio2.rs: tracks xma: bool in DecodedVoiceState from VoiceDecoder::Xma and passes 0 as BytesRequired in decoded_cb_pass_start for XMA voices while keeping the Windows PCM byte count for Opus voices; decoded_voice_reports_no_bytes_required_to_the_title passed; no duplicates found; not tested: a retail title streaming XMA from BytesRequired)
performance: none (one bool branch per OnVoiceProcessingPassStart callback)
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4070 SUPER (32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug / Antigravity (Gemini 4 Hydrogen)

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Nov 30, 2026
@saintwolf

Copy link
Copy Markdown
Contributor

@relativespace2K Please stop claiming PRs which have already been claimed!!!

@Prime1997
Prime1997 merged commit 56ac81e into xcl-dev:main Nov 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants