Skip to content

XAudio2: reject streams wider than two channels - #1886

Open
mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:xma2/validate-stream-channels
Open

mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:xma2/validate-stream-channels

Conversation

@mokkamokacaffe

@mokkamokacaffe mokkamokacaffe commented Nov 24, 2026 •

Copy link
Copy Markdown

StreamConfig is public, but Decoder::new only checked the number of streams and the total channel count. Manually constructed configurations could therefore contain a zero-channel or three-channel stream. XMA streams support one or two channels, and decoder storage is fixed to two.

What is in it

  • Enforce one or two channels for every stream before constructing stream decoders and FIFOs.
  • Keep the aggregate channel-count check after the per-stream invariant.
  • Add regression cases for zero-channel and three-channel configurations and a valid 2 + 1 configuration.

Tested

  • Exact head 91deb1b989d74934b158f99af23cf3d039908677, NVIDIA GeForce RTX 5080, Windows 11, rustc 1.100.0, DXC 1.8.2502.11.
  • cargo build --workspace: passed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 972 passed, 4 failed, 45 ignored. The same four Direct-DXIL fuzz failures occur on base 689f2db; this PR introduced no new failure.
  • decoder_rejects_streams_outside_the_one_or_two_channel_xma_limit: passed.
  • git diff --check: passed.

Regression run

main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1657 (PresentX 1657)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14602 MB

PR:

xcl-smoke v1
commit: 91deb1b989d74934b158f99af23cf3d039908677
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14599 MB

Not tested

  • World loading; the smoke runs stop at the start screen.
  • AMD.
  • XMA1/XMA2 playback through XAudio2 on Windows or Wine.

AI use

  • OpenAI Codex audited and implemented the constructor invariant and regression test.
  • Claude Code ran the independent Windows/NVIDIA suite and smoke pair and drafted the posted report; the contributor checked it.

@mokkamokacaffe mokkamokacaffe changed the title XMA2: reject streams wider than two channels XAudio 2: reject streams wider than two channels Nov 24, 2026
@mokkamokacaffe mokkamokacaffe changed the title XAudio 2: reject streams wider than two channels XAudio2: reject streams wider than two channels Nov 24, 2026
@mokkamokacaffe
mokkamokacaffe force-pushed the xma2/validate-stream-channels branch from b03c081 to 91deb1b Compare November 24, 2026 23:10

@Melow-code Melow-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejecting streams wider than two channels is the right guard — XAudio2's mixing path assumes stereo or mono.

@mokkamokacaffe
mokkamokacaffe marked this pull request as ready for review November 24, 2026 23:19
@frenziedcoder

Copy link
Copy Markdown

NVIDIA test report for 91deb1b: no new test failures (the 4 that fail also fail on 689f2db), its own test decoder_rejects_streams_outside_the_one_or_two_channel_xma_limit passes, and a clean smoke pair on the retail title (1654 vs 1657 frames).

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head 91deb1b989d74934b158f99af23cf3d039908677, no local changes.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 972 passed, 4 failed, 45 ignored; the PR's own test decoder_rejects_streams_outside_the_one_or_two_channel_xma_limit passes. SKIPPED: gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 compares, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 rounding, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 three-source, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 transcendentals, wave64: no wave64), gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu (f64, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer carries, wave64: no wave64), gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The 4 failures are fuzz_validate_and_gpu_0, fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_2, fuzz_validate_and_gpu_3 in gpu::dxil::fuzz_tests. They fail the same way on the base 689f2db here (0x8007000E from CreateComputePipelineState on seeds 70, 545, 1019 and 1507, the NVIDIA refusal @PHeitor1 reported on Direct DXIL: geometry mode, MSAA loads and directed f32 rounding #1679), so this PR adds no failure.
  • test_title_draws_with_a_root_signature_under_the_debug_layer reports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.

Regression run (scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen; XCL_PSO_PRELOAD=0 for both builds, because this machine's preload list holds the program of #1307)

base (689f2db, this PR's merge base with main):

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1657 (PresentX 1657)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14602 MB

this PR:

xcl-smoke v1
commit: 91deb1b989d74934b158f99af23cf3d039908677
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14599 MB

Not tested: the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD.

AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

PR #1886 compatibility verification

Tested detached head 91deb1b989d74934b158f99af23cf3d039908677 on STOR-WINLAB (Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X). Intel Arc A770 16 GiB, driver 32.0.101.9175, wave range 8–32, DoublePrecisionFloatShaderOps=0. DXC/DXIL 1.9.2609.5. Rust 1.100.0 (0ef1bc386, 2026-11-09), unoptimized profiles with debug info disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both succeeded outside the GPU lock.
  • cargo test -p xcl hle::xma2::tests:: -- --nocapture reported 8 passed, 0 failed, 0 ignored. The new Decoder::new test passed for rejection of zero- and three-channel streams and acceptance of a three-channel configuration split into stereo and mono. XMA1/XMA2 decode fixtures and 5.1 interleaving also passed.
  • cargo test -p xcl hle::xaudio2::tests:: -- --nocapture reported 9 passed, 0 failed, 0 ignored. The system XAudio2 engine test passed. Three tests returned early when CreateMasteringVoice failed with 0x80070490 (no audio endpoint), including the XMA2 source-voice test.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc lock with RUST_TEST_NOCAPTURE=1. Cargo exited 101. Summed across 20 harness summaries, including doctests, 951 passed, 25 failed, 45 ignored. The XMA2 regression test passed again.

Of the 25 failures, 20 GPU tests hit CreateComputePipelineState error 0x80070057. Four GPU assertions failed (FMA overflow, implicit-LOD sampling, packed f16 high-half preservation, and wave64 pixel reduction). The test title failed its RSSetDepthBiasX check, drawing blue where green was expected.

The log has 25 SKIPPED lines covering 17 wave64 cases, three unsupported per-lane forms, two debug-layer cases, and one each for tiled tier, heap windows, and driver-cache control. These markers include subcases and confer no coverage.

Not tested

Audio-endpoint playback, D3D12 debug-layer paths, optional game samples, other GPU vendors, and retail-title smoke or comparison against main.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1886-suite.log and published this report.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants