diff --git a/pcsx2/Frontend/MetalHostDisplay.mm b/pcsx2/Frontend/MetalHostDisplay.mm index 5f46b050f9..6e257ea48d 100644 --- a/pcsx2/Frontend/MetalHostDisplay.mm +++ b/pcsx2/Frontend/MetalHostDisplay.mm @@ -83,6 +83,9 @@ bool MetalHostDisplay::HasRenderSurface() const { return static_cast(m_la void MetalHostDisplay::AttachSurfaceOnMainThread() { ASSERT([NSThread isMainThread]); + m_layer = MRCRetain([CAMetalLayer layer]); + [m_layer setDrawableSize:CGSizeMake(m_window_info.surface_width, m_window_info.surface_height)]; + [m_layer setDevice:m_dev.dev]; m_view = MRCRetain((__bridge NSView*)m_window_info.window_handle); [m_view setWantsLayer:YES]; [m_view setLayer:m_layer]; @@ -94,6 +97,7 @@ void MetalHostDisplay::DetachSurfaceOnMainThread() [m_view setLayer:nullptr]; [m_view setWantsLayer:NO]; m_view = nullptr; + m_layer = nullptr; } bool MetalHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, VsyncMode vsync, bool threaded_presentation, bool debug_device) @@ -137,9 +141,6 @@ bool MetalHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view { OnMainThread([this] { - m_layer = MRCRetain([CAMetalLayer layer]); - [m_layer setDrawableSize:CGSizeMake(m_window_info.surface_width, m_window_info.surface_height)]; - [m_layer setDevice:m_dev.dev]; AttachSurfaceOnMainThread(); }); SetVSync(vsync);