Compare commits

..
1 Commits
Author SHA1 Message Date
refractionpcsx2 5e814e8efc PerfMon/ImGui: Add average VPS value to OSD 2026-09-12 02:47:53 +01:00
3 changed files with 66 additions and 1 deletions
+1 -1
View File
@@ -363,7 +363,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
}
if (GSConfig.OsdShowVPS)
s_speed_line.append_format("{}VPS: {:.2f}", s_speed_line.empty() ? "" : " | ", PerformanceMetrics::GetFPS());
s_speed_line.append_format("{}VPS: {:.2f} (Avg. {:.2f})", s_speed_line.empty() ? "" : " | ", PerformanceMetrics::GetFPS(), PerformanceMetrics::GetAvgVPS());
if (GSConfig.OsdShowSpeed)
{
+8
View File
@@ -19,6 +19,7 @@
static const float UPDATE_INTERVAL = 0.5f;
static float s_fps = 0.0f;
static PerformanceMetrics::AverageFPS s_avg_vps;
static float s_internal_fps = 0.0f;
static float s_minimum_frame_time = 0.0f;
static float s_minimum_frame_time_accumulator = 0.0f;
@@ -85,6 +86,7 @@ void PerformanceMetrics::Clear()
Reset();
s_fps = 0.0f;
s_avg_vps.ClearStats();
s_internal_fps = 0.0f;
s_minimum_frame_time = 0.0f;
s_average_frame_time = 0.0f;
@@ -183,6 +185,7 @@ void PerformanceMetrics::Update(bool gs_register_write, bool fb_blit, bool is_sk
s_average_frame_time = std::exchange(s_average_frame_time_accumulator, 0.0f) / static_cast<float>(s_unskipped_frames_since_last_update);
s_maximum_frame_time = std::exchange(s_maximum_frame_time_accumulator, 0.0f);
s_fps = static_cast<float>(s_frames_since_last_update) / time;
s_avg_vps.UpdateAvgFPS(s_fps);
s_average_gpu_time = s_accumulated_gpu_time / static_cast<float>(s_unskipped_frames_since_last_update);
s_average_gpu_vs_invocations = static_cast<double>(s_accumulated_gpu_vs_invocations) / static_cast<double>(s_unskipped_frames_since_last_update);
s_average_gpu_ps_invocations = static_cast<double>(s_accumulated_gpu_ps_invocations) / static_cast<double>(s_unskipped_frames_since_last_update);
@@ -329,6 +332,11 @@ float PerformanceMetrics::GetFPS()
return s_fps;
}
float PerformanceMetrics::GetAvgVPS()
{
return s_avg_vps.GetAvgFPS();
}
float PerformanceMetrics::GetInternalFPS()
{
return s_internal_fps;
+57
View File
@@ -4,6 +4,7 @@
#pragma once
#include <array>
#include <cstring>
#include "common/Threading.h"
namespace PerformanceMetrics
@@ -15,6 +16,61 @@ namespace PerformanceMetrics
DISPFBBlit
};
class AverageFPS
{
private:
#define FPS_BUFFER_SIZE 8
float fps_buff[FPS_BUFFER_SIZE];
int count;
int pos;
public:
void ClearStats()
{
count = 0;
pos = 0;
std::memset(&fps_buff[0], 0, sizeof(float) * FPS_BUFFER_SIZE);
}
AverageFPS()
{
ClearStats();
}
void UpdateAvgFPS(float new_fps_val)
{
// If the change is quite dramatic, the user has either turned off the frame limiter or the game is dying.
// Clear it to catch it up quickly.
if (count > 0)
{
const float last_fps_val = fps_buff[(pos - 1) & (FPS_BUFFER_SIZE - 1)];
if (std::abs(last_fps_val - new_fps_val) > last_fps_val * 0.20f)
ClearStats();
}
fps_buff[pos] = new_fps_val;
pos = (pos + 1) & (FPS_BUFFER_SIZE - 1); // if you use values which don't become all 1's, make it %.
count = std::min(count + 1, FPS_BUFFER_SIZE);
}
float GetAvgFPS()
{
if (count == 0)
return 0.0f;
float avg_fps = 0.0f;
for (int i = 0; i < count; i++)
{
avg_fps += fps_buff[i];
}
avg_fps /= static_cast<float>(count);
return avg_fps;
}
};
static constexpr u32 NUM_FRAME_TIME_SAMPLES = 150;
using FrameTimeHistory = std::array<float, NUM_FRAME_TIME_SAMPLES>;
@@ -36,6 +92,7 @@ namespace PerformanceMetrics
bool IsInternalFPSValid();
float GetFPS();
float GetAvgVPS();
float GetInternalFPS();
float GetSpeed();
float GetAverageFrameTime();