mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-04-26 10:06:17 -05:00
Move PerformanceMetrics from global variable to System
This avoids the static initialization order fiasco between Core and VideoCommon Co-authored-by: Jordan Woyak <jordan.woyak@gmail.com>
This commit is contained in:
parent
7a45ede688
commit
f9c3f06f0a
|
|
@ -332,7 +332,7 @@ static void CpuThread(Core::System& system, const std::optional<std::string>& sa
|
||||||
DolphinAnalytics::Instance().ReportGameStart();
|
DolphinAnalytics::Instance().ReportGameStart();
|
||||||
|
|
||||||
// Clear performance data collected from previous threads.
|
// Clear performance data collected from previous threads.
|
||||||
g_perf_metrics.Reset();
|
system.GetPerfMetrics().Reset();
|
||||||
|
|
||||||
// The JIT need to be able to intercept faults, both for fastmem and for the BLR optimization.
|
// The JIT need to be able to intercept faults, both for fastmem and for the BLR optimization.
|
||||||
const bool exception_handler = EMM::IsExceptionHandlerSupported();
|
const bool exception_handler = EMM::IsExceptionHandlerSupported();
|
||||||
|
|
@ -856,11 +856,12 @@ void RunOnCPUThread(Core::System& system, Common::MoveOnlyFunction<void()> funct
|
||||||
// Called from Renderer::Swap (GPU thread) when a frame is presented to the host screen.
|
// Called from Renderer::Swap (GPU thread) when a frame is presented to the host screen.
|
||||||
void Callback_FramePresented(const PresentInfo& present_info)
|
void Callback_FramePresented(const PresentInfo& present_info)
|
||||||
{
|
{
|
||||||
g_perf_metrics.CountFrame();
|
auto& perf_metrics = Core::System::GetInstance().GetPerfMetrics();
|
||||||
|
perf_metrics.CountFrame();
|
||||||
|
|
||||||
const auto presentation_offset =
|
const auto presentation_offset =
|
||||||
present_info.actual_present_time - present_info.intended_present_time;
|
present_info.actual_present_time - present_info.intended_present_time;
|
||||||
g_perf_metrics.SetLatestFramePresentationOffset(presentation_offset);
|
perf_metrics.SetLatestFramePresentationOffset(presentation_offset);
|
||||||
|
|
||||||
if (present_info.reason == PresentInfo::PresentReason::VideoInterfaceDuplicate)
|
if (present_info.reason == PresentInfo::PresentReason::VideoInterfaceDuplicate)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -422,7 +422,7 @@ void CoreTimingManager::SleepUntil(TimePoint time_point)
|
||||||
|
|
||||||
// Count amount of time sleeping for analytics
|
// Count amount of time sleeping for analytics
|
||||||
const TimePoint time_after_sleep = Clock::now();
|
const TimePoint time_after_sleep = Clock::now();
|
||||||
g_perf_metrics.CountThrottleSleep(time_after_sleep - time);
|
m_system.GetPerfMetrics().CountThrottleSleep(time_after_sleep - time);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -452,8 +452,8 @@ void CoreTimingManager::Throttle(const s64 target_cycle)
|
||||||
|
|
||||||
// Measure current performance after throttling.
|
// Measure current performance after throttling.
|
||||||
Common::ScopeGuard perf_marker{[&] {
|
Common::ScopeGuard perf_marker{[&] {
|
||||||
g_perf_metrics.CountPerformanceMarker(target_cycle,
|
m_system.GetPerfMetrics().CountPerformanceMarker(
|
||||||
m_system.GetSystemTimers().GetTicksPerSecond());
|
target_cycle, m_system.GetSystemTimers().GetTicksPerSecond());
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if (IsSpeedUnlimited())
|
if (IsSpeedUnlimited())
|
||||||
|
|
@ -562,7 +562,7 @@ void CoreTimingManager::AdjustEventQueueTimes(u32 new_ppc_clock, u32 old_ppc_clo
|
||||||
|
|
||||||
UpdateSpeedLimit(ticks, m_emulation_speed);
|
UpdateSpeedLimit(ticks, m_emulation_speed);
|
||||||
|
|
||||||
g_perf_metrics.AdjustClockSpeed(ticks, new_ppc_clock, old_ppc_clock);
|
m_system.GetPerfMetrics().AdjustClockSpeed(ticks, new_ppc_clock, old_ppc_clock);
|
||||||
|
|
||||||
for (Event& ev : m_event_queue)
|
for (Event& ev : m_event_queue)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ s64 SystemTimersManager::GetLocalTimeRTCOffset() const
|
||||||
|
|
||||||
double SystemTimersManager::GetEstimatedEmulationPerformance() const
|
double SystemTimersManager::GetEstimatedEmulationPerformance() const
|
||||||
{
|
{
|
||||||
return g_perf_metrics.GetMaxSpeed();
|
return m_system.GetPerfMetrics().GetMaxSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// split from Init to break a circular dependency between VideoInterface::Init and
|
// split from Init to break a circular dependency between VideoInterface::Init and
|
||||||
|
|
|
||||||
|
|
@ -895,7 +895,7 @@ void VideoInterfaceManager::EndField(FieldType field, u64 ticks)
|
||||||
if (is_vblank_data_wanted)
|
if (is_vblank_data_wanted)
|
||||||
m_system.GetCoreTiming().Throttle(ticks);
|
m_system.GetCoreTiming().Throttle(ticks);
|
||||||
|
|
||||||
g_perf_metrics.CountVBlank();
|
m_system.GetPerfMetrics().CountVBlank();
|
||||||
m_system.GetVideoEvents().vi_end_field_event.Trigger();
|
m_system.GetVideoEvents().vi_end_field_event.Trigger();
|
||||||
Core::OnFrameEnd(m_system);
|
Core::OnFrameEnd(m_system);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ struct System::Impl
|
||||||
IOS::WiiIPC m_wii_ipc;
|
IOS::WiiIPC m_wii_ipc;
|
||||||
Memory::MemoryManager m_memory;
|
Memory::MemoryManager m_memory;
|
||||||
MemoryInterface::MemoryInterfaceManager m_memory_interface;
|
MemoryInterface::MemoryInterfaceManager m_memory_interface;
|
||||||
|
PerformanceMetrics m_perf_metrics;
|
||||||
PixelEngine::PixelEngineManager m_pixel_engine;
|
PixelEngine::PixelEngineManager m_pixel_engine;
|
||||||
PixelShaderManager m_pixel_shader_manager;
|
PixelShaderManager m_pixel_shader_manager;
|
||||||
PowerPC::PowerPCManager m_power_pc;
|
PowerPC::PowerPCManager m_power_pc;
|
||||||
|
|
@ -273,6 +274,11 @@ Movie::MovieManager& System::GetMovie() const
|
||||||
return m_impl->m_movie;
|
return m_impl->m_movie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PerformanceMetrics& System::GetPerfMetrics() const
|
||||||
|
{
|
||||||
|
return m_impl->m_perf_metrics;
|
||||||
|
}
|
||||||
|
|
||||||
PixelEngine::PixelEngineManager& System::GetPixelEngine() const
|
PixelEngine::PixelEngineManager& System::GetPixelEngine() const
|
||||||
{
|
{
|
||||||
return m_impl->m_pixel_engine;
|
return m_impl->m_pixel_engine;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "VideoCommon/PerformanceMetrics.h"
|
||||||
#include "VideoCommon/VideoEvents.h"
|
#include "VideoCommon/VideoEvents.h"
|
||||||
|
|
||||||
class GeometryShaderManager;
|
class GeometryShaderManager;
|
||||||
|
|
@ -186,6 +187,7 @@ public:
|
||||||
MemoryInterface::MemoryInterfaceManager& GetMemoryInterface() const;
|
MemoryInterface::MemoryInterfaceManager& GetMemoryInterface() const;
|
||||||
PowerPC::MMU& GetMMU() const;
|
PowerPC::MMU& GetMMU() const;
|
||||||
Movie::MovieManager& GetMovie() const;
|
Movie::MovieManager& GetMovie() const;
|
||||||
|
PerformanceMetrics& GetPerfMetrics() const;
|
||||||
PixelEngine::PixelEngineManager& GetPixelEngine() const;
|
PixelEngine::PixelEngineManager& GetPixelEngine() const;
|
||||||
PixelShaderManager& GetPixelShaderManager() const;
|
PixelShaderManager& GetPixelShaderManager() const;
|
||||||
PowerPC::PowerPCManager& GetPowerPC() const;
|
PowerPC::PowerPCManager& GetPowerPC() const;
|
||||||
|
|
|
||||||
|
|
@ -417,7 +417,8 @@ void OnScreenUI::Finalize()
|
||||||
{
|
{
|
||||||
auto lock = GetImGuiLock();
|
auto lock = GetImGuiLock();
|
||||||
|
|
||||||
g_perf_metrics.DrawImGuiStats(m_backbuffer_scale);
|
auto& perf_metrics = Core::System::GetInstance().GetPerfMetrics();
|
||||||
|
perf_metrics.DrawImGuiStats(m_backbuffer_scale);
|
||||||
DrawDebugText();
|
DrawDebugText();
|
||||||
OSD::DrawMessages();
|
OSD::DrawMessages();
|
||||||
DrawChallengesAndLeaderboards();
|
DrawChallengesAndLeaderboards();
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
PerformanceMetrics g_perf_metrics;
|
|
||||||
|
|
||||||
PerformanceMetrics::PerformanceMetrics()
|
PerformanceMetrics::PerformanceMetrics()
|
||||||
{
|
{
|
||||||
const auto invalidate_counters_last_time = [this](Core::State) {
|
const auto invalidate_counters_last_time = [this](Core::State) {
|
||||||
|
|
|
||||||
|
|
@ -71,5 +71,3 @@ private:
|
||||||
|
|
||||||
Common::EventHook m_state_change_hook;
|
Common::EventHook m_state_change_hook;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PerformanceMetrics g_perf_metrics;
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user