Skip to content

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

Open
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:opus/mapping-family-single-stream
Open

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:opus/mapping-family-single-stream

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

…tream Opus

opus::Decoder gated both stream channel count setup and RFC 7845 channel
mapping on `multistream = head.stream_count > 1 || ch > 2`. For valid
mapping family 1 or 255 headers with `stream_count == 1` and 1–2 output
channels (e.g. swapped L/R `[1, 0]`, muted channel `[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.

Separate wire framing (`multistream = head.stream_count > 1`) from
channel remapping (`use_mapping = head.mapping_family != 0`) and always
build stream decoders from `head.stream_count` / `head.coupled_count`.

Assisted-by: OpenCode (Gemini 4 Neon)
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants