Moved autoreleasepool into renderframe

This commit is contained in:
Attila Kocsis 2019-01-10 20:25:06 +01:00
parent 39e5cb858d
commit 5cdd4de559
3 changed files with 29 additions and 18 deletions

View File

@ -461,8 +461,11 @@ namespace entry
{
bgfx::renderFrame();
while (dispatchEvent(peekEvent() ) )
@autoreleasepool
{
while (dispatchEvent(peekEvent() ) )
{
}
}
}

View File

@ -12,6 +12,10 @@
#include "topology.h"
#if BX_PLATFORM_OSX
#include <objc/message.h>
#endif
BX_ERROR_RESULT(BGFX_ERROR_TEXTURE_VALIDATION, BX_MAKEFOURCC('b', 'g', 0, 1) );
namespace bgfx
@ -2182,11 +2186,31 @@ namespace bgfx
}
}
}
#if BX_PLATFORM_OSX
struct NSAutoreleasePoolScope
{
NSAutoreleasePoolScope()
{
id obj = class_createInstance(objc_getClass("NSAutoreleasePool"),0);
pool = objc_msgSend(obj, sel_getUid("init"));
}
~NSAutoreleasePoolScope()
{
objc_msgSend(pool, sel_getUid("release"));
}
id pool;
};
#endif
RenderFrame::Enum Context::renderFrame(int32_t _msecs)
{
BGFX_PROFILER_SCOPE("bgfx::renderFrame", 0xff2040ff);
#if BX_PLATFORM_OSX
NSAutoreleasePoolScope pool;
#endif
if (!m_flipAfterRender)
{
BGFX_PROFILER_SCOPE("bgfx/flip", 0xff2040ff);

View File

@ -639,18 +639,11 @@ namespace bgfx { namespace mtl
g_internalData.context = m_device;
#if BX_PLATFORM_OSX
m_pool = [[NSAutoreleasePool alloc] init];
#endif
return true;
}
void shutdown()
{
#if BX_PLATFORM_OSX
[m_pool release];
#endif
m_occlusionQuery.postReset();
m_gpuTimer.shutdown();
@ -1186,11 +1179,6 @@ namespace bgfx { namespace mtl
m_cmd.kick(true);
m_commandBuffer = 0;
#if BX_PLATFORM_OSX
[m_pool release];
m_pool = [[NSAutoreleasePool alloc] init];
#endif
}
void updateResolution(const Resolution& _resolution)
@ -2308,10 +2296,6 @@ namespace bgfx { namespace mtl
RenderCommandEncoder m_renderCommandEncoder;
ComputeCommandEncoder m_computeCommandEncoder;
FrameBufferHandle m_renderCommandEncoderFrameBufferHandle;
#if BX_PLATFORM_OSX
NSAutoreleasePool* m_pool;
#endif
};
RendererContextI* rendererCreate(const Init& _init)