Settings: Turn debug window visiblity into a bitmask

Prevents video thread settings reload on every change, and stops it from
reading achievements state.
wip3-rebase
Stenzek 2 days ago
parent 46fca8f0da
commit 31a610358f
No known key found for this signature in database

@ -2,7 +2,6 @@
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#include "imgui_overlays.h"
#include "achievements.h"
#include "cdrom.h"
#include "controller.h"
#include "core.h"
@ -127,30 +126,27 @@ static InputOverlayState s_input_overlay_state = {};
} // namespace ImGuiManager
bool ImGuiManager::AreAnyDebugWindowsEnabled(const SettingsInterface& si)
u8 ImGuiManager::LoadDebugWindowVisibility(const SettingsInterface& si)
{
const bool block_all = Achievements::IsHardcoreModeActive();
if (block_all)
return false;
u8 visible = 0;
for (size_t i = 0; i < NUM_DEBUG_WINDOWS; i++)
{
const DebugWindowInfo& info = s_debug_window_info[i];
if (si.GetBoolValue(DEBUG_WINDOW_CONFIG_SECTION, info.name, false))
return true;
visible |= (1u << i);
}
return false;
return visible;
}
bool ImGuiManager::IsSPUDebugWindowEnabled()
bool ImGuiManager::IsSPUDebugWindowVisible(u8 debug_window_visibility)
{
return (s_debug_window_state[1].window_handle != nullptr);
return ((debug_window_visibility & (1u << 1)) != 0);
}
bool ImGuiManager::UpdateDebugWindowConfig()
bool ImGuiManager::UpdateDebugWindowConfig(u8 debug_window_visibility)
{
const bool block_all = Achievements::IsHardcoreModeActive();
bool was_changed = false;
for (size_t i = 0; i < NUM_DEBUG_WINDOWS; i++)
@ -159,7 +155,7 @@ bool ImGuiManager::UpdateDebugWindowConfig()
const DebugWindowInfo& info = s_debug_window_info[i];
const bool current = (state.window_handle != nullptr);
const bool enabled = (!block_all && Core::GetBaseBoolSettingValue(DEBUG_WINDOW_CONFIG_SECTION, info.name, false));
const bool enabled = ((debug_window_visibility & (1u << i)) != 0);
if (enabled == current)
continue;

@ -17,10 +17,10 @@ inline constexpr const char* LOGO_IMAGE_NAME = "images/duck.png";
void UpdateInputOverlay();
void RenderTextOverlays(const GPUBackend* gpu);
bool AreAnyDebugWindowsEnabled(const SettingsInterface& si);
bool IsSPUDebugWindowEnabled();
u8 LoadDebugWindowVisibility(const SettingsInterface& si);
bool IsSPUDebugWindowVisible(u8 debug_window_visibility);
void RenderDebugWindows();
bool UpdateDebugWindowConfig();
bool UpdateDebugWindowConfig(u8 debug_window_visibility);
void DestroyAllDebugWindows();
void RenderOverlayWindows();

@ -582,6 +582,8 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
pcdrv_enable_writes = si.GetBoolValue("PCDrv", "EnableWrites", false);
pcdrv_root = Path::ToNativePath(si.GetStringViewValue("PCDrv", "Root"));
debug_window_visibility = ImGuiManager::LoadDebugWindowVisibility(si);
texture_replacements.enable_texture_replacements =
si.GetBoolValue("TextureReplacements", "EnableTextureReplacements", false);
texture_replacements.enable_vram_write_replacements =
@ -1205,6 +1207,8 @@ void Settings::ApplySettingRestrictions()
gpu_show_vram = false;
gpu_dump_cpu_to_vram_copies = false;
gpu_dump_vram_to_cpu_copies = false;
debug_window_visibility = 0;
}
}
@ -1248,7 +1252,7 @@ void Settings::FixIncompatibleSettings(const SettingsInterface& si, bool display
texture_replacements.enable_vram_write_replacements &= (gpu_renderer != GPURenderer::Software);
// GPU thread should be disabled if any debug windows are active, since they will be racing to read CPU thread state.
if (gpu_use_thread && gpu_max_queued_frames > 0 && ImGuiManager::AreAnyDebugWindowsEnabled(si))
if (debug_window_visibility != 0 && gpu_use_thread && gpu_max_queued_frames > 0)
{
WARNING_LOG("Setting maximum queued frames to 0 because one or more debug windows are enabled.");
gpu_max_queued_frames = 0;

@ -127,6 +127,8 @@ struct GPUSettings
bool achievements_rich_presence_monitor : 1 = false;
u8 debug_window_visibility = 0;
NotificationLocation display_osd_message_location = DEFAULT_OSD_MESSAGE_LOCATION;
// achievements

@ -451,9 +451,9 @@ ALIGN_TO_CACHE_LINE static std::array<s16, (44100 / 60) * 2> s_muted_output_buff
#ifdef SPU_ENABLE_VU_METER
static bool IsVUMeterActive()
ALWAYS_INLINE static bool IsVUMeterActive()
{
return ImGuiManager::IsSPUDebugWindowEnabled();
return ImGuiManager::IsSPUDebugWindowVisible(g_settings.debug_window_visibility);
}
ALWAYS_INLINE_RELEASE static void UpdateDebugPeaks(s16 peaks[2], s32 left, s32 right)

@ -4663,6 +4663,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
g_settings.display_line_start_offset != old_settings.display_line_start_offset ||
g_settings.display_line_end_offset != old_settings.display_line_end_offset ||
g_settings.gpu_show_vram != old_settings.gpu_show_vram ||
g_settings.debug_window_visibility != old_settings.debug_window_visibility ||
g_settings.rewind_enable != old_settings.rewind_enable ||
g_settings.runahead_frames != old_settings.runahead_frames ||
g_settings.texture_replacements != old_settings.texture_replacements)
@ -4749,11 +4750,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
VideoThread::UpdateSettings(true, false, false);
}
}
else
{
// still need to update debug windows
VideoThread::UpdateSettings(false, false, false);
}
if (g_settings.gpu_widescreen_hack != old_settings.gpu_widescreen_hack ||
g_settings.display_aspect_ratio != old_settings.display_aspect_ratio)

@ -858,7 +858,7 @@ bool VideoThread::CreateGPUBackendOnThread(bool hardware_renderer, bool upload_v
}
}
ImGuiManager::UpdateDebugWindowConfig();
ImGuiManager::UpdateDebugWindowConfig(g_gpu_settings.debug_window_visibility);
if (hardware_renderer)
s_state.gpu_backend = GPUBackend::CreateHardwareBackend();
@ -1162,7 +1162,7 @@ void VideoThread::UpdateSettingsOnThread(GPUSettings&& new_settings)
return;
}
if (ImGuiManager::UpdateDebugWindowConfig())
if (ImGuiManager::UpdateDebugWindowConfig(g_gpu_settings.debug_window_visibility))
PresentFrameAndRestoreContext();
else
s_state.gpu_backend->RestoreDeviceContext();
@ -1256,17 +1256,6 @@ void VideoThread::UpdateSettings(bool gpu_settings_changed, bool device_settings
UpdateSettingsOnThread(GPUSettings(g_settings));
}
}
else
{
// still need to update debug window visibility
RunOnThread([]() {
if (s_state.gpu_backend)
{
if (ImGuiManager::UpdateDebugWindowConfig())
PresentFrameAndRestoreContext();
}
});
}
}
void VideoThread::UpdateGameInfo(const std::string& title, const std::string& serial, const std::string& path,

Loading…
Cancel
Save