From 7c01136247fb9400b712350627f53e45a42ccebd Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sun, 26 Feb 2023 18:31:19 -0600 Subject: [PATCH] hwr2: Imgui EndFrame if we didn't Render fixes a failed ImGui assertion in Debug builds --- src/i_video_common.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/i_video_common.cpp b/src/i_video_common.cpp index 93d73f7a1..ef02a7643 100644 --- a/src/i_video_common.cpp +++ b/src/i_video_common.cpp @@ -54,6 +54,7 @@ struct InternalPassData static std::unique_ptr g_passes; static Rhi* g_last_known_rhi = nullptr; +static bool g_imgui_frame_active = false; Handle srb2::sys::g_current_rhi = kNullHandle; @@ -220,6 +221,7 @@ static InternalPassData build_pass_manager() [](PassManager&, Rhi& rhi) {}, [framebuffer_manager](PassManager&, Rhi& rhi) { + g_imgui_frame_active = false; rhi.present(); rhi.finish(); framebuffer_manager->reset_post(); @@ -322,11 +324,16 @@ void I_NewTwodeeFrame(void) void I_NewImguiFrame(void) { - // TODO move this to srb2loop + if (g_imgui_frame_active) + { + ImGui::EndFrame(); + g_imgui_frame_active = false; + } ImGuiIO& io = ImGui::GetIO(); io.DisplaySize.x = vid.realwidth; io.DisplaySize.y = vid.realheight; ImGui::NewFrame(); + g_imgui_frame_active = true; } static void maybe_reinit_passes(Rhi* rhi)