GS:Mac: Properly init vulkan on main thread

This commit is contained in:
TellowKrinkle 2022-01-23 22:10:04 -06:00 committed by refractionpcsx2
parent d9e2bcef6d
commit 099ddfedc7
1 changed files with 9 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#if defined(__APPLE__) #if defined(__APPLE__)
#include <objc/message.h> #include <objc/message.h>
#include <dispatch/dispatch.h>
#ifdef __i386__ #ifdef __i386__
typedef float CGFloat; typedef float CGFloat;
@ -52,6 +53,14 @@ Ret msgsend(Self self, const char* sel, Args... args)
static bool CreateMetalLayer(WindowInfo* wi) static bool CreateMetalLayer(WindowInfo* wi)
{ {
// if (![NSThread isMainThread])
if (!msgsend<BOOL, Class>(objc_getClass("NSThread"), "isMainThread"))
{
__block bool ret;
dispatch_sync(dispatch_get_main_queue(), ^{ ret = CreateMetalLayer(wi); });
return ret;
}
id view = reinterpret_cast<id>(wi->window_handle); id view = reinterpret_cast<id>(wi->window_handle);
Class clsCAMetalLayer = objc_getClass("CAMetalLayer"); Class clsCAMetalLayer = objc_getClass("CAMetalLayer");