mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-03-18 19:32:41 +00:00
Merge pull request #14442 from Dentomologist/performancemetrics_use_state_changed_hookableevent
PerformanceMetrics: Use HookableEvent for state changed callback
This commit is contained in:
commit
12d790a54a
@ -929,10 +929,9 @@ Common::EventHook AddOnStateChangedCallback(StateChangedCallbackFunc callback)
|
||||
return s_state_changed_event.Register(std::move(callback));
|
||||
}
|
||||
|
||||
void NotifyStateChanged(Core::State state)
|
||||
void NotifyStateChanged(const Core::State state)
|
||||
{
|
||||
s_state_changed_event.Trigger(state);
|
||||
g_perf_metrics.OnEmulationStateChanged(state);
|
||||
}
|
||||
|
||||
void UpdateWantDeterminism(Core::System& system, bool initial)
|
||||
|
||||
@ -8,11 +8,22 @@
|
||||
#include <imgui.h>
|
||||
#include <implot.h>
|
||||
|
||||
#include "Common/HookableEvent.h"
|
||||
#include "Core/Config/GraphicsSettings.h"
|
||||
#include "Core/Core.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
PerformanceMetrics g_perf_metrics;
|
||||
|
||||
PerformanceMetrics::PerformanceMetrics()
|
||||
{
|
||||
const auto invalidate_counters_last_time = [this](Core::State) {
|
||||
m_fps_counter.InvalidateLastTime();
|
||||
m_vps_counter.InvalidateLastTime();
|
||||
};
|
||||
m_state_change_hook = Core::AddOnStateChangedCallback(invalidate_counters_last_time);
|
||||
}
|
||||
|
||||
void PerformanceMetrics::Reset()
|
||||
{
|
||||
m_fps_counter.Reset();
|
||||
@ -37,12 +48,6 @@ 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;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include <deque>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Common/HookableEvent.h"
|
||||
#include "VideoCommon/PerformanceTracker.h"
|
||||
|
||||
namespace Core
|
||||
@ -18,7 +18,7 @@ class System;
|
||||
class PerformanceMetrics
|
||||
{
|
||||
public:
|
||||
PerformanceMetrics() = default;
|
||||
PerformanceMetrics();
|
||||
~PerformanceMetrics() = default;
|
||||
|
||||
PerformanceMetrics(const PerformanceMetrics&) = delete;
|
||||
@ -30,7 +30,6 @@ public:
|
||||
|
||||
void CountFrame();
|
||||
void CountVBlank();
|
||||
void OnEmulationStateChanged(Core::State state);
|
||||
|
||||
// Call from CPU thread.
|
||||
void CountThrottleSleep(DT sleep);
|
||||
@ -69,6 +68,8 @@ private:
|
||||
|
||||
std::deque<PerfSample> m_samples;
|
||||
DT m_time_sleeping{};
|
||||
|
||||
Common::EventHook m_state_change_hook;
|
||||
};
|
||||
|
||||
extern PerformanceMetrics g_perf_metrics;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user