fix memory leak for metal app

This commit is contained in:
coulsonwang 2019-09-19 15:31:05 +08:00
parent 302007976a
commit e9a33903f0
2 changed files with 3 additions and 0 deletions

View File

@ -195,6 +195,7 @@ private:
dispatch_semaphore_t _frameBoundarySemaphore;
RenderPassDescriptor _prevRenderPassDescriptor;
NSAutoreleasePool* _autoReleasePool = nil;
};
// end of _metal group

View File

@ -220,6 +220,7 @@ CommandBufferMTL::~CommandBufferMTL()
void CommandBufferMTL::beginFrame()
{
_autoReleasePool = [[NSAutoreleasePool alloc] init];
dispatch_semaphore_wait(_frameBoundarySemaphore, DISPATCH_TIME_FOREVER);
_mtlCommandBuffer = [_mtlCommandQueue commandBuffer];
@ -366,6 +367,7 @@ void CommandBufferMTL::endFrame()
[_mtlCommandBuffer commit];
[_mtlCommandBuffer release];
DeviceMTL::resetCurrentDrawable();
[_autoReleasePool drain];
}
void CommandBufferMTL::afterDraw()