Skip to content

Commit

Permalink
MetalDevice: Fix render command encoder leak
Browse files Browse the repository at this point in the history
and subsequent crash on shutdown.
  • Loading branch information
stenzek committed Aug 24, 2023
1 parent 08acc31 commit 1b9e72e
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/util/metal_device.mm
Expand Up @@ -1829,21 +1829,23 @@ static void DumpShader(u32 n, const std::string_view& suffix, const std::string_
m_inline_upload_encoder = nil;
}

MTLRenderPassDescriptor* desc;
if (!m_current_framebuffer)
{
// Rendering to view, but we got interrupted...
desc = [MTLRenderPassDescriptor renderPassDescriptor];
desc.colorAttachments[0].texture = [m_layer_drawable texture];
desc.colorAttachments[0].loadAction = MTLLoadActionLoad;
}
else
{
desc = m_current_framebuffer->GetDescriptor();
}
@autoreleasepool {
MTLRenderPassDescriptor* desc;
if (!m_current_framebuffer)
{
// Rendering to view, but we got interrupted...
desc = [MTLRenderPassDescriptor renderPassDescriptor];
desc.colorAttachments[0].texture = [m_layer_drawable texture];
desc.colorAttachments[0].loadAction = MTLLoadActionLoad;
}
else
{
desc = m_current_framebuffer->GetDescriptor();
}

m_render_encoder = [m_render_cmdbuf renderCommandEncoderWithDescriptor:desc];
SetInitialEncoderState();
m_render_encoder = [[m_render_cmdbuf renderCommandEncoderWithDescriptor:desc] retain];
SetInitialEncoderState();
}
}

void MetalDevice::EndRenderPass()
Expand Down

0 comments on commit 1b9e72e

Please sign in to comment.