XAudio2: honor RFC 7845 channel mapping and coupled_count on single-stream Opus #1455

Open
b3IKK wants to merge 1 commit from upstream-pr/1465 into main
b3IKK commented 2026-11-24 16:31:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T16:31:58Z.


opus::Decoder gated both stream channel count setup and RFC 7845 channel remapping on multistream = head.stream_count > 1 || ch > 2. For valid RFC 7845 mapping family 1 or 255 headers with stream_count == 1 and 1–2 output channels (such as swapped L/R [1, 0], muted channels [0, 255], or a coupled stereo stream selecting channel 1), coupled_count and mapping were silently ignored. Conversely, a 1-stream header with ch > 2 set multistream = true for wire packet framing even though packets hold only one stream.

This separates wire framing (multistream = head.stream_count > 1) from channel remapping (use_mapping = head.mapping_family != 0), and always builds stream decoders from head.stream_count / head.coupled_count.

What is in it

  • crates/xcl/src/hle/opus.rs: add use_mapping to Decoder, set multistream = head.stream_count > 1, build stream decoders unconditionally from coupled_count, and add unit test single_stream_mapping_family_honors_channel_mapping_and_silence (verified failing before the fix).

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): 771 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)
  • cargo test -p xcl --lib opus: 16 passed, 0 failed (single_stream_mapping_family_honors_channel_mapping_and_silence 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: d1e28a57ce7527a82f9a40c979aa59ea10fcba60
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1644 (PresentX 1644)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14467 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: audited hle/opus.rs, wrote the fix and unit test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5476231250 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1465). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T16:31:58Z. --- `opus::Decoder` gated both stream channel count setup and RFC 7845 channel remapping on `multistream = head.stream_count > 1 || ch > 2`. For valid RFC 7845 mapping family 1 or 255 headers with `stream_count == 1` and 1–2 output channels (such as swapped L/R `[1, 0]`, muted channels `[0, 255]`, or a coupled stereo stream selecting channel 1), `coupled_count` and `mapping` were silently ignored. Conversely, a 1-stream header with `ch > 2` set `multistream = true` for wire packet framing even though packets hold only one stream. This separates wire framing (`multistream = head.stream_count > 1`) from channel remapping (`use_mapping = head.mapping_family != 0`), and always builds stream decoders from `head.stream_count` / `head.coupled_count`. **What is in it** - `crates/xcl/src/hle/opus.rs`: add `use_mapping` to `Decoder`, set `multistream = head.stream_count > 1`, build stream decoders unconditionally from `coupled_count`, and add unit test `single_stream_mapping_family_honors_channel_mapping_and_silence` (verified failing before the fix). **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`): 771 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`) - `cargo test -p xcl --lib opus`: 16 passed, 0 failed (`single_stream_mapping_family_honors_channel_mapping_and_silence` 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: d1e28a57ce7527a82f9a40c979aa59ea10fcba60 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1644 (PresentX 1644) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14467 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: audited `hle/opus.rs`, wrote the fix and unit test, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
futurepro62 commented 2026-11-24 17:06:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T16:56:40Z.


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

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, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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.
  • The new tests ran and passed: single_stream_mapping_family_honors_channel_mapping_and_silence.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 771 passed, 0 failed, 41 ignored, no skips.

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.
<!-- greyfinch-sync:ivall/xcl:comment:7138447706 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1465#issuecomment-7138447706). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T16:56:40Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `d1e28a5` (on its base `b7aa9f3`). **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, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_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`. - The new tests ran and passed: `single_stream_mapping_family_honors_channel_mapping_and_silence`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **771 passed, 0 failed, 41 ignored**, no skips. **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.
DavidM1911 commented 2026-11-24 19:07:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:01Z.


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 unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141285855 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1465#issuecomment-7141285855). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:53:01Z. --- 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 unmodified `main`.) Thanks!
S1m0ne1997 commented 2026-11-25 16:12:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by S1m0ne1997 on 2026-11-25T15:18:41Z.


Test report for d1e28a57ce7527a82f9a40c979aa59ea10fcba60 (this PR's head), for #1607.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 771 passed, 0 failed, 41 ignored.
  • SKIPPED (2): 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; main built from the commit in its block, this PR from its head with no changes to crates/, both run with the scripts/smoke.ps1 of main, which hashes the name of the game folder)

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16384 MB

this PR:

xcl-smoke v1
commit: d1e28a57ce7527a82f9a40c979aa59ea10fcba60
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1635 (PresentX 1635)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 21575 MB

Peak commit is over the 125 % rule: this PR's run peaked at 21575 MB, 132 % of main's 16384 MB (frames: within 80 %). I can't tell from this whether the PR causes it: this branch is based on b7aa9f3, 440 commits older than the main commit (06c9f55) its run is compared with, and each side was run once. A smoke run of the base itself, or of this PR rebased onto current main, would separate the two.

Not tested

  • AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7166640064 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1465#issuecomment-7166640064). Originally posted by [S1m0ne1997](https://github.com/S1m0ne1997) on 2026-11-25T15:18:41Z. --- Test report for `d1e28a57ce7527a82f9a40c979aa59ea10fcba60` (this PR's head), for #1607. **Tested** - NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, `rustc 1.100.0 (0ef1bc386 2026-11-09)` `x86_64-pc-windows-msvc`, debug. - `cargo build --workspace`, then `cargo test --workspace -- --test-threads=4` at the head: **771 passed, 0 failed, 41 ignored**. - SKIPPED (2): `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; `main` built from the commit in its block, this PR from its head with no changes to `crates/`, both run with the `scripts/smoke.ps1` of `main`, which hashes the name of the game folder) main: ``` xcl-smoke v1 commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324 gpu: NVIDIA GeForce RTX 4090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1599 (PresentX 1599) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16384 MB ``` this PR: ``` xcl-smoke v1 commit: d1e28a57ce7527a82f9a40c979aa59ea10fcba60 gpu: NVIDIA GeForce RTX 4090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1635 (PresentX 1635) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 21575 MB ``` **Peak commit is over the 125 % rule:** this PR's run peaked at 21575 MB, 132 % of `main`'s 16384 MB (frames: within 80 %). I can't tell from this whether the PR causes it: this branch is based on `b7aa9f3`, 440 commits older than the `main` commit (`06c9f55`) its run is compared with, and each side was run once. A smoke run of the base itself, or of this PR rebased onto current `main`, would separate the two. **Not tested** - AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only. *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.*
github-actions[bot] commented 2026-11-29 20:42:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:42:52Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262299146 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1465#issuecomment-7262299146). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:42:52Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:51:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:51:26Z.


Triage (#1607) – head d1e28a5

No open or merged PR applies the channel mapping to a single-stream Opus head with mapping family 1/255. #2696 and #503 change the multistream mapping, not this case. Main's Decoder::new still uses multistream = stream_count > 1 || ch > 2.
Main now builds channel_map and the sub-packet buffers only if multistream. When this is rebased, the use_mapping path needs them too, or the single-stream mapped decode has an empty map.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302211586 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1465#issuecomment-7302211586). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:51:26Z. --- **Triage (#1607)** – head d1e28a5 No open or merged PR applies the channel mapping to a single-stream Opus head with mapping family 1/255. #2696 and #503 change the multistream mapping, not this case. Main's `Decoder::new` still uses `multistream = stream_count > 1 || ch > 2`. Main now builds `channel_map` and the sub-packet buffers only `if multistream`. When this is rebased, the `use_mapping` path needs them too, or the single-stream mapped decode has an empty map. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1465:upstream-pr/1465'
git switch 'upstream-pr/1465'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1465'
git switch 'upstream-pr/1465'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1465'
git switch 'upstream-pr/1465'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1465'
git switch 'main'
git merge --squash 'upstream-pr/1465'
git switch 'main'
git merge --ff-only 'upstream-pr/1465'
git switch 'main'
git merge 'upstream-pr/1465'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1455
No description provided.