XAudio2: write decoded XMA samples directly into interleaved PCM #526

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

@⁠wileyGray on GitHub · 2026-11-24 01:20 UTC · original
wileyGray:codex/xma-pcm-output → main · +37 −41 · 1 files · 1 commits · draft

XAudio2 requests PCM16 from the XMA decoder. The decoder previously popped each sample from a channel queue into a float buffer, then allocated a second buffer and converted the entire result. Related to #459.

What is in it

  • Write each channel into its interleaved output positions, convert to the requested format as samples are written, and drain the channel queue once. The 5.1 test compares packet-by-packet PCM16 with a full float decode.

Tested

  • Windows 11 build 26300, i9-14900K, RTX 4080 SUPER (32.0.16.2114), Rust 1.93.0 MSVC. Debug cargo build --locked --workspace --offline passed. cargo test --workspace -- --test-threads=4 on cc09012 reported 680 passed, 0 failed, 41 ignored, including the end-to-end test title. Two GPU tests reported SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • All seven project XMA fixtures produced byte-identical float and PCM16 output on 508a0c7 and cc09012.
  • Median time in microseconds for a complete decode_buffer_i16(packet_data, true) call. Built both module versions with rustc --edition=2021 -O --test, pinned to the same logical CPU, warmed the decoder, then alternated baseline and patch order over 15 runs of 350 decodes per fixture. Inputs and outputs used std::hint::black_box.
Project fixture Main µs PR µs Time saved
XMA2 mono 50.59 40.89 19.2%
XMA2 stereo 61.28 51.40 16.1%
Variable subframes 45.83 40.47 11.7%
All coefficient paths 25.02 21.34 14.7%
XMA1 stereo 59.00 51.63 12.5%
Cross-packet 24.32 21.06 13.4%
5.1 surround 96.84 77.76 19.7%

Regression run

Retail regression evidence needed. A tester with any unpacked Xbox Series title can supply this pair; the title need not use XMA. In clean checkouts of upstream 508a0c74d7c0 and PR head cc09012b7e0b, run the following in each checkout, using the same game folder, machine and duration:

cargo build --release -p xcl
.\scripts\smoke.ps1 -Game 'D:\Games\YourTitle' -Seconds 60

Please attach the two generated xcl-smoke blocks to this PR, labeled main and PR, with the title version. Only the text output is needed. I can then update this section with the credited results.

For comparison, the repository's synthetic title passed all 50 checks on both commits with xcl run <game> -- --hello (exit 0). Unmodified scripts/smoke.ps1 launched the same fixture without its required --hello argument and recorded exit 1, one crash and zero device removals on both commits.

Not tested

  • Retail-title throughput, frame rate, and paired retail smoke runs. Optional game samples were unset. The D3D12 debug layer was unavailable.

AI use

  • Codex (gpt-6.2-astra) wrote and reviewed the patch, extended the test, ran the benchmarks and workspace suite, and drafted this description.
**@⁠wileyGray** on GitHub · 2026-11-24 01:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/526) `wileyGray:codex/xma-pcm-output` → `main` · +37 −41 · 1 files · 1 commits · draft XAudio2 requests PCM16 from the XMA decoder. The decoder previously popped each sample from a channel queue into a float buffer, then allocated a second buffer and converted the entire result. Related to #459. **What is in it** - Write each channel into its interleaved output positions, convert to the requested format as samples are written, and drain the channel queue once. The 5.1 test compares packet-by-packet PCM16 with a full float decode. **Tested** - Windows 11 build 26300, i9-14900K, RTX 4080 SUPER (32.0.16.2114), Rust 1.93.0 MSVC. Debug `cargo build --locked --workspace --offline` passed. `cargo test --workspace -- --test-threads=4` on `cc09012` reported **680 passed, 0 failed, 41 ignored**, including the end-to-end test title. Two GPU tests reported SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - All seven project XMA fixtures produced byte-identical float **and** PCM16 output on `508a0c7` and `cc09012`. - Median time in microseconds for a complete `decode_buffer_i16(packet_data, true)` call. Built both module versions with `rustc --edition=2021 -O --test`, pinned to the same logical CPU, warmed the decoder, then alternated baseline and patch order over 15 runs of 350 decodes per fixture. Inputs and outputs used `std::hint::black_box`. | Project fixture | Main µs | PR µs | Time saved | |---|---:|---:|---:| | XMA2 mono | 50.59 | 40.89 | 19.2% | | XMA2 stereo | 61.28 | 51.40 | 16.1% | | Variable subframes | 45.83 | 40.47 | 11.7% | | All coefficient paths | 25.02 | 21.34 | 14.7% | | XMA1 stereo | 59.00 | 51.63 | 12.5% | | Cross-packet | 24.32 | 21.06 | 13.4% | | 5.1 surround | 96.84 | 77.76 | 19.7% | **Regression run** Retail regression evidence needed. A tester with any unpacked Xbox Series title can supply this pair; the title need not use XMA. In clean checkouts of upstream `508a0c74d7c0` and PR head `cc09012b7e0b`, run the following in each checkout, using the same game folder, machine and duration: ```powershell cargo build --release -p xcl .\scripts\smoke.ps1 -Game 'D:\Games\YourTitle' -Seconds 60 ``` Please attach the two generated `xcl-smoke` blocks to this PR, labeled main and PR, with the title version. Only the text output is needed. I can then update this section with the credited results. For comparison, the repository's synthetic title passed all 50 checks on both commits with `xcl run <game> -- --hello` (exit 0). Unmodified `scripts/smoke.ps1` launched the same fixture without its required `--hello` argument and recorded exit 1, one crash and zero device removals on both commits. **Not tested** - Retail-title throughput, frame rate, and paired retail smoke runs. Optional game samples were unset. The D3D12 debug layer was unavailable. **AI use** - Codex (gpt-6.2-astra) wrote and reviewed the patch, extended the test, ran the benchmarks and workspace suite, and drafted this description.
Drain synchronized channels in batches and convert each sample as it lands in the output buffer. This avoids a separate float buffer and a queue pop per sample. Compare streamed PCM16 against the full 5.1 float fixture.

Assisted-by: Codex (gpt-6.2-astra)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:24:36 +00:00
Author
Owner

@⁠DTsordas on GitHub · 2026-11-24 09:44 UTC · original

Test report for #526 at cc09012: AMD RDNA4 (native wave64), Windows

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 5 5600X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug; DXC 1.9.2602.17 (SDK 10.0.26100.0).
  • cargo build --workspace and cargo test --workspace -- --test-threads=4 at cc09012: 680 passed, 0 failed, 41 ignored, 0 SKIPPED. The two tests skipped on the RTX 4080 for lack of wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware) ran and passed here.
  • All 7 hle::xma2 tests pass, including the extended surround_5_1_interleaves_three_streams_and_isolates_channels and decodes_xma2_and_xma1_bitstreams_matching_ffmpeg.
  • cc09012 merged into current main 077ce40 (no conflicts): cargo test -p xcl --lib hle::xma2:: 7 passed, 0 failed.

Not tested

  • The regression run: there's no unpacked title on this machine yet, so no xcl-smoke blocks; the PR check still needs them.
  • Release build, and the whole suite on the merge with main (only the XMA tests there).

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

**@⁠DTsordas** on GitHub · 2026-11-24 09:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/526#issuecomment-7127820018) **Test report for #526 at `cc09012`: AMD RDNA4 (native wave64), Windows** **Tested** - AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 5 5600X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug; DXC 1.9.2602.17 (SDK 10.0.26100.0). - `cargo build --workspace` and `cargo test --workspace -- --test-threads=4` at `cc09012`: 680 passed, 0 failed, 41 ignored, 0 SKIPPED. The two tests skipped on the RTX 4080 for lack of wave64 (`gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`) ran and passed here. - All 7 `hle::xma2` tests pass, including the extended `surround_5_1_interleaves_three_streams_and_isolates_channels` and `decodes_xma2_and_xma1_bitstreams_matching_ffmpeg`. - `cc09012` merged into current main `077ce40` (no conflicts): `cargo test -p xcl --lib hle::xma2::` 7 passed, 0 failed. **Not tested** - The regression run: there's no unpacked title on this machine yet, so no `xcl-smoke` blocks; the PR check still needs them. - Release build, and the whole suite on the merge with main (only the XMA tests there). **AI use:** Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 02:57 UTC · original

Regression run of cc09012b on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: cc09012b7e0b598d62cfad39d53402634188d44b
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1459 (PresentX 1459)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14733 MB

Against the limits in CONTRIBUTING.md: 90 % of main's frames, 99 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 02:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/526#issuecomment-7151410561) Regression run of `cc09012b` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: cc09012b7e0b598d62cfad39d53402634188d44b gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1459 (PresentX 1459) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14733 MB ``` Against the limits in CONTRIBUTING.md: 90 % of `main`'s frames, 99 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 13:43 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 13:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/526#issuecomment-7164193475) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
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/526/head:github-bot/gh-526'
git switch 'github-bot/gh-526'

Merge

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