Repository navigation
Conversation
… imports (RT-5 follow-up) Adds 21 shim imports across 4 new DLL shims: - chad.dll (5): XDspActivate, XDspConnectWithMaximumStreamLimit, XDspDeactivate, XDspDisconnect, XDspSubmitCommand — XDSP hardware audio DSP, accepts connections/activations and drops commands - xapu.dll (5): XApuConnect, XApuDequeueResult, XApuDisconnect, XApuEnqueueCommand, XApuGetResultCount — audio processing unit, accepts commands and reports no pending results - xg_xs.dll (2): XGCreateTextureComputer, XGSuggestSwizzleMode — texture tiling/suggestion, returns linear mode and E_NOTIMPL for the texture computer - AcpHal.dll (9): AcpHalAllocateShapeContexts, AcpHalCreate, AcpHalReleaseShapeContexts, ApuAlloc, ApuCreateHeap, ApuFree, ApuIsVirtualAddressValid, ApuMapApuAddress, ApuMapVirtualAddress — audio control processor HAL with APU heap from VirtualAlloc All API signatures from the public GDK reference at devdocs.xbox.com. HRESULT classification added to registry.cpp for all families. Also fixes a crash in library_loader::host_module_name when called from CRT init (DllMain/TLS callback) where std::map new failed because the CRT heap wasn't ready yet - replaced with a stack buffer. Dry-run against the retail executable now reports 9 unimplemented imports (down from 30). The remaining 9 are xmem, d3d12_xs and XCRDAPI imports already covered by open PRs. AI-assisted: yes
|
Tested a6692f4 on NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 (26200), MSVC 2022 RelWithDebInfo: dry run passes, one test regresses, and Retail
Smaller note: the Code read otherwise: no process, network or registry calls; the shims allocate with AI-assisted (Claude Code). |
devnull34
left a comment
There was a problem hiding this comment.
Verified on Windows 11 (MSVC RelWithDebInfo):
- Built
gta6rt.execleanly with the new shims (chad.cpp,xapu.cpp,xg_xs.cpp,acphal.cpp). - Validated
library_loader::host_module_namestack buffer fix and HRESULT classification inregistry.cpp. run_tiny_gdk_loadCTest passed 100% (0.09s).gta6rt.exe --dry-runagainst synthetic guest executable ran cleanly with 0 unimplemented imports.- Python tests
test_gdk_runtime_calls.pyandtest_exe_checklist.pypassed all 30 tests in 0.536s. - Whitespace clean (
git diff HEAD~1..HEAD --check).
|
Tested a6692f4 on Windows 11 Pro 10.0.26100, MSVC 19.51 (VS 18), using my own copy of the same executable (SHA-256
So the shim set works as claimed. Note this PR overlaps #6885, #6981 and #6891 (AcpHal / xapu+chad / xg_xs); a single merge here would cover all four DLLs. Only counts, argument constants and exception classes are reported; no code, strings or bytes from the executable. AI-assisted (opencode). |
|
Built and ran this on Linux (clang-cl 23.1.5 + xwin Win11 SDK 10.0.26100, wine-11.22) applied alone to |
…on, test expectation, revert library_loader - Replace empty SHAPE context structs (1 byte each) with GDK-documented field layouts so sizeof() returns the real per-context stride: SHAPE_XMA_CONTEXT 64 B, SHAPE_SRC_CONTEXT 32 B, SHAPE_PCM_CONTEXT 32 B, SHAPE_FILTVOL_CONTEXT 32 B, SHAPE_DMA_CONTEXT 16 B, SHAPE_EQCOMP_CONTEXT 352 B. Prevents heap overflow when the title writes through the real stride (e.g. memset xmaContextArray with 64-byte stride into a 1-byte-element allocation). - Remove the src == pcm + xma validation in AcpHalAllocateShapeContexts. The title calls with numSrcContexts=0, numXmaContexts=350, numPcmContexts=0 (XMA allocated independently), which failed the check and returned E_INVALIDARG. Accept any combination. - Remove stray 'S_OK;' dead statement in XGSuggestSwizzleMode. - Update unimplemented_policy_test: replace the 'unmeasured acphal import is other' expectation with proper checks for the newly classified imports across chad, xapu, xg_xs, and acphal DLLs. - Revert library_loader.cpp to the original cached-map implementation. The stack-buffer change is unrelated to the audio/DSP shims and belongs in its own PR. AI-assisted: yes
|
Thanks for the thorough review, @dadsmallbuk1. All three issues are fixed:
Also removed a stray dead Tested (same conditions as before): cross-built with clang-cl + xwin on Linux. The dry-run still shows 9 unimplemented imports (down from 30), and |
|
One independent build-integration finding remains at On the previous head |
|
Tested
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
|
@Spacecer2, thanks for the careful read. The two arity blockers and the AcpHalCreate handle issue are fixed in commit e86d997: 1.
2.
3.
|
|
Retested at e86d997 (same machine: RTX 5090, driver 617.42, Windows 11 26200, MSVC 2022 RelWithDebInfo): pass.
Thanks for the quick turnaround. AI-assisted (Claude Code). |
|
Tested 390ade8 on Windows 11 26H2 (26300), MSVC 19.44.35229 (v143) + Ninja, RelWithDebInfo: Overlap with #6981 is silent if both merge. This PR's Measured locally: I added #6981's Suggestion, independent of which of the two lands: make AI-assisted (Claude Code). |
….gitignore - Add chad.cpp, xapu.cpp, xg_xs.cpp, acphal.cpp to the standalone cl.exe source list in scripts/build_runtime.ps1. The CMake target already listed them, but the fallback PowerShell build used by first_look.ps1 omitted them, causing test_build_runtime_fallback.py to fail 1/8. - Revert .gitignore addition of .xwin-cache/. It is unrelated to the audio/DSP shims and belongs in its own commit. AI-assisted: yes
|
@wasonidas, good catch. Fixed in commit 651395d: added the four new shim sources (chad.cpp, xapu.cpp, xg_xs.cpp, acphal.cpp) to the standalone cl.exe source list in scripts/build_runtime.ps1, and reverted the unrelated .gitignore change. The fallback list now matches the CMake target. |
Four new test executables exercising the registered shim exports through the registry, matching the pattern of xmem_test: - xg_xs_test: resolves both exports, verifies the corrected arity (2-arg XGCreateTextureComputer, 3-arg XGSuggestSwizzleMode), and exercises the computer's vtable at the measured slots (1, 2, 8, 10). - xapu_test: resolves all 5 xapu.dll exports through rt::shims::find, covers connect/enqueue/result-count/dequeue/disconnect with the measured argument shapes and the hypothesized buffer layout. - chad_test: resolves all 5 chad.dll exports, covers connect/activate/submit/deactivate/disconnect with the measured 6-arg connect and the return-value-as-success pattern. - acphal_test: resolves all 9 acphal.dll exports, covers AcpHalCreate (dereferenceable vtable object), AcpHalAllocateShapeContexts (title's real arg values, struct-by-stride write), ApuCreateHeap, ApuAlloc alignment, ApuIsVirtualAddressValid, and the APU address mapping round-trip. All four are registered in CMakeLists.txt as build targets and CTest entries (xg_xs, xapu, chad, acphal). AI-assisted: yes
|
Test files added in commit fddca8e:
All four are registered in CMakeLists as build targets and CTest entries ( |
|
Tested this PR's four shims (acphal, chad, xapu, xg_xs at e86d997) inside a local stack of #7132 + #6919 on the retail 1.0.2.1 package, Windows 11, MSVC 14.50. Dry-run: 0 unimplemented imports, 5 modules mapped.
AI-assisted. No game data (no addresses, RVAs, strings or dumps beyond 'pointer into ASCII data'). |
|
Tested Build failure
Remaining targets (built individually via
|
|
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
|
@gabrielcruzg3, thanks for catching those build/test failures. All three fixed in commit 654d499:
This was the same class of bug as the xg_xs arity issue identified by Spacecer2 — the GDK doc signatures don't match the actual call site register layout. The same pass checked for similar issues and fixed (5→4 args) and (3→2 args) arities. |
Integrates the non-merge commits of upstream PR ItsNotRexed#4348 (f87d05f, c77338e, ac1843d), resolving build lists and import-policy tests alongside PR ItsNotRexed#7009. Adds the existing 258-check DirectStorage regression target to the fork's integration build. AI-assisted integration. Local fallback-build tests: 8 passed; GDK inspection tests: 23 passed; no-game-data and diff checks passed. Compression and GPU destinations remain unsupported as documented upstream.
|
Tested 654d499 on Windows 11, MSVC 19.44.35217 (VS 2022 17.14), no GPU used: build fails.
the build completes. Then:
AI-assisted (Claude Code). |
|
Retested Build failure
Remaining targets (built via
|
- Fix APU_ADDRESS struct comparison: map_virtual(nullptr) returns a struct, can't compare with == 0. Use .value == 0 instead. - Fix SHAPE_CONTEXTS xmaContextArray pointer offset: the struct has 6 uint32_t (24 B) then 6 pointers (no padding because 24 is already 8-byte aligned). xmaContextArray is at offset 56 (uint64_t index 7), not index 4. The old index 4 read eqCompContextArray which was unassigned (nullptr). AI-assisted: yes
|
Thanks for the detailed test report. Two bugs fixed in fd64853:
|
Shims for chad, xapu, xg_xs and AcpHal. Conflicts: unimplemented_policy_test keeps ItsNotRexed#4348's xcrdapi checks and takes ItsNotRexed#7009's classifications for xg_xs and acphal (now registered, so AcpHalCreate is an HRESULT); build_runtime.ps1's cl.exe source list takes ItsNotRexed#7009's four shims plus ItsNotRexed#4348's dstorage.cpp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…slot Two test bugs from ItsNotRexed#7009: APU_ADDRESS is a struct, so the null check compares its value, and xmaContextArray sits after the six 32-bit counts (pointer slot 3 + 4), not at pointer slot 4 (which is dmaContextArray, null here). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Retested
AI-assisted testing. |
throny
left a comment
There was a problem hiding this comment.
Tested fd64853 on Windows 11, MSVC 14.44, NVIDIA RTX 4080: tests pass, dry-run 22 → 1 unimplemented; one defect in ApuAlloc (reproduction below).
Setup: fd648533 merged onto main 0656b0b2 (clean merge). Built with CMake + Ninja, RelWithDebInfo, VS 2022 BuildTools.
ctest (full suite, -j 6):
main 0656b0b2 |
this PR merged | |
|---|---|---|
| tests | 270 | 275 (+5: xg_xs, xapu, chad, acphal; unimplemented_policy changed) |
| failed | 3: d3d12_vulkan_device, d3d12_indirect_dispatch_count, d3d12_bindless_churn_validated |
2: d3d12_vulkan_device, d3d12_indirect_dispatch_count |
Both failures with the PR also fail on main. The GPU was in use by another job, so those Vulkan results say nothing about this PR. xg_xs, xapu, chad, acphal and unimplemented_policy pass.
The previous head 654d4999 did not compile: acphal_test.cpp:167 compared an APU_ADDRESS with 0 (C2678). Its XMA check also read pointer index 4 (eqCompContextArray) instead of 7. fd648533 fixes both.
Negative control: I built the four new test files against main's registry.cpp without the new shim sources. All four exit 1: xg_xs 3 FAIL, xapu 6, chad 6, acphal 10. In each case the exports aren't found and the registry doesn't own the DLL.
gta6rt --dry-run game_scarlett_master.exe (own 1.0.2.1 copy, --game-dir the package, overlay outside it):
| shim | unimplemented | |
|---|---|---|
| main | 61 | 22 |
| this PR | 82 | 1 |
Per DLL (unimplemented → shim): chad.dll 5 → 5, xapu.dll 5 → 5, xg_xs.dll 2 → 2, AcpHal.dll 9 → 9. Only XCRDAPI.dll!DStorageGetFactory remains unimplemented, now under the HRESULT policy through the xcrdapi.dll line added in registry.cpp. On the other four mapped modules, unimplemented stays 0.
Defect: the cached and non-cached APU heaps share one bump offset (runtime/shims/acphal.cpp:455-457). ApuAlloc keeps a single static uint64_t bump_offset and checks it against the size of whichever heap the flags pick. Cached allocations therefore use up the non-cached heap's space: after enough cached allocations, a non-cached one fails even though the non-cached heap is empty. Reproduction (probe linked against this PR's acphal.cpp and registry.cpp, through rt::shims::find):
ApuCreateHeap(4 MiB, 0x226e00) -> 0x00000000
ApuAlloc(&c, nullptr, 3 MiB, 0x800, 0 /*cached*/) -> 0x00000000
ApuAlloc(&n, nullptr, 0x1000, 0x800, 1 /*noncached*/) -> 0x8007000e (E_OUTOFMEMORY), n = null
Before that limit is reached, a non-cached block still starts at the shared offset into the smaller heap, so space is wasted. The fix is one offset per heap.
Related, on the same path (acphal.cpp:434-442): after ApuCreateHeap(size, 0), a non-cached ApuAlloc finds heap_base null and creates a default heap. That overwrites g_apu_cached_base/g_apu_cached_size, so the first heap leaks, and ApuIsVirtualAddressValid returns FALSE for blocks allocated from it earlier. The title's call passes a non-zero non-cached size (per this PR's test comment), so this path may not be hit at boot. A non-cached request on a heap without a non-cached part should fail instead.
Other notes
registry.cpp:108classifiesApuMapApuAddressas HRESULT, but it returnsvoid*. This only matters under the unimplemented policy, which no longer applies to it here.ApuMapVirtualAddressreturns the full 64-bit host pointer as theAPU_ADDRESS. The PR's own comment calls the console's address 40-bit. Whether the title masks or stores it in a narrower field isn't measured; if it does,ApuMapApuAddresswon't round-trip. Hypothesis only.- Overlap: #6981 registers the same
xapu.dll/chad.dllexports (SHIM_TABLE(xapu),SHIM_TABLE(chad)inxapu_chad.cpp), and #6885/#6891 cover AcpHal and xg_xs. Only one of each set can land. - Still stubs: no audio is processed. XDsp/XApu commands are dropped, the XApu result queue is always empty,
XGCreateTextureComputer/XGSuggestSwizzleModereturnE_NOTIMPL, theIAcpHalslots past 1 returnE_NOTIMPL, andApuFreefrees nothing.
AI-assisted.
|
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). |
ASSET-587 (was RT-AGENTS-AUDIO-SHIMS). Claimed in #6750.
What and why
The retail
game_scarlett_master.exeimports 30 functions from seven Xbox-only DLLs, of which 21 are from four DLLs with no shim in the repository:chad.dll,xapu.dll,xg_xs.dllandAcpHal.dll. The other six (xmem.dll, d3d12_xs.dll, XCRDAPI.dll) already have open PRs (#6803, #5253, #5381, #6792, #4348).This adds shims for all 21, removing them from the unimplemented list. The dry-run report now shows 9 unimplemented imports (down from 30).
Changes
Four new shim files and three unchanged ones that ship with the runtime tests:
runtime/shims/chad.cppruntime/shims/xapu.cppruntime/shims/xg_xs.cppruntime/shims/acphal.cppEach shim:
E_NOTIMPLfor XGCreateTextureComputer (no tiling hardware on PC)Supporting changes:
runtime/shims/registry.cpp: HRESULT classification for all four DLL familiesruntime/CMakeLists.txt: source file registrationruntime/shims/library_loader.cpp: fixed null-map crash inhost_module_namewhen called from CRT init (the static std::map allocated withnewcrashed when the CRT heap was not initialised yet)Tested
gta6rt --dry-run game_scarlett_master.exe: 30 → 9 unimplemented imports, all 21 new imports show asshimgta6rt --init game_scarlett_master.exe: exit 0, all DllMain and TLS callbacks passgta6rt --run game_scarlett_master.exe: boots past the audio/ACP initialization, stops atd3d12_xs.dll!D3D12ConfigureVirtualMemoryX(PR d3d12_xs: D3D12ConfigureVirtualMemoryX shim (first unimplemented call of the title) #6792)AI-assisted: yes