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");