Settings: Fix race toggling OSD messages

arm-build
Stenzek 14 hours ago
parent 6a86c80445
commit ec7c83a58e
No known key found for this signature in database

@ -322,7 +322,7 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
display_active_end_offset = static_cast<s16>(si.GetIntValue("Display", "ActiveEndOffset", 0));
display_line_start_offset = static_cast<s8>(si.GetIntValue("Display", "LineStartOffset", 0));
display_line_end_offset = static_cast<s8>(si.GetIntValue("Display", "LineEndOffset", 0));
ImGuiManager::SetShowOSDMessages(si.GetBoolValue("Display", "ShowOSDMessages", true));
display_show_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false);
display_show_gpu_stats = si.GetBoolValue("Display", "ShowGPUStatistics", false);
@ -629,7 +629,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
si.GetIntValue("Display", "CustomAspectRatioDenominator", display_aspect_ratio_custom_denominator);
if (!ignore_base)
{
si.SetBoolValue("Display", "ShowOSDMessages", ImGuiManager::IsShowingOSDMessages());
si.SetBoolValue("Display", "ShowOSDMessages", display_show_messages);
si.SetBoolValue("Display", "ShowFPS", display_show_fps);
si.SetBoolValue("Display", "ShowSpeed", display_show_speed);
si.SetBoolValue("Display", "ShowResolution", display_show_resolution);

@ -133,6 +133,7 @@ struct GPUSettings
bool display_disable_mailbox_presentation : 1 = true;
bool display_force_4_3_for_24bit : 1 = false;
bool display_24bit_chroma_smoothing : 1 = false;
bool display_show_messages : 1 = false;
bool display_show_fps : 1 = false;
bool display_show_speed : 1 = false;
bool display_show_gpu_stats : 1 = false;

@ -1305,6 +1305,7 @@ void System::SetDefaultSettings(SettingsInterface& si)
Settings temp;
// we don't want to reset some things (e.g. OSD)
temp.display_show_messages = g_settings.display_show_messages;
temp.display_show_fps = g_settings.display_show_fps;
temp.display_show_speed = g_settings.display_show_speed;
temp.display_show_gpu_stats = g_settings.display_show_gpu_stats;
@ -4524,7 +4525,8 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
}
}
else if (const bool device_settings_changed = g_settings.AreGPUDeviceSettingsChanged(old_settings);
device_settings_changed || g_settings.display_show_fps != old_settings.display_show_fps ||
device_settings_changed || g_settings.display_show_messages != old_settings.display_show_messages ||
g_settings.display_show_fps != old_settings.display_show_fps ||
g_settings.display_show_speed != old_settings.display_show_speed ||
g_settings.display_show_gpu_stats != old_settings.display_show_gpu_stats ||
g_settings.display_show_resolution != old_settings.display_show_resolution ||
@ -4906,7 +4908,7 @@ void System::WarnAboutUnsafeSettings()
// Force the message, but use a reduced duration if they have OSD messages disabled.
Host::AddKeyedOSDWarning("performance_settings_warning", std::string(messages.view()),
ImGuiManager::IsShowingOSDMessages() ? Host::OSD_INFO_DURATION : Host::OSD_QUICK_DURATION);
g_settings.display_show_messages ? Host::OSD_INFO_DURATION : Host::OSD_QUICK_DURATION);
}
else
{

@ -12,6 +12,7 @@
// TODO: Remove me when GPUDevice config is also cleaned up.
#include "core/gpu_thread.h"
#include "core/host.h"
#include "core/settings.h"
#include "common/assert.h"
#include "common/bitutils.h"
@ -110,7 +111,6 @@ struct ALIGN_TO_CACHE_LINE State
std::deque<OSDMessage> osd_posted_messages;
std::mutex osd_messages_lock;
bool show_osd_messages = true;
// Owned by GPU thread
ALIGN_TO_CACHE_LINE Timer::Value last_render_time = 0;
@ -219,21 +219,6 @@ void ImGuiManager::SetGlobalScale(float global_scale)
s_state.scale_changed = true;
}
bool ImGuiManager::IsShowingOSDMessages()
{
return s_state.show_osd_messages;
}
void ImGuiManager::SetShowOSDMessages(bool enable)
{
if (s_state.show_osd_messages == enable)
return;
s_state.show_osd_messages = enable;
if (!enable)
Host::ClearOSDMessages(false);
}
bool ImGuiManager::Initialize(float global_scale, float screen_margin, Error* error)
{
if (!LoadFontData(error))
@ -864,9 +849,6 @@ void ImGuiManager::AddOSDMessage(std::string key, std::string message, float dur
else
INFO_LOG("OSD: {}", message);
if (!s_state.show_osd_messages && !is_warning)
return;
const Timer::Value current_time = Timer::GetCurrentValue();
OSDMessage msg;
@ -885,9 +867,6 @@ void ImGuiManager::AddOSDMessage(std::string key, std::string message, float dur
void ImGuiManager::RemoveKeyedOSDMessage(std::string key, bool is_warning)
{
if (!s_state.show_osd_messages && !is_warning)
return;
ImGuiManager::OSDMessage msg = {};
msg.key = std::move(key);
msg.duration = 0.0f;
@ -983,6 +962,7 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
const float padding = std::ceil(9.0f * scale);
const float rounding = std::ceil(6.0f * scale);
const float max_width = s_state.window_width - (margin + padding) * 2.0f;
const bool show_messages = g_gpu_settings.display_show_messages;
float position_x = margin;
float position_y = margin;
@ -1044,7 +1024,7 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
}
}
if (actual_y >= ImGui::GetIO().DisplaySize.y)
if (actual_y >= ImGui::GetIO().DisplaySize.y || (!show_messages && !msg.is_warning))
break;
const ImVec2 pos(position_x, actual_y);

@ -74,10 +74,6 @@ std::vector<WCharType> CompactFontRange(std::span<const WCharType> range);
/// Changes the global scale.
void SetGlobalScale(float global_scale);
/// Changes whether OSD messages are silently dropped.
bool IsShowingOSDMessages();
void SetShowOSDMessages(bool enable);
/// Initializes ImGui, creates fonts, etc.
bool Initialize(float global_scale, float screen_margin, Error* error);

Loading…
Cancel
Save