Skip to content

Commit

Permalink
MetalDevice: Defer release of layer drawables
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Dec 18, 2023
1 parent f4fb069 commit 9e82c18
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/util/metal_device.mm
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,12 @@ static void RunOnMainThread(F&& f)

@autoreleasepool
{
id<MTLDrawable> drawable = [m_layer nextDrawable];
id<MTLDrawable> drawable = [[m_layer nextDrawable] retain];
m_layer_pass_desc.colorAttachments[0].texture = [drawable texture];
id<MTLRenderCommandEncoder> encoder = [m_render_cmdbuf renderCommandEncoderWithDescriptor:m_layer_pass_desc];
[encoder endEncoding];
[m_render_cmdbuf presentDrawable:drawable];
DeferRelease(drawable);
SubmitCommandBuffer();
}
}
Expand Down Expand Up @@ -2019,7 +2020,7 @@ static void DumpShader(u32 n, const std::string_view& suffix, const std::string_
EndAnyEncoding();

[m_render_cmdbuf presentDrawable:m_layer_drawable];
[m_layer_drawable release];
DeferRelease(m_layer_drawable);
m_layer_drawable = nil;
SubmitCommandBuffer();
TrimTexturePool();
Expand Down

0 comments on commit 9e82c18

Please sign in to comment.