diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-05-03 02:48:44 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2025-11-02 17:30:43 -0600 |
| commit | f289b06e0db8bba6a3491d6e3cf0c2dd1b7a29fa (patch) | |
| tree | 4e95a04a656f571e4dc0a7024348d22c5a1c662e /Source/Core/VideoCommon/Statistics.cpp | |
| parent | 9c28f19e56307ac4de750ffa6ffb8c4e15e55def (diff) | |
Common: Make HookableEvent use non-static data.
Co-authored-by: Dentomologist <dentomologist@gmail.com>
Diffstat (limited to 'Source/Core/VideoCommon/Statistics.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Statistics.cpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/Source/Core/VideoCommon/Statistics.cpp b/Source/Core/VideoCommon/Statistics.cpp index db098db5c7..97c9264d18 100644 --- a/Source/Core/VideoCommon/Statistics.cpp +++ b/Source/Core/VideoCommon/Statistics.cpp @@ -20,18 +20,8 @@ Statistics g_stats; -static Common::EventHook s_before_frame_event = - BeforeFrameEvent::Register([] { g_stats.ResetFrame(); }, "Statistics::ResetFrame"); - -static Common::EventHook s_after_frame_event = AfterFrameEvent::Register( - [](const Core::System& system) { - DolphinAnalytics::Instance().ReportPerformanceInfo({ - .speed_ratio = system.GetSystemTimers().GetEstimatedEmulationPerformance(), - .num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims, - .num_draw_calls = g_stats.this_frame.num_draw_calls, - }); - }, - "Statistics::PerformanceSample"); +static Common::EventHook s_before_frame_event; +static Common::EventHook s_after_frame_event; static bool clear_scissors; @@ -507,3 +497,25 @@ void Statistics::DisplayScissor() ImGui::End(); } + +void Statistics::Init() +{ + s_before_frame_event = GetVideoEvents().before_frame_event.Register([] { g_stats.ResetFrame(); }, + "Statistics::ResetFrame"); + + s_after_frame_event = GetVideoEvents().after_frame_event.Register( + [](const Core::System& system) { + DolphinAnalytics::Instance().ReportPerformanceInfo({ + .speed_ratio = system.GetSystemTimers().GetEstimatedEmulationPerformance(), + .num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims, + .num_draw_calls = g_stats.this_frame.num_draw_calls, + }); + }, + "Statistics::PerformanceSample"); +} + +void Statistics::Shutdown() +{ + s_before_frame_event.reset(); + s_after_frame_event.reset(); +} |
