From 59334894566db4135a8ecd974150171556aaa155 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 26 Dec 2025 01:56:00 +1000 Subject: [PATCH] ImGuiManager: Reduce possible false sharing when adding events --- src/util/imgui_manager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/imgui_manager.cpp b/src/util/imgui_manager.cpp index 82eedfb3e..31dadb57e 100644 --- a/src/util/imgui_manager.cpp +++ b/src/util/imgui_manager.cpp @@ -127,17 +127,23 @@ namespace { struct ALIGN_TO_CACHE_LINE State { + // Shared between both threads + // cached copies of WantCaptureKeyboard/Mouse, used to know when to dispatch events std::atomic_bool imgui_wants_keyboard{false}; std::atomic_bool imgui_wants_mouse{false}; std::atomic_bool imgui_wants_text{false}; + std::array software_cursors = {}; + std::deque osd_posted_messages; std::mutex osd_messages_lock; - // Owned by GPU thread + // Read by both threads ALIGN_TO_CACHE_LINE ImGuiContext* imgui_context = nullptr; - Timer::Value last_render_time = 0; + + // Owned by GPU thread + ALIGN_TO_CACHE_LINE Timer::Value last_render_time = 0; float global_scale = 0.0f; float window_width = 0.0f; @@ -156,8 +162,6 @@ struct ALIGN_TO_CACHE_LINE State std::deque osd_active_messages; float osd_messages_end_y = 0.0f; - std::array software_cursors = {}; - TextFontOrder text_font_order = ImGuiManager::GetDefaultTextFontOrder(); std::array, static_cast(TextFont::MaxCount)> text_fonts_data;