From 9e82c18559842a53c93b8154173d7249eae8f198 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 18 Dec 2023 20:16:36 +1000 Subject: [PATCH] MetalDevice: Defer release of layer drawables --- src/util/metal_device.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/metal_device.mm b/src/util/metal_device.mm index a8d23cbfb..12618553f 100644 --- a/src/util/metal_device.mm +++ b/src/util/metal_device.mm @@ -394,11 +394,12 @@ void MetalDevice::RenderBlankFrame() @autoreleasepool { - id drawable = [m_layer nextDrawable]; + id drawable = [[m_layer nextDrawable] retain]; m_layer_pass_desc.colorAttachments[0].texture = [drawable texture]; id encoder = [m_render_cmdbuf renderCommandEncoderWithDescriptor:m_layer_pass_desc]; [encoder endEncoding]; [m_render_cmdbuf presentDrawable:drawable]; + DeferRelease(drawable); SubmitCommandBuffer(); } } @@ -2019,7 +2020,7 @@ void MetalDevice::EndPresent() EndAnyEncoding(); [m_render_cmdbuf presentDrawable:m_layer_drawable]; - [m_layer_drawable release]; + DeferRelease(m_layer_drawable); m_layer_drawable = nil; SubmitCommandBuffer(); TrimTexturePool();