runtime: xapu.dll as a command queue with the console's layouts (RT-XAPU-CONNECT-LAYOUTS) #1144

Manually merged
github merged 4 commits from github-bot/gh-1144 into main 2026-11-26 14:53:20 +00:00 AGit
Owner

@⁠nicoco23 on GitHub · 2026-11-24 19:10 UTC · original
nicoco23:xapu-connect-layouts → main · +610 −160 · 6 files · 4 commits · merged 2026-11-26 14:41 UTC

Claimed in the coordination issue as: RT-XAPU-CONNECT-LAYOUTS

xapu.dll moves out of xapu_chad.cpp into xapu.cpp and becomes a command queue with the console's layouts: the XApuConnect input and output, 24-byte command ids, 0x50-byte results, the 0x8AC81000+ error codes, and the frame count of an Opus packet's TOC byte (RFC 6716 section 3.1). The audio stays silent, nothing is decoded. chad.dll is unchanged.

This replaces the xapu half of #277 (piyonchu's draft, which needs a rebase); the chad half stays as it is. Credit to piyonchu for the original shim.

The layouts are facts from Marvisak/VIctory (GPL-3.0-or-later, crates/victory-hle/src/modules/apu.rs at ffe310e), no code is copied. See docs/related_projects.md.

Tested: xapu_chad_test via ctest on Windows 11, 100% success. No game files, no GPU.
AI-assisted: yes (Claude Code).

**@⁠nicoco23** on GitHub · 2026-11-24 19:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144) `nicoco23:xapu-connect-layouts` → `main` · +610 −160 · 6 files · 4 commits · merged 2026-11-26 14:41 UTC Claimed in the coordination issue as: RT-XAPU-CONNECT-LAYOUTS xapu.dll moves out of xapu_chad.cpp into xapu.cpp and becomes a command queue with the console's layouts: the XApuConnect input and output, 24-byte command ids, 0x50-byte results, the 0x8AC81000+ error codes, and the frame count of an Opus packet's TOC byte (RFC 6716 section 3.1). The audio stays silent, nothing is decoded. chad.dll is unchanged. This replaces the xapu half of #277 (piyonchu's draft, which needs a rebase); the chad half stays as it is. Credit to piyonchu for the original shim. The layouts are facts from Marvisak/VIctory (GPL-3.0-or-later, crates/victory-hle/src/modules/apu.rs at ffe310e), no code is copied. See docs/related_projects.md. Tested: xapu_chad_test via ctest on Windows 11, 100% success. No game files, no GPU. AI-assisted: yes (Claude Code).
xapu.dll moves out of xapu_chad.cpp into xapu.cpp; chad.dll is unchanged.

The signatures, structure layouts, command kinds, option bits and error
codes come from Marvisak/VIctory (GPL-3.0-or-later,
crates/victory-hle/src/modules/apu.rs at ffe310e), which runs the retail
executable through these calls. Only facts are used, no code
(docs/related_projects.md). They settle what the old header left open:
XApuConnect's first argument is an input (processing kind, streams,
commands per stream, memory bytes, frames per output, options), and the
dword the title reads at +0x34 of a result is its output byte count.

- XApuConnect validates the input, allocates the memory the title asks
  for (zeroed) and, with option 0x8, an auto-reset result event; any
  processing kind but Opus decoding is E_NOTIMPL.
- Each accepted command gives one result in command order, with the
  console's error codes; an unknown kind, a stream out of range or a full
  stream is refused with no result.
- A process result carries the frame count of the Opus packet's TOC byte
  (RFC 6716, section 3.1), clipped from first_frame, to frame_count and to
  the output, and zeros in the output. Nothing is decoded.
- xapu_chad_test covers result order, the full queue, the error codes,
  frame counts, silence and the event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fallback file list in build_runtime.ps1 must match the gta6rt sources
CMake has; xapu.cpp was missing, so test_build_runtime_fallback failed
and a build without CMake would have had no xapu.dll shim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main added its own runtime/shims/xapu.cpp: the boot stack's earlier xapu.dll stub, which gta6rt does not link and
xapu_test checks. This branch's xapu.dll command queue moves to runtime/shims/xapu_queue.cpp so both stay: gta6rt,
xapu_chad_test, the cl.exe fallback list in scripts/build_runtime.ps1 and the references in xapu_chad.cpp,
xapu_chad_test.cpp and docs/audio_hal_exe_calls.md name the new file; main's xapu.cpp and xapu_test are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GnGkjYHUWx92TkwvwCnAMe
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:40:05 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 19:13 UTC · original · approved these changes

Reviewed and verified. Cleanly splits xapu.dll into dedicated runtime/shims/xapu.cpp implementing command queue structures matching console layouts (XApuConnect input/output shapes, 24-byte command IDs, 0x50-byte results, and RFC 6716 Opus TOC frame counts). Audio remains cleanly silent without game data. Verified via xapu_chad_test (100% PASS). 100% clean-room compliant.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 19:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144#pullrequestreview-6045688589) · **approved these changes** Reviewed and verified. Cleanly splits `xapu.dll` into dedicated `runtime/shims/xapu.cpp` implementing command queue structures matching console layouts (`XApuConnect` input/output shapes, 24-byte command IDs, 0x50-byte results, and RFC 6716 Opus TOC frame counts). Audio remains cleanly silent without game data. Verified via `xapu_chad_test` (100% PASS). 100% clean-room compliant.
Author
Owner

@⁠madhyn on GitHub · 2026-11-24 19:31 UTC · original

Tested 370e52b8c on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build):

  • ctest --test-dir runtime/build/win -R "xapu" --output-on-failure: xapu_chad Passed (5.35 s)

AI-assisted: yes

**@⁠madhyn** on GitHub · 2026-11-24 19:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144#issuecomment-7142210763) Tested `370e52b8c` on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build): - `ctest --test-dir runtime/build/win -R "xapu" --output-on-failure`: `xapu_chad` **Passed** (5.35 s) AI-assisted: yes
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:13 UTC · original

Recommendation: [MERGE]

Reasoning: Moves xapu.dll out of xapu_chad.cpp into its own shim modelled as a command queue with the console's layouts (XApuConnect I/O, command ids, result size, error codes, Opus TOC frame count). Audio stays silent. The layouts are credited to a GPL-3.0-or-later project, which is compatible with this repo's GPL-3.0 licence. A moderate refactor (+608/-159) with an extended test, verified on Wine (xapu_chad passes). Once merged, the xapu half of #277 should be dropped. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 5/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144#issuecomment-7143215584) **Recommendation:** [MERGE] **Reasoning:** Moves `xapu.dll` out of `xapu_chad.cpp` into its own shim modelled as a command queue with the console's layouts (XApuConnect I/O, command ids, result size, error codes, Opus TOC frame count). Audio stays silent. The layouts are credited to a GPL-3.0-or-later project, which is compatible with this repo's GPL-3.0 licence. A moderate refactor (+608/-159) with an extended test, verified on Wine (`xapu_chad` passes). Once merged, the xapu half of #277 should be dropped. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 5/10
Author
Owner

@⁠espaciointoficial-sys on GitHub · 2026-11-24 21:22 UTC · original · reviewed

Read through the diff (not built or run here).

  • Blocking: shims/xapu.cpp is added to CMake's add_executable(gta6rt ...) but not to the cl.exe fallback list in scripts/build_runtime.ps1 (line 89, next to "shims\xapu_chad.cpp"). The fallback build would lose all five xapu.dll exports, and tests/test_build_runtime_fallback.py (test_the_launcher_compiles_every_source_cmake_gives_gta6rt) should flag shims\xapu.cpp as missing.
  • The Opus TOC parsing in opus_packet_frames() matches RFC 6716 §3.1.
  • Question: where do kMaxStreams = 500 and kMaxCommandsPerStream = 16 come from? If the title asks for more, XApuConnect now fails with E_INVALIDARG where the old shim succeeded.
  • Order with #1206 and #1078: after this one, #1206's registry comment ("the shims in xapu_chad.cpp") and #1078's "xapu_chad.cpp leaves open…" sentence are out of date.

The failing label check is the repository's needs-rebase labeler (#1250), not this PR. AI-assisted review (Claude Code).

**@⁠espaciointoficial-sys** on GitHub · 2026-11-24 21:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144#pullrequestreview-6047624150) · **reviewed** Read through the diff (not built or run here). - **Blocking:** `shims/xapu.cpp` is added to CMake's `add_executable(gta6rt ...)` but not to the cl.exe fallback list in `scripts/build_runtime.ps1` (line 89, next to `"shims\xapu_chad.cpp"`). The fallback build would lose all five `xapu.dll` exports, and `tests/test_build_runtime_fallback.py` (`test_the_launcher_compiles_every_source_cmake_gives_gta6rt`) should flag `shims\xapu.cpp` as missing. - The Opus TOC parsing in `opus_packet_frames()` matches RFC 6716 §3.1. - Question: where do `kMaxStreams = 500` and `kMaxCommandsPerStream = 16` come from? If the title asks for more, `XApuConnect` now fails with `E_INVALIDARG` where the old shim succeeded. - Order with #1206 and #1078: after this one, #1206's registry comment ("the shims in xapu_chad.cpp") and #1078's "`xapu_chad.cpp` leaves open…" sentence are out of date. The failing `label` check is the repository's needs-rebase labeler (#1250), not this PR. AI-assisted review (Claude Code).
Author
Owner

@⁠nicoco23 on GitHub · 2026-11-24 21:30 UTC · original

Thanks, both points are fair.

Fixed in 19559fec6: shims\xapu.cpp is now in the cl.exe fallback list in scripts/build_runtime.ps1 (before xapu_chad.cpp). test_the_launcher_compiles_every_source_cmake_gives_gta6rt failed on it before and python -I tests/test_build_runtime_fallback.py now passes. I ran that test, not the cl.exe fallback build itself.

On kMaxStreams = 500 and kMaxCommandsPerStream = 16: they are the validation bounds of VIctory's apu.rs (ffe310e), which runs the retail executable through these calls, so the title stays inside them there. I have not measured the retail call site for them myself, and the previous shim accepted any values. If a run shows the title asking for more, these two constants are the only thing to raise.

Noted on the order: once this merges, the registry comment in #1206 and the "xapu_chad.cpp leaves open" sentence in #1078 need a one-line update. I will do both right after.

**@⁠nicoco23** on GitHub · 2026-11-24 21:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144#issuecomment-7145012593) Thanks, both points are fair. Fixed in 19559fec6: shims\xapu.cpp is now in the cl.exe fallback list in scripts/build_runtime.ps1 (before xapu_chad.cpp). test_the_launcher_compiles_every_source_cmake_gives_gta6rt failed on it before and python -I tests/test_build_runtime_fallback.py now passes. I ran that test, not the cl.exe fallback build itself. On kMaxStreams = 500 and kMaxCommandsPerStream = 16: they are the validation bounds of VIctory's apu.rs (ffe310e), which runs the retail executable through these calls, so the title stays inside them there. I have not measured the retail call site for them myself, and the previous shim accepted any values. If a run shows the title asking for more, these two constants are the only thing to raise. Noted on the order: once this merges, the registry comment in #1206 and the "xapu_chad.cpp leaves open" sentence in #1078 need a one-line update. I will do both right after.
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 19:16 UTC · original

@⁠nicoco23 FYI: #2044 (RT-XAPU-OPUS-DECODE) is now stacked on this branch and only adds runtime/opus_decoder plus the decode inside fill_silence()/fill(); no layout or queue changes. I merged main into the stack because this head predates the slot-133 kernel_writes fix (title_page_watch.h:662) and the retail boot crashed early on the old base; with the merge the boot runs 121 s, session d, no faults, and decodes 256 streams. If you would rather fold the decoder into this PR, the crate + fill patch is ready to hand over.

**@⁠BubsMcgee** on GitHub · 2026-11-25 19:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144#issuecomment-7172070361) @⁠nicoco23 FYI: #2044 (RT-XAPU-OPUS-DECODE) is now stacked on this branch and only adds `runtime/opus_decoder` plus the decode inside `fill_silence()`/`fill()`; no layout or queue changes. I merged `main` into the stack because this head predates the slot-133 `kernel_writes` fix (`title_page_watch.h:662`) and the retail boot crashed early on the old base; with the merge the boot runs 121 s, session `d`, no faults, and decodes 256 streams. If you would rather fold the decoder into this PR, the crate + `fill` patch is ready to hand over.
github manually merged commit 4cfbdfc0b2 into main 2026-11-26 14:53:20 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 14:42 UTC · original

Thank you, @⁠nicoco23. Your xapu command queue went into main through #2350 (RT-LINUX-AMD-WORLD), as part of #2044, which was built on your head 6ee7ef89b. Your commits and authorship are kept. GitHub shows this PR as merged for that reason, so nothing needs closing.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

**@⁠aslan2142** on GitHub · 2026-11-26 14:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1144#issuecomment-7195195653) Thank you, @⁠nicoco23. Your xapu command queue went into `main` through #2350 (RT-LINUX-AMD-WORLD), as part of #2044, which was built on your head `6ee7ef89b`. Your commits and authorship are kept. GitHub shows this PR as merged for that reason, so nothing needs closing. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
This discussion has been locked. Commenting is limited to contributors.
No description provided.