From fccf11b66bef32cbb03fbc2ae52409dace994210 Mon Sep 17 00:00:00 2001 From: Fr0gzilla <242606097+Fr0gzilla@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:10:34 +0100 Subject: [PATCH] fix(macos_host): answer D3D12CreateDevice (d3d12.dll #101) with DXGI_ERROR_UNSUPPORTED There is no Microsoft D3D12 on the host, as there is no DXGI (CreateDXGIFactory1 already answers DXGI_ERROR_UNSUPPORTED). d3d12.lib imports D3D12CreateDevice as ordinal 101, which the host did not export, so a test that tries to create a host device for comparison stopped at an unimplemented import instead of taking its own "no host device" path. d3d12_fence_timing_test is one: GetCustomHeapProperties creates a default-adapter device to compare with. Tested on an Apple M5 (macOS 26.6, MoltenVK 1.4.2): d3d12_fence_timing_test passes with the matching test change, and the other D3D12 tests keep their results. --- runtime/macos_host/kernel32_crt.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/macos_host/kernel32_crt.cpp b/runtime/macos_host/kernel32_crt.cpp index d832e6bf10..685658dc64 100644 --- a/runtime/macos_host/kernel32_crt.cpp +++ b/runtime/macos_host/kernel32_crt.cpp @@ -693,6 +693,13 @@ int32_t CreateDXGIFactory1(const void*, void** out) { return static_cast(0x887A0004); // DXGI_ERROR_UNSUPPORTED } +// Nor a Microsoft D3D12 device (d3d12.lib imports D3D12CreateDevice as ordinal 101): tests that compare with one +// skip that part when creating it fails, as they do on a Windows host without one. +int32_t D3D12CreateDevice(void*, int32_t, const void*, void** out) { + if (out) *out = nullptr; + return static_cast(0x887A0004); // DXGI_ERROR_UNSUPPORTED +} + // d3d12.dll's own debug layer does not exist here (d3d12.lib imports it as ordinal 102). int32_t D3D12GetDebugInterface(const void*, void** out) { *out = nullptr; @@ -802,7 +809,7 @@ Exports kernel32_crt_exports() { K(GetSystemInfo), K(GetNativeSystemInfo), K(GetCurrentProcessorNumber), K(FlushProcessWriteBuffers), K(GetCurrentThread), K(DuplicateHandle), K(SwitchToThread), K(AddVectoredExceptionHandler), K(EncodePointer), K(CreateEventW), K(CreateEventA), K(CreateEventExW), K(CreateSemaphoreW), K(CreateSemaphoreExW), K(SetEvent), K(ResetEvent), K(AreFileApisANSI), K(FormatMessageA), K(LocalFree), K(GetTempPathW), - EXPORT("ntdll.dll", wine_get_version), EXPORT("dxgi.dll", CreateDXGIFactory1), EXPORT_AS("d3d12.dll", "#102", D3D12GetDebugInterface), EXPORT_AS("gameinput.dll", "#1", GameInputCreate), K(CreateMutexA), K(ReleaseMutex), K(InitializeCriticalSection), EXPORT_AS("kernel32.dll", "SetThreadPriority", set_ok), EXPORT_AS("kernel32.dll", "SetProcessPriorityBoost", set_ok), EXPORT_AS("kernel32.dll", "GetThreadPriority", thread_priority), EXPORT_AS("kernel32.dll", "ResumeThread", resume_thread), EXPORT_AS("kernel32.dll", "SuspendThread", suspend_thread), K(GetThreadGroupAffinity), K(SetThreadGroupAffinity), K(GetProcessId), K(OpenProcess), K(OpenThread), K(GetUserDefaultGeoName), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-0.dll", "RegisterAppStateChangeNotification", register_app_notification), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-0.dll", "UnregisterAppStateChangeNotification", unregister_app_notification), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-1.dll", "RegisterAppConstrainedChangeNotification", register_app_notification), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-1.dll", "UnregisterAppConstrainedChangeNotification", unregister_app_notification), EXPORT_AS("msvcp140.dll", "?_Random_device@std@@YAIXZ", random_device), EXPORT("gameinput.dll", GameInputCreate), K(ReleaseSemaphore), K(WaitForSingleObjectEx), K(WaitForSingleObject), K(WaitForMultipleObjects), K(ExitThread), K(FreeLibraryAndExitThread), + EXPORT("ntdll.dll", wine_get_version), EXPORT("dxgi.dll", CreateDXGIFactory1), EXPORT_AS("d3d12.dll", "#101", D3D12CreateDevice), EXPORT_AS("d3d12.dll", "#102", D3D12GetDebugInterface), EXPORT_AS("gameinput.dll", "#1", GameInputCreate), K(CreateMutexA), K(ReleaseMutex), K(InitializeCriticalSection), EXPORT_AS("kernel32.dll", "SetThreadPriority", set_ok), EXPORT_AS("kernel32.dll", "SetProcessPriorityBoost", set_ok), EXPORT_AS("kernel32.dll", "GetThreadPriority", thread_priority), EXPORT_AS("kernel32.dll", "ResumeThread", resume_thread), EXPORT_AS("kernel32.dll", "SuspendThread", suspend_thread), K(GetThreadGroupAffinity), K(SetThreadGroupAffinity), K(GetProcessId), K(OpenProcess), K(OpenThread), K(GetUserDefaultGeoName), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-0.dll", "RegisterAppStateChangeNotification", register_app_notification), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-0.dll", "UnregisterAppStateChangeNotification", unregister_app_notification), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-1.dll", "RegisterAppConstrainedChangeNotification", register_app_notification), EXPORT_AS("api-ms-win-core-psm-appnotify-l1-1-1.dll", "UnregisterAppConstrainedChangeNotification", unregister_app_notification), EXPORT_AS("msvcp140.dll", "?_Random_device@std@@YAIXZ", random_device), EXPORT("gameinput.dll", GameInputCreate), K(ReleaseSemaphore), K(WaitForSingleObjectEx), K(WaitForSingleObject), K(WaitForMultipleObjects), K(ExitThread), K(FreeLibraryAndExitThread), K(GetExitCodeThread), EXPORT("advapi32.dll", OpenProcessToken), EXPORT("advapi32.dll", OpenThreadToken), K(DecodePointer), }; }