ImguiSystem: perform atomic exchange before acquiring snapshot lock

Significantly improves performance when none of the imgui surfaces are being drawn.
This commit is contained in:
Kawe Mazidjatari 2024-11-15 20:33:57 +01:00
parent 4d2ac77ac7
commit e2b931d6d8
2 changed files with 3 additions and 4 deletions

View File

@ -155,13 +155,12 @@ void CImguiSystem::SwapBuffers()
void CImguiSystem::RenderFrame()
{
Assert(IsInitialized());
AUTO_LOCK(m_snapshotBufferMutex);
if (!m_hasNewFrame)
if (!m_hasNewFrame.exchange(false))
return;
AUTO_LOCK(m_snapshotBufferMutex);
ImGui_ImplDX11_RenderDrawData(&m_snapshotData.DrawData);
m_hasNewFrame = false;
}
//-----------------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ private:
mutable CThreadMutex m_inputEventQueueMutex;
bool m_initialized;
bool m_hasNewFrame;
std::atomic_bool m_hasNewFrame;
};
CImguiSystem* ImguiSystem();