HLE: write decoded Opus samples through unaligned output buffers #1214

Manually merged
github merged 1 commit from gh-pr/1214/head into gh-pr/1214/base 2026-11-26 04:23:59 +00:00
Owner

@⁠divyeshganta on GitHub · 2026-11-24 16:26 UTC · original
divyeshganta:codex/hle-apu-unaligned-output-ub → main · +165 −11 · 1 files · 1 commits · merged 2026-11-25 00:17 UTC

Fixes #839.

XApuEnqueueCommand receives a packed process command whose output is a byte pointer with no 4-byte alignment guarantee. The decoder now writes sample bytes through a u8 slice, preserving interleaved and deinterleaved layouts without constructing a potentially misaligned &mut [f32]. Zero-frame requests skip slice construction.

Also reject invalid channel counts before constructing the Opus decoder, and free the connection allocation if optional result-event creation fails.

Patch by AndyLatimer, carried from commit 13df0dad39c78af7c6479116cc185ab22ce44f05.

The branch adds synthetic tests for unaligned output, both stereo layouts, zero frames, invalid channels, and bit-for-bit parity. Independent Windows 10/11 reports on the source branch say the focused tests and cargo test -p victory-hle passed; Clippy with -D warnings was clean. I attempted cargo test -p victory-hle --locked locally on this PR head after installing Rust 1.98.1, but compilation stopped before tests ran because link.exe (the MSVC linker) is unavailable in this environment. GitHub shows the workflow awaiting maintainer approval, so this PR has no check result yet. No game data used.

**@⁠divyeshganta** on GitHub · 2026-11-24 16:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1214) `divyeshganta:codex/hle-apu-unaligned-output-ub` → `main` · +165 −11 · 1 files · 1 commits · merged 2026-11-25 00:17 UTC Fixes #839. `XApuEnqueueCommand` receives a packed process command whose output is a byte pointer with no 4-byte alignment guarantee. The decoder now writes sample bytes through a `u8` slice, preserving interleaved and deinterleaved layouts without constructing a potentially misaligned `&mut [f32]`. Zero-frame requests skip slice construction. Also reject invalid channel counts before constructing the Opus decoder, and free the connection allocation if optional result-event creation fails. Patch by AndyLatimer, carried from commit `13df0dad39c78af7c6479116cc185ab22ce44f05`. The branch adds synthetic tests for unaligned output, both stereo layouts, zero frames, invalid channels, and bit-for-bit parity. Independent Windows 10/11 reports on the source branch say the focused tests and `cargo test -p victory-hle` passed; Clippy with `-D warnings` was clean. I attempted `cargo test -p victory-hle --locked` locally on this PR head after installing Rust 1.98.1, but compilation stopped before tests ran because `link.exe` (the MSVC linker) is unavailable in this environment. GitHub shows the workflow awaiting maintainer approval, so this PR has no check result yet. No game data used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:23:58 +00:00
github manually merged commit 643fc6dfec into gh-pr/1214/base 2026-11-26 04:23:59 +00:00
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 17:59 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 643fc6d: cargo test -p victory-hle passes, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 17:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1214#issuecomment-7140009099) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 643fc6d: `cargo test -p victory-hle` passes, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1214
No description provided.