Repository navigation
runtime: xapu.dll and chad.dll shims, connections that succeed with an empty result queue (RT-489) - #6981
runtime: xapu.dll and chad.dll shims, connections that succeed with an empty result queue (RT-489)#6981Jadiac5 wants to merge 4 commits into
Conversation
|
Static check at
The No Windows ctest here, so this is static confirmation only. No game data: counts, offsets and RVAs only. AI-assisted. |
|
Tested
Details: #6910 (comment). AI-assisted (Claude Code). |
8f8fb2b to
e6515ea
Compare
…d.dll shims) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/runtime_imports.md # runtime/CMakeLists.txt
On top of ItsNotRexed#6981, from the public GDK reference (xapu.h, XDspAudio.h on docs.xbox.com) checked against the executable's call sites (static read): - XApuConnect takes the 24-byte block as input and leaves it alone; base data is baseDataLength bytes, zeroed; no result-ready event (the title does not ask for one). - Every XApu command gets exactly one result with its id, visible from the second XApuGetResultCount after the enqueue (the title stores a stream's state only after the enqueue returns and polls from another job). Without results the title's stream slots never return to their free list. - A process command is answered with one frame of silence in its output buffer, bounded by its capacity and the base data; the 0x50-byte result is the packed XApuResult, outputDataLength at +0x34. An empty queue is XAPU_E_PENDING_RESULTS. - XDspActivate hands out a zeroed XDspStatus per stream (the voice path reads it with no NULL check); XDspSubmitCommand returns sequences 1, 2, ... and marks each processed in that block, which the title waits for before the next submit. Status blocks are pooled, never freed. - The documented error codes for refused calls (stream limit, clients, invalid command or stream index, handles still active). - build_runtime.ps1's cl.exe fallback lists acphal.cpp and xapu_chad.cpp, which tests/test_build_runtime_fallback.py requires. xapu_chad_test drives all ten in the title's shapes, with commands against a no-access page, and one thread enqueuing 20000 commands while another polls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto main AI-assisted (Claude Code). |
|
Tested
|
|
Tested |
|
Thanks for the test and the finding. Fixed in
AI-assisted (Claude Code). |
…shapes - XGCreateTextureComputer: fix signature from 4 args (desc, device, riid, out) to the measured 2 args (desc, out**). The out pointer arrives in RDX, not R9 — the old 4-arg version wrote through a stale register as textureComputer, which the two callers that ignore the HRESULT would use as a null/wild vtable call. Now returns a static computer with a proper vtable (AddRef/Release for slot 0/1, E_NOTIMPL for all other slots with a one-time log). - XGSuggestSwizzleMode: fix signature from 2 args (desc, mode*) to the measured 3 args (desc, flags, mode*). The mode* arrives in R8, not RDX, so *mode = 0 was previously writing to a wrong register. Now returns E_NOTIMPL and writes nothing (the caller already zeroed the field). - AcpHalCreate: replace the non-dereferenceable id<<4 handle with a static object with a proper vtable (IAcpHal COM-like interface). Any method call through it logs once per slot and returns E_NOTIMPL instead of faulting. Both fixes match the measured call shapes documented in the overlapping PRs ItsNotRexed#6891 and ItsNotRexed#6981 and verified by reviewers. AI-assisted: yes
|
Tested Built |
|
Verified at your rebased head e6515ea: merges clean into 8575d36 (the old docs/runtime_imports.md conflict vs #6715 is gone). The shims register through SHIM_TABLE so owns_dll picks both DLLs up without loader changes, and the call shapes match the independently measured docs/audio_hal_exe_calls.md (#6899, tools/import_call_sites.py): 8 xapu + 5 chad sites, the 0x80 stream limit, result queue semantics all consistent; buffer-size guesses are honestly marked HYPOTHESIS. Three things before merge: (1) your own docs/runtime_imports.md:141-142 still says "the other 22 are in five DLLs ... with no shim at all" — that sentence now contradicts this PR (xapu and chad are shimmed here); fix its count and list in the same PR; (2) cite tools/import_call_sites.py for the "read statically from the executable's call sites" claim, matching #6899's convention; (3) XApuDisconnect's shape comment omits the measured second argument 0x20 that audio_hal_exe_calls.md records. C++ not buildable here; xapu_chad_test runs in the windows CI job. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run, C++ review-only). |
|
Re-tested at |
Update xapu.cpp and chad.cpp to use the measured argument shapes from the executable (PR ItsNotRexed#6981) instead of GDK-documented struct-based signatures that mismatch the real call site register layout. xapu.cpp: - XApuConnect: (void* out24, void* out16, void** handle) — 3 raw pointers matching the measured call, not the GDK struct types. Removed the XApuConnectInputParameters/OutputParameters structs that were reading garbage from arg1. - XApuEnqueueCommand: (handle, cmd*, uint64_t flags) — 3rd arg is flags (always 0 at call sites), not totalCommandCount*. - XApuGetResultCount: (handle, uint64_t flags) — 2nd arg is flags, not totalResultCount*. - XApuDequeueResult: (handle, out*) — no arity change. - XApuDisconnect: (handle) — no arity change. chad.cpp: - XDspActivate: (handle, u64, u64, u64, u64) — 5 args (was 4). The measured call passes 4 extra uint64_t values; our old 4-arg version read status/streamHandle from the wrong registers. - XDspDeactivate: (handle, u64, u64, u64) — 4 args (was 1). - XDspSubmitCommand: (void*, void*) — 2 args (was 3 with commandSeq). Also fix chad_test.cpp to pass baseBufferLength >= 0x10000 so the shim's validation doesn't reject it, and update error code expectations (E_POINTER for null handle, not E_INVALIDARG). Fix acphal_test.cpp APU_ADDRESS struct ordering (must be defined before the using declarations that reference it). AI-assisted: yes
|
New head
Not run against the retail executable. AI-assisted (Claude Code). |
|
Tested Setup. The head merged alone onto Tests
Retail exe (
The only change in the dry-run list is the ten imports this PR serves: the five Not tested: native Windows/MSVC, and the retail AI-assisted (Claude Code). cc @shayderrr |
|
Heads-up from comparing this with the 1.0.2.1 executable's call sites (details and RVAs in #7599 (comment)):
Static analysis only (our boot does not reach audio yet). AI-assisted (Claude Code). |
Integrate DirectStorage from upstream PR ItsNotRexed#4348 and adapt memory/connection code from ItsNotRexed#6885 and ItsNotRexed#6981. Reject unsupported audio commands instead of reporting successful processing. Validate with synthetic CPU tests under Wine; game execution remains untested.
|
AI-assisted: yes Independent verification on rebased head
Verdict: PASS on |
Retain a fork-only sample comparison for the XAPU owner. A system Media Foundation transform can decode these packets without a separate Rust crate or workflow. Refs: ItsNotRexed#6981, ItsNotRexed#8598
|
@Jadiac5, a Windows backend is available for the type-3 path in All 5,760 float samples from the four original packets agreed with FFmpeg’s native Opus decoder to a maximum absolute error of 0.000000119. Swapping the two stereo packets preserved both output lengths and raised the sample error to 0.46968, failing the comparison. The Windows SDK and the system decoder supplied the decode path. FFmpeg generated the test inputs and reference. Windows probe · Fixture generator To reproduce from that fork commit in an x64 Visual Studio Developer PowerShell with FFmpeg on PATH: $source = (Get-Location).Path
$scratch = Join-Path $env:TEMP ([Guid]::NewGuid().ToString())
python -I "$source/runtime/test/opus_mft_fixture.py" $scratch
Push-Location $scratch
cl /nologo /std:c++20 /EHsc /MD /O2 /DNOMINMAX "$source/runtime/test/opus_mft_probe.cpp" /Fe:opus_mft_probe.exe mfplat.lib mfuuid.lib ole32.lib
.\opus_mft_probe.exe
Pop-LocationThis was a decoder-level test on Windows 11 Home 25H2 build 26200.9974, Intel Core Ultra 7 265K, MSVC 19.44. The GeForce RTX 5070 (621.01) was idle. A check through the XAPU shim would submit a type-3 command, compare its destination samples and verify the completion’s stream ID and produced-byte count. The title’s live connection mode, playback and Wine support remain unmeasured here. AI-assisted by GPT-6.2 Astra. |
# Conflicts: # docs/runtime_imports.md # runtime/CMakeLists.txt
|
Tested 3d3ff20 (merged onto main 867d922) on RTX 5070, NVIDIA 621.24, Windows 11 (build 26200), Vulkan validation layer on (
Ran the tests that belong to the test files this PR changes (ctest entries, or the test program directly when it is not registered), with no game files ( |
|
checked: #69813d3ff20 | with: AI-assisted (Claude Code). |
|
An offer on top of this PR, not a competing one: one commit that makes the connections behave the way the retail executable's call sites expect. seblessa@67a35f69c (branch It follows the public GDK reference (
AI-assisted (Claude Code). |
runtime: xapu.dll and chad.dll shims, connections that succeed with an empty result queue (RT-489) Independent review: ItsNotRexed#6981 (comment) Fork integration. AI-assisted (Codex).
|
Tested Merged onto @tibzejoker's With #6885 and this PR, the run that faulted in the title's memset after the missing Traces stay local; only outcomes, slot numbers and public formats here. AI-assisted (Claude Code). |
…onnections that succeed with an empty result queue (RT-489) Squashed from ItsNotRexed#6981 by Jadiac5, head eaeee26 (security scan PASS). Conflicts in runtime/CMakeLists.txt and docs/runtime_imports.md with ItsNotRexed#6885: kept both sides.
|
Tested Boot integration datapoint (base
Control: without the audio shims the same build stops earlier at a deterministic AV in the audio-object initialization ( |
LaugeM
left a comment
There was a problem hiding this comment.
Read at 3d3ff20e against main 5d74c2723. This should be the xapu.dll and chad.dll shim that lands, together with #6885 for AcpHal. XDspActivate (runtime/shims/xapu_chad.cpp:178-185) hands back two zeroed 256-byte blocks of the connection. The title's wait after XDspSubmitCommand (status +0xc == 0 and +4 == *id) holds on that memory as long as the id it compares is 0. #7009's XDspActivate writes no outputs, and #8848's status block holds the descriptor's block size at +0xc. The type 1 and 2 echo in XApuEnqueueCommand (:130) is also what keeps the title's 256 stream ids from running out, and #7009 doesn't have it.
Still open at this head:
- Types 3 and 5 get no result (
xapu_chad.cpp:130). SweatierKey and jeremygold02 read the type 5 (flush) command as moving the stream to a state that only a type 5 result leaves. A type 3 result carries the output byte count at+0x34. With no echo for either, a stream that is flushed once stays stuck, and a decode never reports completion. That doesn't block boot, but it is the next stop once audio streams play. Plausible (their static reads). - One status block per connection (
:75-78,:183-184). EveryXDspActivateon a connection gets the samestatusandstreampointers. That is harmless while nothing writes them. Once a command really completes, each stream needs its own block, or one stream's completion reads as another's. - The fallback
$fileslist inscripts/build_runtime.ps1:84still lacksshims\xapu_chad.cpp(Hiiva raised it).test_build_runtime_fallback.pywill report it, on top of main's existingxg_xs.cppmiss.
Merge note: #8848's description says this PR covers only xapu.dll, but SHIM_TABLE(chad, …) here registers all five chad.dll names. Only one of the two can land.
AI-assisted review (Opus 5.5). Read the diff against main; not built.
Item: RT-489, shims for
xapu.dllandchad.dll(claimed in #6750 (comment)).What the imports are for
xapu.dllis the console's audio processing unit (APU) command queue andchad.dllits audio DSP. #6715 liststheir ten imports among the 30 the retail executable calls with no binding. A PC has neither unit.
What the call sites show
Read statically from the executable (never run or mapped). Each import is reached through one jump stub; the
direct callers:
XApuConnect: 1 site, three pointer arguments (a 24-byte global of the title, a 16-byte output, and a handle).Success is read as
SUCCEEDED. The first qword of the 16-byte output is used later as the base of a CPU-visiblebuffer: stream input at a 0x280-byte stride from the base, stream output at a 0x1E00-byte stride from
base + 0x14000. Other title code also addresses the 24-byte global, so it may be an input.
XApuEnqueueCommand: 4 sites, (handle, pointer to a stack-built command, 0). The command's first dword is a type(1, 2 and 3 seen), the second a stream slot. The return value is never read.
XApuGetResultCount: 1 site, (handle, 0). 0 skips the dequeue loop.XApuDequeueResult: 1 site, (handle, pointer to a zeroed 0x50-byte local), called count times; a negativeresult skips that entry. The loop reads a type at +0 and a stream slot at +4. A type 1 result marks the stream
opened; a type 2 result, after the title enqueued a type 2 command, returns the stream id to the title's free
list.
XApuDisconnect: 1 site, one argument (the handle global, cleared after); the return value is not read.XDspConnectWithMaximumStreamLimit: 1 site, six arguments (a buffer from the title'sXMemAlloc, two dwords,0x80,1, a handle output). Success is a return of 0.XDspActivate: 1 site, (handle, pointer to a local description, two output pointers into the caller's object).Success is a return of 0, else the caller returns -1. The title later reads dwords at +4 and +0xc through one
output with no null check and passes the other to
XDspSubmitCommand.XDspSubmitCommand: 1 site, (the stream fromXDspActivate, a command, pointer to an id the title zeroed).Success is a return of 0. The title then waits until the status dword at +0xc is 0 and the one at +4 equals the
id.
XDspDeactivate,XDspDisconnect: 1 tail jump each; the caller returns what they return.What each function does now
New file
runtime/shims/xapu_chad.cpp, registered likexmem.dll(soowns_dllcovers both DLLs for run-timeLoadLibrarytoo):XApuConnect: allocates a zeroed shared buffer, writes{base, size}to the 16-byte output, leaves the 24-byteglobal untouched and returns
S_OKwith a handle.E_INVALIDARGwithout a handle pointer.XApuEnqueueCommand:S_OK. A type 1 (open) or type 2 (close) command queues one result of the same type andslot; nothing is processed.
XApuGetResultCount: the number of queued results.XApuDequeueResult: writes the type and slot of the oldestone;
E_FAILwithout writing when the queue is empty.XApuDisconnect: frees the buffer and the handle,S_OK.XDspConnectWithMaximumStreamLimit: a handle andS_OK.XDspActivate: writes both outputs as pointers tozeroed memory the connection owns,
S_OK.XDspSubmitCommand:S_OK, the id stays the title's 0, which thezeroed status already reports as done.
XDspDeactivate:S_OK.XDspDisconnect: frees the handle,S_OK.--trace, the first call of each function and the first command of each type is anaudio_queueevent,with the caller.
The effect is silent audio: the title's buffers are accepted and nothing is rendered into them.
Hypotheses (also in the file's comment):
DSP connect passes 0x80 as its stream limit; no call site shows a bound.
console is not measured. Only the first two dwords are written. Other command types give no result, so a stream
that waits for a type 5 result keeps waiting.
XDspActivate's outputs, and that an id of 0 with a status of 0 readsas "done".
Tests
xapu_chad_test(new, in ctest asxapu_chad): 33 checks, 0 failures. It resolves all ten through the registry,checks
owns_dll, the connect output, that the 24-byte block is untouched, that the buffer is zeroed and writableat the end of slot 127, three command types, the two results they queue, the empty queue after, and the DSP calls
in their call-site shapes, including the two
XDspActivateoutputs and what the title's wait reads.xapu_chad,xmem,process_cmdline,file_system,unimplemented_policy,winhttp_offline: 6/6 passed.gta6rtbuilds with the new file.python -I tests/test_docs_repo_paths.py: OK.python -I scripts/check_no_game_data.py: exit 0.Not tested
dequeue loop).
static read only.
Related: #6899 documents the same call sites. It is docs only, so this PR does not depend on it. One difference:
it reads a second argument
0x20forXApuDisconnect; here that0x20goes to anXMemFreecall just before, andthe disconnect site loads only the handle.
Tested on Windows 11, MSVC 19.44, AMD Radeon RX 9070 XT, driver 32.0.32029.2010 (no GPU is used by these tests).
AI-assisted (Claude Code).