runtime: chad.dll with the console's DSP layouts, outputs silent (RT-CHAD-DSP-LAYOUTS) #2363

Closed
nicoco23 wants to merge 1 commit from upstream-pr/2363 into main
nicoco23 commented 2026-11-26 15:36:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by nicoco23 on 2026-11-26T15:36:11Z.


Builds on #1144 (merged via #2350): runtime/shims/xapu_chad.cpp, which now serves only chad.dll, replaces its two HYPOTHESIS (zeroed status owned by the connection, *id left at 0) with the console's layouts. No new file.

This takes over the chad half of draft #277, as #1144 took its xapu half; cc @Andretuta.

Source of the layouts

Signatures, structure layouts, limits and error codes come from Marvisak/VIctory, crates/victory-hle/src/modules/dsp.rs at commit ffe310e (GPL-3.0-or-later, compatible with this project's licence). Facts only, no code copied (see docs/related_projects.md); the top of xapu_chad.cpp lists them. They fit the call shapes measured statically in docs/audio_hal_exe_calls.md: the title's 0x80 is the stream limit, XDspActivate's outputs are a 16-byte status block and the stream, and the title's wait reads the last completed ticket (+4) and its result (+0xc).

What changes

  • XDspConnectWithMaximumStreamLimit: bounds on base, base_bytes (0x10000..0x1F400000), ir_seconds (≤0x80), max_streams (≤0x100), max_channels (≤2) → E_INVALIDARG, then null out → E_POINTER.
  • XDspActivate: description rules (kind, frames, channels, options 0x2/0x4/0x8), stream limit → E_OUTOFMEMORY, a per-stream status block starting zeroed with S_OK.
  • XDspSubmitCommand: completes at once; writes frames × channels zero floats to the output and advances submitted/completed with interlocked stores.
  • XDspDeactivate / XDspDisconnect: released or unknown handles refused with E_INVALIDARG (HYPOTHESIS); disconnect releases streams still active.
  • No convolution is computed (impulse-response layout unknown): reverb returns stay dry.
  • Docs: docs/runtime_imports.md and docs/audio_hal_exe_calls.md.

Tested

Windows 11, scripts/build_runtime.ps1 -FetchSdl3 (CMake + Ninja, MSVC; no cargo). No GPU involved.

  • xapu_chad_test: 108 checks, 0 failures (bounds, description rules, status block, tickets, silence, handle lifetime)
  • xapu_test 18/0, chad_test 12/0, unimplemented_policy_test 104/0
  • tests/test_docs_*.py, tests/test_text_write_line_endings.py, scripts/check_no_game_data.py: OK
  • The cl.exe fallback build was not exercised; not run against the retail package.

Item: RT-CHAD-DSP-LAYOUTS
Depends on: #1144 (merged)

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5512909465 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2363). Originally posted by [nicoco23](https://github.com/nicoco23) on 2026-11-26T15:36:11Z. --- Builds on #1144 (merged via #2350): `runtime/shims/xapu_chad.cpp`, which now serves only `chad.dll`, replaces its two HYPOTHESIS (zeroed status owned by the connection, `*id` left at 0) with the console's layouts. No new file. This takes over the chad half of draft #277, as #1144 took its xapu half; cc @Andretuta. ## Source of the layouts Signatures, structure layouts, limits and error codes come from Marvisak/VIctory, `crates/victory-hle/src/modules/dsp.rs` at commit `ffe310e` (GPL-3.0-or-later, compatible with this project's licence). Facts only, no code copied (see `docs/related_projects.md`); the top of `xapu_chad.cpp` lists them. They fit the call shapes measured statically in `docs/audio_hal_exe_calls.md`: the title's `0x80` is the stream limit, `XDspActivate`'s outputs are a 16-byte status block and the stream, and the title's wait reads the last completed ticket (+4) and its result (+0xc). ## What changes - `XDspConnectWithMaximumStreamLimit`: bounds on base, base_bytes (0x10000..0x1F400000), ir_seconds (≤0x80), max_streams (≤0x100), max_channels (≤2) → `E_INVALIDARG`, then null out → `E_POINTER`. - `XDspActivate`: description rules (kind, frames, channels, options 0x2/0x4/0x8), stream limit → `E_OUTOFMEMORY`, a per-stream status block starting zeroed with S_OK. - `XDspSubmitCommand`: completes at once; writes frames × channels zero floats to the output and advances submitted/completed with interlocked stores. - `XDspDeactivate` / `XDspDisconnect`: released or unknown handles refused with `E_INVALIDARG` (HYPOTHESIS); disconnect releases streams still active. - No convolution is computed (impulse-response layout unknown): reverb returns stay dry. - Docs: `docs/runtime_imports.md` and `docs/audio_hal_exe_calls.md`. ## Tested Windows 11, `scripts/build_runtime.ps1 -FetchSdl3` (CMake + Ninja, MSVC; no cargo). No GPU involved. - `xapu_chad_test`: 108 checks, 0 failures (bounds, description rules, status block, tickets, silence, handle lifetime) - `xapu_test` 18/0, `chad_test` 12/0, `unimplemented_policy_test` 104/0 - `tests/test_docs_*.py`, `tests/test_text_write_line_endings.py`, `scripts/check_no_game_data.py`: OK - The cl.exe fallback build was not exercised; not run against the retail package. Item: RT-CHAD-DSP-LAYOUTS Depends on: #1144 (merged) AI-assisted (Claude Code).
lixonik commented 2026-11-26 15:40:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:40:26Z.

Review: COMMENTED


Windows 11/MSVC: xapu_chad passed all 108 synthetic checks. The suite covers connection and stream boundaries, independent status blocks, silent output and ticket completion, and release/disconnect behavior. Title boot was outside this run.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6076918460 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2363#pullrequestreview-6076918460). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T15:40:26Z. **Review:** COMMENTED --- Windows 11/MSVC: `xapu_chad` passed all 108 synthetic checks. The suite covers connection and stream boundaries, independent status blocks, silent output and ticket completion, and release/disconnect behavior. Title boot was outside this run. AI-assisted.
OreoFR commented 2026-11-26 23:48:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-26T23:48:42Z.

Review: COMMENTED


Read through on main d1dff7949 (static review, no build, no retail run). The code is clean: live handles tracked and refused once released, interlocked stores on the status block, no throwing new, and 108 checks in xapu_chad_test. Two points before merge:

  1. New refusals on values the title was never measured passing. Before, XDspConnectWithMaximumStreamLimit accepted anything. It now returns E_INVALIDARG for base_bytes outside 0x10000..0x1F400000, ir_seconds above 0x80 or max_channels above 2. XDspActivate likewise applies VIctory's description rules. Only the fourth argument (0x80) is measured at the call site (docs/audio_hal_exe_calls.md); the old test passed 0, 0 for the two before it. If the retail call is outside these bounds, the title takes its failure path for the DSP, which nobody has run yet (the same doc calls that path unmeasured). Suggestion: have note() record all the arguments (today it only records max_streams), and do one --trace run with the retail executable before the bounds are enforced. Or log-and-accept until then.
  2. XDspSubmitCommand's third argument. The table in docs/audio_hal_exe_calls.md reads "two arguments, both taken from registers", but the shim now writes *ticket through a third one. The shim's own header speaks of an *id the title zeroes, so it is probably there. If the call site only sets two registers, though, that store goes through whatever is in r8. Could you confirm from the call site and align the doc row?

The rest (completion at once, silent output of frames × channels floats, handle lifetimes) reads right to me. AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6081665040 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2363#pullrequestreview-6081665040). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-26T23:48:42Z. **Review:** COMMENTED --- Read through on `main` `d1dff7949` (static review, no build, no retail run). The code is clean: live handles tracked and refused once released, interlocked stores on the status block, no throwing `new`, and 108 checks in `xapu_chad_test`. Two points before merge: 1. **New refusals on values the title was never measured passing.** Before, `XDspConnectWithMaximumStreamLimit` accepted anything. It now returns `E_INVALIDARG` for `base_bytes` outside 0x10000..0x1F400000, `ir_seconds` above 0x80 or `max_channels` above 2. `XDspActivate` likewise applies VIctory's description rules. Only the fourth argument (`0x80`) is measured at the call site (`docs/audio_hal_exe_calls.md`); the old test passed `0, 0` for the two before it. If the retail call is outside these bounds, the title takes its failure path for the DSP, which nobody has run yet (the same doc calls that path unmeasured). Suggestion: have `note()` record all the arguments (today it only records `max_streams`), and do one `--trace` run with the retail executable before the bounds are enforced. Or log-and-accept until then. 2. **`XDspSubmitCommand`'s third argument.** The table in `docs/audio_hal_exe_calls.md` reads "two arguments, both taken from registers", but the shim now writes `*ticket` through a third one. The shim's own header speaks of an `*id` the title zeroes, so it is probably there. If the call site only sets two registers, though, that store goes through whatever is in `r8`. Could you confirm from the call site and align the doc row? The rest (completion at once, silent output of frames × channels floats, handle lifetimes) reads right to me. AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-11-29 13:23:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T13:23:39Z.


@DadaCap the same DSP layouts are already in the Rust HLE (leonida-hle/src/modules/dsp.rs:84-91, :163). Is the C++ xapu_chad path still needed? If not, this can close.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256504443 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2363#issuecomment-7256504443). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T13:23:39Z. --- @DadaCap the same DSP layouts are already in the Rust HLE (leonida-hle/src/modules/dsp.rs:84-91, :163). Is the C++ xapu_chad path still needed? If not, this can close.
aslan2142 commented 2026-12-01 12:32:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:32:04Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311269479 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2363#issuecomment-7311269479). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:32:04Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 17:25:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:25:37Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319279834 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2363#issuecomment-7319279834). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:25:37Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!2363
No description provided.