From bdf4a5249d1f0814b4c7f026cf18f15ff1435722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A5IGA?= <164882787+Xphalnos@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:53:25 +0100 Subject: [PATCH] imgui: Displays FPS color based on FPS (#2437) --- src/common/config.cpp | 7 +++++++ src/common/config.h | 1 + src/core/devtools/layer.cpp | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/common/config.cpp b/src/common/config.cpp index aae903da6..a42709b7a 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -68,6 +68,7 @@ static bool vkCrashDiagnostic = false; static bool vkHostMarkers = false; static bool vkGuestMarkers = false; static bool rdocEnable = false; +static bool isFpsColor = true; static s16 cursorState = HideCursorState::Idle; static int cursorHideTimeout = 5; // 5 seconds (default) static bool useUnifiedInputConfig = true; @@ -282,6 +283,10 @@ bool isRdocEnabled() { return rdocEnable; } +bool fpsColor() { + return isFpsColor; +} + u32 vblankDiv() { return vblankDivider; } @@ -757,6 +762,7 @@ void load(const std::filesystem::path& path) { isDebugDump = toml::find_or(debug, "DebugDump", false); isShaderDebug = toml::find_or(debug, "CollectShader", false); + isFpsColor = toml::find_or(debug, "FPSColor", true); } if (data.contains("GUI")) { @@ -881,6 +887,7 @@ void save(const std::filesystem::path& path) { data["Vulkan"]["rdocEnable"] = rdocEnable; data["Debug"]["DebugDump"] = isDebugDump; data["Debug"]["CollectShader"] = isShaderDebug; + data["Debug"]["FPSColor"] = isFpsColor; data["Keys"]["TrophyKey"] = trophyKey; diff --git a/src/common/config.h b/src/common/config.h index dfb1d9fad..7b9bc789b 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -67,6 +67,7 @@ bool copyGPUCmdBuffers(); bool dumpShaders(); bool patchShaders(); bool isRdocEnabled(); +bool fpsColor(); u32 vblankDiv(); void setDebugDump(bool enable); diff --git a/src/core/devtools/layer.cpp b/src/core/devtools/layer.cpp index a6d99b49b..603d76df5 100644 --- a/src/core/devtools/layer.cpp +++ b/src/core/devtools/layer.cpp @@ -259,7 +259,19 @@ void L::DrawAdvanced() { void L::DrawSimple() { const float frameRate = DebugState.Framerate; + if (Config::fpsColor()) { + if (frameRate < 10) { + PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); // Red + } else if (frameRate >= 10 && frameRate < 20) { + PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.5f, 0.0f, 1.0f)); // Orange + } else { + PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // White + } + } else { + PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // White + } Text("%d FPS (%.1f ms)", static_cast(std::round(frameRate)), 1000.0f / frameRate); + PopStyleColor(); } static void LoadSettings(const char* line) {