diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-10-27 23:59:31 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2025-11-11 20:01:52 -0600 |
| commit | bf61c890cafc494def3a30ec06b742571b20b8d9 (patch) | |
| tree | c9359016e0c4ca301a59d0ef7f30e192de12d7bf /Source/Core/VideoCommon | |
| parent | c2a1dce246e27f1ac9dc421387e4d70402bb96f4 (diff) | |
VideoCommon/PerformanceMetrics: Display current offset between the latest frame presentation time and the intended presentation time in the "Show Frame Times" box.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceMetrics.cpp | 11 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceMetrics.h | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/PerformanceMetrics.cpp b/Source/Core/VideoCommon/PerformanceMetrics.cpp index 5a38e1e3c6..d00e5dbbba 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.cpp +++ b/Source/Core/VideoCommon/PerformanceMetrics.cpp @@ -23,6 +23,8 @@ void PerformanceMetrics::Reset() m_speed = 0; m_max_speed = 0; + + m_frame_presentation_offset = DT{}; } void PerformanceMetrics::CountFrame() @@ -98,6 +100,11 @@ double PerformanceMetrics::GetMaxSpeed() const return m_max_speed.load(std::memory_order_relaxed); } +void PerformanceMetrics::SetLatestFramePresentationOffset(DT offset) +{ + m_frame_presentation_offset.store(offset, std::memory_order_relaxed); +} + void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) { m_vps_counter.UpdateStats(); @@ -293,6 +300,10 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) DT_ms(m_fps_counter.GetDtAvg()).count()); ImGui::TextColored(ImVec4(r, g, b, 1.0f), " ±:%6.2lfms", DT_ms(m_fps_counter.GetDtStd()).count()); + + const auto offset = + DT_ms(m_frame_presentation_offset.load(std::memory_order_relaxed)).count(); + ImGui::TextColored(ImVec4(r, g, b, 1.0f), "ofs:%5.1lfms", offset); } } ImGui::End(); diff --git a/Source/Core/VideoCommon/PerformanceMetrics.h b/Source/Core/VideoCommon/PerformanceMetrics.h index bca6372d18..914e6bc82f 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.h +++ b/Source/Core/VideoCommon/PerformanceMetrics.h @@ -43,6 +43,9 @@ public: double GetSpeed() const; double GetMaxSpeed() const; + // Call from any thread. + void SetLatestFramePresentationOffset(DT offset); + // ImGui Functions void DrawImGuiStats(const float backbuffer_scale); @@ -55,6 +58,8 @@ private: std::atomic<double> m_speed{}; std::atomic<double> m_max_speed{}; + std::atomic<DT> m_frame_presentation_offset{}; + struct PerfSample { TimePoint clock_time; |
