From 17385d6f1d913b8d7259f53f063b75161be2fd6f Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:32:24 +0100 Subject: [PATCH] ImGui: add render frame stage and scope mutex --- src/gameui/imgui_system.cpp | 9 +++++++-- src/gameui/imgui_system.h | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gameui/imgui_system.cpp b/src/gameui/imgui_system.cpp index 31225d5c..4d9343b0 100644 --- a/src/gameui/imgui_system.cpp +++ b/src/gameui/imgui_system.cpp @@ -149,8 +149,13 @@ void CImguiSystem::RenderFrame() if (m_systemInitState < ImguiSystemInitStage_e::IM_FRAME_SWAPPED) return; - AUTO_LOCK(m_snapshotBufferMutex); - ImGui_ImplDX11_RenderDrawData(&m_snapshotData.DrawData); + { + AUTO_LOCK(m_snapshotBufferMutex); + ImGui_ImplDX11_RenderDrawData(&m_snapshotData.DrawData); + } + + if (m_systemInitState == ImguiSystemInitStage_e::IM_FRAME_SAMPLED) + m_systemInitState = ImguiSystemInitStage_e::IM_FRAME_RENDERED; } //----------------------------------------------------------------------------- diff --git a/src/gameui/imgui_system.h b/src/gameui/imgui_system.h index 4c6e701e..aa8121fd 100644 --- a/src/gameui/imgui_system.h +++ b/src/gameui/imgui_system.h @@ -44,7 +44,10 @@ private: // State gets set to this then buffers have been swapped for the first // time. - IM_FRAME_SWAPPED + IM_FRAME_SWAPPED, + + // Rendered for the first time. + IM_FRAME_RENDERED }; ImguiSystemInitStage_e m_systemInitState;