mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Fixed shutdown sequence.
This commit is contained in:
parent
06314151c5
commit
c5a03233c0
2 changed files with 12 additions and 6 deletions
13
src/bgfx.cpp
13
src/bgfx.cpp
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue