mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-08-10 23:29:43 +00:00
Fix: reset s_renderFrameCalled in bgfx::shutdown() to allow re-init (#3690)
bgfx::renderFrame() sets s_renderFrameCalled = true on its first call (line 1541) and never clears it. bgfx::shutdown() resets s_threadIndex to 0 (line 3958) but leaves s_renderFrameCalled sticky, which means that on a 2nd renderFrame after shutdown the gate at line 1534 still runs BGFX_CHECK_RENDER_THREAD(). That assertion checks (s_ctx != NULL && single-threaded) || (~BGFX_API_THREAD_MAGIC == s_threadIndex); both branches fail post-shutdown (s_ctx is NULL, s_threadIndex is 0), and the assertion fires in debug builds — blocking re-init of the bgfx context within the same process. Adding the symmetric s_renderFrameCalled reset to shutdown() makes shutdown leave bgfx in the same state as a fresh process, so a subsequent renderFrame()+init() pair behaves like the first one. Verified locally: a downstream test that constructs an SDL+bgfx context, runs a frame, destroys it, then constructs another from the same thread now passes in debug builds with this patch (it asserts at line 1536 without it).
This commit is contained in:
@@ -3956,6 +3956,7 @@ namespace bgfx
|
||||
}
|
||||
|
||||
s_threadIndex = 0;
|
||||
s_renderFrameCalled = false;
|
||||
g_callback = NULL;
|
||||
g_allocator = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user