diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5588287f1c..0a9eefdc40 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1389,6 +1389,8 @@ list(APPEND NativeAppSource
UI/BackgroundAudio.cpp
UI/ChatScreen.h
UI/ChatScreen.cpp
+ UI/DebugOverlay.cpp
+ UI/DebugOverlay.h
UI/DevScreens.cpp
UI/DevScreens.h
UI/DisplayLayoutScreen.cpp
diff --git a/UI/DebugOverlay.cpp b/UI/DebugOverlay.cpp
new file mode 100644
index 0000000000..fa4d8a92c9
--- /dev/null
+++ b/UI/DebugOverlay.cpp
@@ -0,0 +1,131 @@
+#include "Common/Render/DrawBuffer.h"
+#include "Common/GPU/thin3d.h"
+#include "Common/System/System.h"
+#include "UI/DebugOverlay.h"
+#include "Core/HW/Display.h"
+#include "Core/HLE/sceSas.h"
+#include "Core/ControlMapper.h"
+#include "Core/Config.h"
+#include "GPU/GPU.h"
+// TODO: This should be moved here or to Common, doesn't belong in /GPU
+#include "GPU/Vulkan/DebugVisVulkan.h"
+
+static void DrawDebugStats(UIContext *ctx, const Bounds &bounds) {
+ FontID ubuntu24("UBUNTU24");
+
+ float left = std::max(bounds.w / 2 - 20.0f, 550.0f);
+ float right = bounds.w - left - 20.0f;
+
+ char statbuf[4096];
+
+ ctx->Flush();
+ ctx->BindFontTexture();
+ ctx->Draw()->SetFontScale(.7f, .7f);
+
+ __DisplayGetDebugStats(statbuf, sizeof(statbuf));
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, left, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, left, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
+
+ __SasGetDebugStats(statbuf, sizeof(statbuf));
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + left + 21, bounds.y + 31, right, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + left + 20, bounds.y + 30, right, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
+
+ ctx->Draw()->SetFontScale(1.0f, 1.0f);
+ ctx->Flush();
+ ctx->RebindTexture();
+}
+
+static void DrawAudioDebugStats(UIContext *ctx, const Bounds &bounds) {
+ FontID ubuntu24("UBUNTU24");
+
+ char statbuf[4096] = { 0 };
+ System_AudioGetDebugStats(statbuf, sizeof(statbuf));
+
+ ctx->Flush();
+ ctx->BindFontTexture();
+ ctx->Draw()->SetFontScale(0.7f, 0.7f);
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, bounds.w - 20, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
+ ctx->Draw()->SetFontScale(1.0f, 1.0f);
+ ctx->Flush();
+ ctx->RebindTexture();
+}
+
+static void DrawControlDebug(UIContext *ctx, const ControlMapper &mapper, const Bounds &bounds) {
+ FontID ubuntu24("UBUNTU24");
+
+ char statbuf[4096] = { 0 };
+ mapper.GetDebugString(statbuf, sizeof(statbuf));
+
+ ctx->Flush();
+ ctx->BindFontTexture();
+ ctx->Draw()->SetFontScale(0.5f, 0.5f);
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, bounds.w - 20, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII);
+ ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
+ ctx->Draw()->SetFontScale(1.0f, 1.0f);
+ ctx->Flush();
+ ctx->RebindTexture();
+}
+
+static void DrawFrameTimes(UIContext *ctx, const Bounds &bounds) {
+ FontID ubuntu24("UBUNTU24");
+ int valid, pos;
+ double *sleepHistory;
+ double *history = __DisplayGetFrameTimes(&valid, &pos, &sleepHistory);
+ int scale = 7000;
+ int width = 600;
+
+ ctx->Flush();
+ ctx->BeginNoTex();
+ int bottom = bounds.y2();
+ for (int i = 0; i < valid; ++i) {
+ double activeTime = history[i] - sleepHistory[i];
+ ctx->Draw()->vLine(bounds.x + i, bottom, bottom - activeTime * scale, 0xFF3FFF3F);
+ ctx->Draw()->vLine(bounds.x + i, bottom - activeTime * scale, bottom - history[i] * scale, 0x7F3FFF3F);
+ }
+ ctx->Draw()->vLine(bounds.x + pos, bottom, bottom - 512, 0xFFff3F3f);
+
+ ctx->Draw()->hLine(bounds.x, bottom - 0.0333 * scale, bounds.x + width, 0xFF3f3Fff);
+ ctx->Draw()->hLine(bounds.x, bottom - 0.0167 * scale, bounds.x + width, 0xFF3f3Fff);
+
+ ctx->Flush();
+ ctx->Begin();
+ ctx->BindFontTexture();
+ ctx->Draw()->SetFontScale(0.5f, 0.5f);
+ ctx->Draw()->DrawText(ubuntu24, "33.3ms", bounds.x + width, bottom - 0.0333 * scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII);
+ ctx->Draw()->DrawText(ubuntu24, "16.7ms", bounds.x + width, bottom - 0.0167 * scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII);
+ ctx->Draw()->SetFontScale(1.0f, 1.0f);
+ ctx->Flush();
+ ctx->RebindTexture();
+}
+
+
+void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper &controlMapper, DebugOverlay overlay) {
+ switch (overlay) {
+ case DebugOverlay::DEBUG_STATS:
+ DrawDebugStats(ctx, ctx->GetLayoutBounds());
+ break;
+ case DebugOverlay::FRAME_GRAPH:
+ DrawFrameTimes(ctx, ctx->GetLayoutBounds());
+ break;
+ case DebugOverlay::AUDIO:
+ DrawAudioDebugStats(ctx, ctx->GetLayoutBounds());
+ break;
+ case DebugOverlay::CONTROL:
+ DrawControlDebug(ctx, controlMapper, ctx->GetLayoutBounds());
+ break;
+#if !PPSSPP_PLATFORM(UWP) && !PPSSPP_PLATFORM(SWITCH)
+
+ case DebugOverlay::GPU_PROFILE:
+ if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN || g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
+ DrawGPUProfilerVis(ctx, gpu);
+ }
+ break;
+ case DebugOverlay::GPU_ALLOCATOR:
+ if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN || g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
+ DrawGPUMemoryVis(ctx, gpu);
+ }
+ break;
+#endif
+ }
+}
diff --git a/UI/DebugOverlay.h b/UI/DebugOverlay.h
new file mode 100644
index 0000000000..0723734195
--- /dev/null
+++ b/UI/DebugOverlay.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "Common/UI/Context.h"
+#include "Core/ConfigValues.h"
+#include "Core/ControlMapper.h"
+
+void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper &controlMapper, DebugOverlay overlay);
diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp
index 09430cac3d..2d55bdd763 100644
--- a/UI/EmuScreen.cpp
+++ b/UI/EmuScreen.cpp
@@ -92,6 +92,7 @@ using namespace std::placeholders;
#include "UI/ProfilerDraw.h"
#include "UI/DiscordIntegration.h"
#include "UI/ChatScreen.h"
+#include "UI/DebugOverlay.h"
#include "Core/Reporting.h"
@@ -1172,31 +1173,6 @@ void EmuScreen::checkPowerDown() {
}
}
-static void DrawDebugStats(UIContext *ctx, const Bounds &bounds) {
- FontID ubuntu24("UBUNTU24");
-
- float left = std::max(bounds.w / 2 - 20.0f, 550.0f);
- float right = bounds.w - left - 20.0f;
-
- char statbuf[4096];
-
- ctx->Flush();
- ctx->BindFontTexture();
- ctx->Draw()->SetFontScale(.7f, .7f);
-
- __DisplayGetDebugStats(statbuf, sizeof(statbuf));
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, left, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, left, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
-
- __SasGetDebugStats(statbuf, sizeof(statbuf));
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + left + 21, bounds.y + 31, right, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + left + 20, bounds.y + 30, right, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
-
- ctx->Draw()->SetFontScale(1.0f, 1.0f);
- ctx->Flush();
- ctx->RebindTexture();
-}
-
static const char *CPUCoreAsString(int core) {
switch (core) {
case 0: return "Interpreter";
@@ -1343,38 +1319,6 @@ Invalid / Unknown (%d)
ctx->RebindTexture();
}
-static void DrawAudioDebugStats(UIContext *ctx, const Bounds &bounds) {
- FontID ubuntu24("UBUNTU24");
-
- char statbuf[4096] = { 0 };
- System_AudioGetDebugStats(statbuf, sizeof(statbuf));
-
- ctx->Flush();
- ctx->BindFontTexture();
- ctx->Draw()->SetFontScale(0.7f, 0.7f);
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, bounds.w - 20, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT);
- ctx->Draw()->SetFontScale(1.0f, 1.0f);
- ctx->Flush();
- ctx->RebindTexture();
-}
-
-static void DrawControlDebug(UIContext *ctx, const ControlMapper &mapper, const Bounds &bounds) {
- FontID ubuntu24("UBUNTU24");
-
- char statbuf[4096] = { 0 };
- mapper.GetDebugString(statbuf, sizeof(statbuf));
-
- ctx->Flush();
- ctx->BindFontTexture();
- ctx->Draw()->SetFontScale(0.5f, 0.5f);
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, bounds.w - 20, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII);
- ctx->Draw()->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
- ctx->Draw()->SetFontScale(1.0f, 1.0f);
- ctx->Flush();
- ctx->RebindTexture();
-}
-
static void DrawFPS(UIContext *ctx, const Bounds &bounds) {
FontID ubuntu24("UBUNTU24");
float vps, fps, actual_fps;
@@ -1408,38 +1352,6 @@ static void DrawFPS(UIContext *ctx, const Bounds &bounds) {
ctx->RebindTexture();
}
-static void DrawFrameTimes(UIContext *ctx, const Bounds &bounds) {
- FontID ubuntu24("UBUNTU24");
- int valid, pos;
- double *sleepHistory;
- double *history = __DisplayGetFrameTimes(&valid, &pos, &sleepHistory);
- int scale = 7000;
- int width = 600;
-
- ctx->Flush();
- ctx->BeginNoTex();
- int bottom = bounds.y2();
- for (int i = 0; i < valid; ++i) {
- double activeTime = history[i] - sleepHistory[i];
- ctx->Draw()->vLine(bounds.x + i, bottom, bottom - activeTime * scale, 0xFF3FFF3F);
- ctx->Draw()->vLine(bounds.x + i, bottom - activeTime * scale, bottom - history[i] * scale, 0x7F3FFF3F);
- }
- ctx->Draw()->vLine(bounds.x + pos, bottom, bottom - 512, 0xFFff3F3f);
-
- ctx->Draw()->hLine(bounds.x, bottom - 0.0333 * scale, bounds.x + width, 0xFF3f3Fff);
- ctx->Draw()->hLine(bounds.x, bottom - 0.0167 * scale, bounds.x + width, 0xFF3f3Fff);
-
- ctx->Flush();
- ctx->Begin();
- ctx->BindFontTexture();
- ctx->Draw()->SetFontScale(0.5f, 0.5f);
- ctx->Draw()->DrawText(ubuntu24, "33.3ms", bounds.x + width, bottom - 0.0333 * scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII);
- ctx->Draw()->DrawText(ubuntu24, "16.7ms", bounds.x + width, bottom - 0.0167 * scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII);
- ctx->Draw()->SetFontScale(1.0f, 1.0f);
- ctx->Flush();
- ctx->RebindTexture();
-}
-
void EmuScreen::preRender() {
using namespace Draw;
DrawContext *draw = screenManager()->getDrawContext();
@@ -1626,33 +1538,7 @@ void EmuScreen::renderUI() {
}
if (!invalid_) {
- switch (g_Config.iDebugOverlay) {
- case DebugOverlay::DEBUG_STATS:
- DrawDebugStats(ctx, ctx->GetLayoutBounds());
- break;
- case DebugOverlay::FRAME_GRAPH:
- DrawFrameTimes(ctx, ctx->GetLayoutBounds());
- break;
- case DebugOverlay::AUDIO:
- DrawAudioDebugStats(ctx, ctx->GetLayoutBounds());
- break;
- case DebugOverlay::CONTROL:
- DrawControlDebug(ctx, controlMapper_, ctx->GetLayoutBounds());
- break;
-#if !PPSSPP_PLATFORM(UWP) && !PPSSPP_PLATFORM(SWITCH)
-
- case DebugOverlay::GPU_PROFILE:
- if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN || g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
- DrawGPUProfilerVis(ctx, gpu);
- }
- break;
- case DebugOverlay::GPU_ALLOCATOR:
- if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN || g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
- DrawGPUMemoryVis(ctx, gpu);
- }
- break;
-#endif
- }
+ DrawDebugOverlay(ctx, ctx->GetLayoutBounds(), controlMapper_, g_Config.iDebugOverlay);
if (g_Config.iShowStatusFlags) {
DrawFPS(ctx, ctx->GetLayoutBounds());
diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj
index 68cf5bac73..bc54fd4ced 100644
--- a/UI/UI.vcxproj
+++ b/UI/UI.vcxproj
@@ -40,6 +40,7 @@
+
@@ -76,6 +77,7 @@
+
diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters
index 4ce9a0676a..5c1d68dab9 100644
--- a/UI/UI.vcxproj.filters
+++ b/UI/UI.vcxproj.filters
@@ -89,6 +89,9 @@
Screens
+
+ Screens
+
@@ -178,6 +181,9 @@
Screens
+
+ Screens
+
diff --git a/UWP/UI_UWP/UI_UWP.vcxproj b/UWP/UI_UWP/UI_UWP.vcxproj
index ceb1d347cf..5694417bb5 100644
--- a/UWP/UI_UWP/UI_UWP.vcxproj
+++ b/UWP/UI_UWP/UI_UWP.vcxproj
@@ -123,6 +123,7 @@
+
@@ -160,6 +161,7 @@
+
diff --git a/UWP/UI_UWP/UI_UWP.vcxproj.filters b/UWP/UI_UWP/UI_UWP.vcxproj.filters
index 179a0bf35a..aa3b1b3b6b 100644
--- a/UWP/UI_UWP/UI_UWP.vcxproj.filters
+++ b/UWP/UI_UWP/UI_UWP.vcxproj.filters
@@ -36,6 +36,7 @@
+
@@ -73,5 +74,6 @@
+
\ No newline at end of file
diff --git a/android/jni/Android.mk b/android/jni/Android.mk
index 494a4d6316..3edfbdfc9d 100644
--- a/android/jni/Android.mk
+++ b/android/jni/Android.mk
@@ -763,6 +763,7 @@ LOCAL_SRC_FILES := \
$(SRC)/UI/BackgroundAudio.cpp \
$(SRC)/UI/DiscordIntegration.cpp \
$(SRC)/UI/ChatScreen.cpp \
+ $(SRC)/UI/DebugOverlay.cpp \
$(SRC)/UI/DevScreens.cpp \
$(SRC)/UI/DisplayLayoutScreen.cpp \
$(SRC)/UI/EmuScreen.cpp \