From e13685369013f90e3a742c75675e7eaf67d3fe10 Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 24 Nov 2026 20:34:38 +0100 Subject: [PATCH 1/3] runtime: pin the DLL spellings the unimplemented-import policy classifies (TEST-POLICY-DLL-SPELLINGS) classify() matches DStorageGetFactory under dstorage.dll, dstorage_xs.dll and xcrdapi.dll, but unimplemented_policy_test only checked dstorage_xs.dll: removing the spelling the retail executable uses (XCRDAPI.dll) broke no test. The test now checks XCRDAPI.dll (retail case, so the lookup stays case-insensitive), dstorage.dll, and that another xcrdapi.dll name stays Other. xapu.dll and chad.dll were not in classify(), so under LEONIDA_UNIMPLEMENTED=fail an import of theirs without a shim returned 0 instead of E_NOTIMPL. classify() now names the nine functions whose shims in xapu_chad.cpp return an HRESULT; XApuGetResultCount returns uint32_t and stays Other. The test checks all ten, and audio_hal_exe_calls.md no longer says none of the audio calls is on the list. Co-Authored-By: Claude Opus 5.5 --- docs/audio_hal_exe_calls.md | 4 ++-- runtime/shims/registry.cpp | 9 +++++++++ runtime/test/unimplemented_policy_test.cpp | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/audio_hal_exe_calls.md b/docs/audio_hal_exe_calls.md index c04943c7d5..55cc395e4b 100644 --- a/docs/audio_hal_exe_calls.md +++ b/docs/audio_hal_exe_calls.md @@ -68,8 +68,8 @@ open pull request for it. Four of the calls above have a branch for a negative result: `AcpHalCreate`, `AcpHalAllocateShapeContexts`, `ApuCreateHeap` and `XApuDequeueResult`. An unimplemented import under `LEONIDA_UNIMPLEMENTED=log` returns 0, so a caller that tests for a negative result sees success with its outputs unset; under `fail` only imports `classify_import` -knows to return an `HRESULT` get `E_NOTIMPL`, and none of these four is on that list (it names only functions the public -documentation describes). So today neither mode makes the executable take its own failure path for the audio hardware. +knows to return an `HRESULT` get `E_NOTIMPL`; all four are on that list now (`runtime/shims/registry.cpp` names the +`AcpHal.dll`, `xapu.dll` and `chad.dll` functions whose shims return an `HRESULT`), but their shims serve them. So today neither mode makes the executable take its own failure path for the audio hardware. Whether the title survives that path, or needs the coprocessor, is **unmeasured**: it takes a run to find out, and the first run reported in #6603 stops earlier, in `D3D12ConfigureVirtualMemoryX`. diff --git a/runtime/shims/registry.cpp b/runtime/shims/registry.cpp index f041df89fd..7b0d29c88e 100644 --- a/runtime/shims/registry.cpp +++ b/runtime/shims/registry.cpp @@ -84,6 +84,7 @@ std::vector g_lookups; // xcrdapi.dll functions/dstoragegetfactory). dstorage_xs.dll is the console name; xcrdapi.dll is a // console module the title may import it from (docs/directstorage.md). dstorage.cpp serves // it; the class is kept for a build without that shim. +// xapu.dll, chad.dll the HRESULT returns of the shims in xapu_chad.cpp; XApuGetResultCount returns uint32_t. const char* const kNotHResult[] = { "XAsyncCancel", "XAsyncComplete", "XTaskQueueCloseHandle", "XTaskQueueDispatch", "XTaskQueueGetCurrentProcessTaskQueue", @@ -121,6 +122,14 @@ ReturnClass classify(const std::string& dll, const std::string& name) { name == "AcpHalReleaseShapeContexts" || name == "ApuAlloc" || name == "ApuCreateHeap") return ReturnClass::HResult; + } else if (dll == "xapu.dll") { + if (name == "XApuConnect" || name == "XApuDequeueResult" || name == "XApuDisconnect" || + name == "XApuEnqueueCommand") + return ReturnClass::HResult; + } else if (dll == "chad.dll") { + if (name == "XDspActivate" || name == "XDspConnectWithMaximumStreamLimit" || name == "XDspDeactivate" || + name == "XDspDisconnect" || name == "XDspSubmitCommand") + return ReturnClass::HResult; } else if (dll == "xgameruntime.dll") { if (name == "XGameRuntimeInitialize" || name == "XGameEventWrite") return ReturnClass::HResult; for (const char* n : kNotHResult) diff --git a/runtime/test/unimplemented_policy_test.cpp b/runtime/test/unimplemented_policy_test.cpp index 8941901296..0c69a1c18e 100644 --- a/runtime/test/unimplemented_policy_test.cpp +++ b/runtime/test/unimplemented_policy_test.cpp @@ -231,6 +231,17 @@ void test_classification() { check(cls("gameinput.dll", "GameInputCreate") == ReturnClass::HResult, "GameInputCreate is hresult"); check(cls("dstorage_xs.dll", "DStorageGetFactory") == ReturnClass::HResult, "the console dstorage name is hresult"); + check(cls("XCRDAPI.dll", "DStorageGetFactory") == ReturnClass::HResult, + "the retail spelling XCRDAPI.dll is hresult, case-insensitively"); + check(cls("dstorage.dll", "DStorageGetFactory") == ReturnClass::HResult, "the PC dstorage name is hresult"); + check(cls("xcrdapi.dll", "DStorageGetFactoryLeonidaPolicyProbe") == ReturnClass::Other, + "another xcrdapi import is other"); + for (const char* name : {"XApuConnect", "XApuDequeueResult", "XApuDisconnect", "XApuEnqueueCommand"}) + check(cls("xapu.dll", name) == ReturnClass::HResult, name); + check(cls("xapu.dll", "XApuGetResultCount") == ReturnClass::Other, "XApuGetResultCount returns uint32_t"); + for (const char* name : {"XDspActivate", "XDspConnectWithMaximumStreamLimit", "XDspDeactivate", "XDspDisconnect", + "XDspSubmitCommand"}) + check(cls("chad.dll", name) == ReturnClass::HResult, name); check(cls("xg_xs.dll", "XGCreateTexture2DComputer") == ReturnClass::Other, "unmeasured xg_xs import is other"); check(cls("acphal.dll", "AcpHalCreate") == ReturnClass::HResult, "AcpHalCreate is hresult"); check(cls("acphal.dll", "ApuFree") == ReturnClass::Other, "ApuFree returns void"); From ef55ee5828ebc3f7fce7ab16929ace6b7cdeaa2a Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 24 Nov 2026 22:33:02 +0100 Subject: [PATCH 2/3] docs: wrap the audio_hal_exe_calls.md paragraph at 120 columns (review of #1206) Only the line breaks of the "What the executable already does about a failure" paragraph change; the words are the same. Co-Authored-By: Claude Opus 5.5 --- docs/audio_hal_exe_calls.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/audio_hal_exe_calls.md b/docs/audio_hal_exe_calls.md index 55cc395e4b..2195803b3e 100644 --- a/docs/audio_hal_exe_calls.md +++ b/docs/audio_hal_exe_calls.md @@ -66,12 +66,13 @@ open pull request for it. ## What the executable already does about a failure Four of the calls above have a branch for a negative result: `AcpHalCreate`, `AcpHalAllocateShapeContexts`, -`ApuCreateHeap` and `XApuDequeueResult`. An unimplemented import under `LEONIDA_UNIMPLEMENTED=log` returns 0, so a caller -that tests for a negative result sees success with its outputs unset; under `fail` only imports `classify_import` +`ApuCreateHeap` and `XApuDequeueResult`. An unimplemented import under `LEONIDA_UNIMPLEMENTED=log` returns 0, so a +caller that tests for a negative result sees success with its outputs unset; under `fail` only imports `classify_import` knows to return an `HRESULT` get `E_NOTIMPL`; all four are on that list now (`runtime/shims/registry.cpp` names the -`AcpHal.dll`, `xapu.dll` and `chad.dll` functions whose shims return an `HRESULT`), but their shims serve them. So today neither mode makes the executable take its own failure path for the audio hardware. -Whether the title survives that path, or needs the coprocessor, is **unmeasured**: it takes a run to find out, and the -first run reported in #6603 stops earlier, in `D3D12ConfigureVirtualMemoryX`. +`AcpHal.dll`, `xapu.dll` and `chad.dll` functions whose shims return an `HRESULT`), but their shims serve them. So today +neither mode makes the executable take its own failure path for the audio hardware. Whether the title survives that +path, or needs the coprocessor, is **unmeasured**: it takes a run to find out, and the first run reported in #6603 stops +earlier, in `D3D12ConfigureVirtualMemoryX`. ## What this does not show From ef12c755616c82d8f9cdfb739dfe4fb29db38745 Mon Sep 17 00:00:00 2001 From: Nico Date: Thu, 26 Nov 2026 17:22:57 +0100 Subject: [PATCH 3/3] registry: name xapu_queue.cpp and xapu_chad.cpp now that #1144 is merged (review of #1206) --- runtime/shims/registry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/shims/registry.cpp b/runtime/shims/registry.cpp index 9dcb064287..eeb9e4bdac 100644 --- a/runtime/shims/registry.cpp +++ b/runtime/shims/registry.cpp @@ -84,7 +84,8 @@ std::vector g_lookups; // xcrdapi.dll functions/dstoragegetfactory). dstorage_xs.dll is the console name; xcrdapi.dll is a // console module the title may import it from (docs/directstorage.md). dstorage.cpp serves // it; the class is kept for a build without that shim. -// xapu.dll, chad.dll the HRESULT returns of the shims in xapu_chad.cpp; XApuGetResultCount returns uint32_t. +// xapu.dll, chad.dll the HRESULT returns of the shims in xapu_queue.cpp (xapu.dll) and xapu_chad.cpp +// (chad.dll); XApuGetResultCount returns uint32_t.XApuGetResultCount returns uint32_t. const char* const kNotHResult[] = { "XAsyncCancel", "XAsyncComplete", "XTaskQueueCloseHandle", "XTaskQueueDispatch", "XTaskQueueGetCurrentProcessTaskQueue",