Fixed shutdown sequence.

This commit is contained in:
Branimir Karadžić 2015-04-06 18:22:15 -07:00
parent 06314151c5
commit c5a03233c0
2 changed files with 12 additions and 6 deletions

View file

@ -819,6 +819,10 @@ namespace bgfx
BGFX_CHECK_RENDER_THREAD();
if (s_ctx->renderFrame() )
{
Context* ctx = s_ctx;
ctx->gameSemWait();
s_ctx = NULL;
ctx->renderSemPost();
return RenderFrame::Exiting;
}
@ -1054,15 +1058,18 @@ namespace bgfx
m_declRef.shutdown(m_vertexDeclHandle);
#if BGFX_CONFIG_MULTITHREADED
// Render thread shutdown sequence.
renderSemWait(); // Wait for previous frame.
gameSemPost(); // OK to set context to NULL.
// s_ctx is NULL here.
renderSemWait(); // In RenderFrame::Exiting state.
if (m_thread.isRunning() )
{
m_thread.shutdown();
}
#endif // BGFX_CONFIG_MULTITHREADED
s_ctx = NULL; // Can't be used by renderFrame at this point.
renderSemWait();
m_submit->destroy();
m_render->destroy();

View file

@ -1934,11 +1934,10 @@ namespace bgfx
{
}
static int32_t renderThread(void* _userData)
static int32_t renderThread(void* /*_userData*/)
{
BX_TRACE("render thread start");
Context* ctx = (Context*)_userData;
while (!ctx->renderFrame() ) {};
while (RenderFrame::Exiting != bgfx::renderFrame() ) {};
BX_TRACE("render thread exit");
return EXIT_SUCCESS;
}