From cc3fbb22e495021145c71875017d3403aeee7d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 18 Jun 2025 11:00:27 +0200 Subject: [PATCH] Change some stat arrays from double to float (to save mem bandwidth) --- Core/Debugger/WebSocket/GPUStatsSubscriber.cpp | 8 ++++---- Core/HW/Display.cpp | 10 +++++----- Core/HW/Display.h | 2 +- UI/DebugOverlay.cpp | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp b/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp index 1c1147bd42..2e6582e99f 100644 --- a/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp +++ b/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp @@ -26,8 +26,8 @@ struct CollectedStats { float fps; float actual_fps; char statbuf[4096]; - std::vector frameTimes; - std::vector sleepTimes; + std::vector frameTimes; + std::vector sleepTimes; int frameTimePos; }; @@ -123,8 +123,8 @@ void WebSocketGPUStatsState::FlipListener() { __DisplayGetDebugStats(stats.statbuf, sizeof(stats.statbuf)); int valid; - double *sleepHistory; - double *history = __DisplayGetFrameTimes(&valid, &stats.frameTimePos, &sleepHistory); + float *sleepHistory; + float *history = __DisplayGetFrameTimes(&valid, &stats.frameTimePos, &sleepHistory); stats.frameTimes.resize(valid); stats.sleepTimes.resize(valid); diff --git a/Core/HW/Display.cpp b/Core/HW/Display.cpp index 064a2b1cde..405dec5021 100644 --- a/Core/HW/Display.cpp +++ b/Core/HW/Display.cpp @@ -63,8 +63,8 @@ static int fpsHistoryPos = 0; static int fpsHistoryValid = 0; // Frame time stats. -static double frameTimeHistory[600]; -static double frameSleepHistory[600]; +static float frameTimeHistory[600]; +static float frameSleepHistory[600]; static constexpr int frameTimeHistorySize = (int)ARRAY_SIZE(frameTimeHistory); static int frameTimeHistoryPos = 0; static int frameTimeHistoryValid = 0; @@ -93,13 +93,13 @@ static void CalculateFPS() { } if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) { - frameTimeHistory[frameTimeHistoryPos++] = now - lastFrameTimeHistory; + frameTimeHistory[frameTimeHistoryPos++] = (float)(now - lastFrameTimeHistory); lastFrameTimeHistory = now; frameTimeHistoryPos = frameTimeHistoryPos % frameTimeHistorySize; if (frameTimeHistoryValid < frameTimeHistorySize) { ++frameTimeHistoryValid; } - frameSleepHistory[frameTimeHistoryPos] = 0.0; + frameSleepHistory[frameTimeHistoryPos] = 0.0f; } } @@ -169,7 +169,7 @@ void DisplayAdjustAccumulatedHcount(uint32_t diff) { hCountBase += diff; } -double *__DisplayGetFrameTimes(int *out_valid, int *out_pos, double **out_sleep) { +float *__DisplayGetFrameTimes(int *out_valid, int *out_pos, float **out_sleep) { *out_valid = frameTimeHistoryValid; *out_pos = frameTimeHistoryPos; *out_sleep = frameSleepHistory; diff --git a/Core/HW/Display.h b/Core/HW/Display.h index 4bc08c1a45..59fb13511e 100644 --- a/Core/HW/Display.h +++ b/Core/HW/Display.h @@ -42,7 +42,7 @@ void __DisplayGetDebugStats(char *stats, size_t bufsize); void __DisplayGetAveragedFPS(float *out_vps, float *out_fps); void __DisplayGetFPS(float *out_vps, float *out_fps, float *out_actual_fps); void __DisplayGetVPS(float *out_vps); -double *__DisplayGetFrameTimes(int *out_valid, int *out_pos, double **out_sleep); +float *__DisplayGetFrameTimes(int *out_valid, int *out_pos, float **out_sleep); int DisplayGetSleepPos(); void DisplayNotifySleep(double t, int pos = -1); bool DisplayIsRunningSlow(); diff --git a/UI/DebugOverlay.cpp b/UI/DebugOverlay.cpp index 354ced7e7b..9946fd639e 100644 --- a/UI/DebugOverlay.cpp +++ b/UI/DebugOverlay.cpp @@ -97,9 +97,9 @@ static void DrawControlDebug(UIContext *ctx, const ControlMapper &mapper, const static void DrawFrameTimes(UIContext *ctx, const Bounds &bounds) { FontID ubuntu24("UBUNTU24"); - double *sleepHistory; + float *sleepHistory; int valid, pos; - double *history = __DisplayGetFrameTimes(&valid, &pos, &sleepHistory); + float *history = __DisplayGetFrameTimes(&valid, &pos, &sleepHistory); int scale = 7000; int width = 600;