diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-11-04 13:57:08 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-04 13:57:08 -0600 |
| commit | 7d617878e0a4d61bd1362cb5069b86e82be4723f (patch) | |
| tree | c4fac7cdff7aeacf983ba65ba0ea8bc1ed9a8f4b /Source/Core/VideoCommon/Statistics.cpp | |
| parent | 947ed4aaf69714d6df0209bf1c55bd419ab8a3a3 (diff) | |
| parent | f289b06e0db8bba6a3491d6e3cf0c2dd1b7a29fa (diff) | |
Merge pull request #13626 from jordan-woyak/non-global-hookable-event
Common: Make HookableEvent use non-static data.
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(); +} |
