Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Features/PerformanceOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,19 @@ void PerformanceOverlay::DrawFPS()
ImGui::TableNextColumn();
ImGui::Text(this->state.isFrameGenerationActive ? "Raw FPS:" : "FPS:");
ImGui::TableNextColumn();
ImGui::Text("%.1f (%.2f ms)", this->state.smoothFps, this->state.smoothFrameTimeMs);

// Check if buffer is full for the avg
auto frameData = this->state.frameTimeHistory.GetData();
size_t validFrameCount = std::count_if(frameData.begin(), frameData.end(), [](float ft) { return ft > 0.0f; });
bool bufferIsFull = validFrameCount == frameData.size();

if (bufferIsFull) {
float avgFrameTime = std::accumulate(frameData.begin(), frameData.end(), 0.0f) / frameData.size();
float avgFps = (avgFrameTime > 0.001f) ? 1000.0f / avgFrameTime : 0.0f;
ImGui::Text("%.1f (%.2f ms) | Avg: %.1f", this->state.smoothFps, this->state.smoothFrameTimeMs, avgFps);
} else {
ImGui::Text("%.1f (%.2f ms)", this->state.smoothFps, this->state.smoothFrameTimeMs);
}

if (this->state.isFrameGenerationActive) {
ImGui::TableNextColumn();
Expand Down
6 changes: 3 additions & 3 deletions src/Features/PerformanceOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ struct PerformanceOverlay : OverlayFeature
static constexpr float kVRAMSectionWidth = 300.0f; // pixels - VRAM section width
static constexpr float kWindowBorderPadding = 20.0f; // pixels - Window border padding
static constexpr float kDefaultFrameTimeMs = 16.67f; // ms - Default frame time (60 FPS)
static constexpr int kMinFrameHistorySize = 60; // 60 frames = 1s @ 60fps. Reasonable minimum.
static constexpr int kMaxFrameHistorySize = 480; // 480 frames = 10s @ 60fps or 2s @ 240fps. Reasonable maximum.
static constexpr int kMinFrameHistorySize = 120; // 2s @ 60fps, 0.5s @ 240fps
static constexpr int kMaxFrameHistorySize = 1800; // 30s @ 60fps, 7.5s @ 240fps

bool ShowInOverlay = true; // was: Enabled
bool ShowDrawCalls = true;
Expand All @@ -268,7 +268,7 @@ struct PerformanceOverlay : OverlayFeature
bool ShowPreFGFrameTimeGraph = true;
bool ShowPostFGFrameTimeGraph = true;
float UpdateInterval = 0.5f;
int FrameHistorySize = 120; // Default 120 frames = 2s @ 60fps. Clamped using static values to prevent config file values going outside of slider bounds.
int FrameHistorySize = 600; // 10s @ 60fps, 2.5s @ 240fps
float TextSize = 1.0f;

float BackgroundOpacity = 0.5f;
Expand Down