diff options
| author | JMC47 <JMC4789@gmail.com> | 2025-05-01 21:29:02 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-01 21:29:02 -0400 |
| commit | 2b568566acc2aed7a0fd39504a145ad9228f67b0 (patch) | |
| tree | 8718085f9587d2d5ece384b74595b98b1deae55d /Source/Core/VideoCommon | |
| parent | 539a3ed021269439d287891ee14d1f43779eb5fb (diff) | |
| parent | bad78cfed416d89ceb6b0acf6c134d3691b3d624 (diff) | |
Merge pull request #13535 from m-brodschi/mihaib/fix-shutdown-crash
Core, VideoCommon: Fix crash at shutdown due to destructor order
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceMetrics.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceMetrics.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceTracker.cpp | 13 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceTracker.h | 5 |
4 files changed, 15 insertions, 11 deletions
diff --git a/Source/Core/VideoCommon/PerformanceMetrics.cpp b/Source/Core/VideoCommon/PerformanceMetrics.cpp index 8d18b846ef..520f9d8b95 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.cpp +++ b/Source/Core/VideoCommon/PerformanceMetrics.cpp @@ -35,6 +35,12 @@ void PerformanceMetrics::CountVBlank() m_vps_counter.Count(); } +void PerformanceMetrics::OnEmulationStateChanged([[maybe_unused]] Core::State state) +{ + m_fps_counter.InvalidateLastTime(); + m_vps_counter.InvalidateLastTime(); +} + void PerformanceMetrics::CountThrottleSleep(DT sleep) { m_time_sleeping += sleep; diff --git a/Source/Core/VideoCommon/PerformanceMetrics.h b/Source/Core/VideoCommon/PerformanceMetrics.h index 7beac394dc..bca6372d18 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.h +++ b/Source/Core/VideoCommon/PerformanceMetrics.h @@ -7,6 +7,7 @@ #include <deque> #include "Common/CommonTypes.h" +#include "Core/Core.h" #include "VideoCommon/PerformanceTracker.h" namespace Core @@ -29,6 +30,7 @@ public: void CountFrame(); void CountVBlank(); + void OnEmulationStateChanged(Core::State state); // Call from CPU thread. void CountThrottleSleep(DT sleep); diff --git a/Source/Core/VideoCommon/PerformanceTracker.cpp b/Source/Core/VideoCommon/PerformanceTracker.cpp index f61f8fe63e..7113f388d1 100644 --- a/Source/Core/VideoCommon/PerformanceTracker.cpp +++ b/Source/Core/VideoCommon/PerformanceTracker.cpp @@ -23,17 +23,9 @@ PerformanceTracker::PerformanceTracker(const std::optional<std::string> log_name const std::optional<DT> sample_window_duration) : m_log_name{log_name}, m_sample_window_duration{sample_window_duration} { - m_on_state_changed_handle = - Core::AddOnStateChangedCallback([this](Core::State state) { m_is_last_time_sane = false; }); - Reset(); } -PerformanceTracker::~PerformanceTracker() -{ - Core::RemoveOnStateChangedCallback(&m_on_state_changed_handle); -} - void PerformanceTracker::Reset() { m_raw_dts.Clear(); @@ -135,6 +127,11 @@ DT PerformanceTracker::GetLastRawDt() const return m_last_raw_dt; } +void PerformanceTracker::InvalidateLastTime() +{ + m_is_last_time_sane = false; +} + void PerformanceTracker::ImPlotPlotLines(const char* label) const { // "quality" graph uses twice as many points. diff --git a/Source/Core/VideoCommon/PerformanceTracker.h b/Source/Core/VideoCommon/PerformanceTracker.h index fac6435101..358de676b4 100644 --- a/Source/Core/VideoCommon/PerformanceTracker.h +++ b/Source/Core/VideoCommon/PerformanceTracker.h @@ -16,7 +16,7 @@ class PerformanceTracker public: PerformanceTracker(const std::optional<std::string> log_name = std::nullopt, const std::optional<DT> sample_window_duration = std::nullopt); - ~PerformanceTracker(); + ~PerformanceTracker() = default; PerformanceTracker(const PerformanceTracker&) = delete; PerformanceTracker& operator=(const PerformanceTracker&) = delete; @@ -39,6 +39,7 @@ public: DT GetDtAvg() const; DT GetDtStd() const; DT GetLastRawDt() const; + void InvalidateLastTime(); private: void LogRenderTimeToFile(DT val); @@ -47,8 +48,6 @@ private: void PushFront(DT value); void PopBack(); - int m_on_state_changed_handle; - // Name of log file and file stream std::optional<std::string> m_log_name; std::ofstream m_bench_file; |
