From 099ddfedc7def7150fde5b15d80e23aa5d57b53b Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sun, 23 Jan 2022 22:10:04 -0600 Subject: [PATCH] GS:Mac: Properly init vulkan on main thread --- common/Vulkan/SwapChain.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/Vulkan/SwapChain.cpp b/common/Vulkan/SwapChain.cpp index fc0d6834d0..1a7a4b2bce 100644 --- a/common/Vulkan/SwapChain.cpp +++ b/common/Vulkan/SwapChain.cpp @@ -28,6 +28,7 @@ #if defined(__APPLE__) #include +#include #ifdef __i386__ typedef float CGFloat; @@ -52,6 +53,14 @@ Ret msgsend(Self self, const char* sel, Args... args) static bool CreateMetalLayer(WindowInfo* wi) { + // if (![NSThread isMainThread]) + if (!msgsend(objc_getClass("NSThread"), "isMainThread")) + { + __block bool ret; + dispatch_sync(dispatch_get_main_queue(), ^{ ret = CreateMetalLayer(wi); }); + return ret; + } + id view = reinterpret_cast(wi->window_handle); Class clsCAMetalLayer = objc_getClass("CAMetalLayer");