mirror of https://github.com/PCSX2/pcsx2.git
Add PerformanceMetrics to replace multiple sources of truth
This commit is contained in:
parent
2a7c948a57
commit
c4084b4162
|
@ -142,6 +142,7 @@ set(pcsx2Sources
|
|||
Patch.cpp
|
||||
Patch_Memory.cpp
|
||||
Pcsx2Config.cpp
|
||||
PerformanceMetrics.cpp
|
||||
PrecompiledHeader.cpp
|
||||
R3000A.cpp
|
||||
R3000AInterpreter.cpp
|
||||
|
@ -214,6 +215,7 @@ set(pcsx2Headers
|
|||
Patch.h
|
||||
PathDefs.h
|
||||
PCSX2Base.h
|
||||
PerformanceMetrics.h
|
||||
PrecompiledHeader.h
|
||||
R3000A.h
|
||||
R5900Exceptions.h
|
||||
|
@ -907,7 +909,6 @@ set(pcsx2GuiSources
|
|||
gui/AppRes.cpp
|
||||
gui/CheckedStaticBox.cpp
|
||||
gui/ConsoleLogger.cpp
|
||||
gui/CpuUsageProvider.cpp
|
||||
gui/Dialogs/AboutBoxDialog.cpp
|
||||
gui/Dialogs/GSDumpDialog.cpp
|
||||
gui/Dialogs/AssertionDialog.cpp
|
||||
|
@ -981,7 +982,6 @@ set(pcsx2GuiHeaders
|
|||
gui/AppSaveStates.h
|
||||
gui/CheckedStaticBox.h
|
||||
gui/ConsoleLogger.h
|
||||
gui/CpuUsageProvider.h
|
||||
gui/Debugger/BreakpointWindow.h
|
||||
gui/Debugger/CtrlDisassemblyView.h
|
||||
gui/Debugger/CtrlMemView.h
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "GS.h"
|
||||
#include "VUmicro.h"
|
||||
#include "PerformanceMetrics.h"
|
||||
|
||||
#include "ps2/HwInternal.h"
|
||||
#include "Sio.h"
|
||||
|
@ -400,6 +401,8 @@ u32 UpdateVSyncRate()
|
|||
cpuRcntSet();
|
||||
}
|
||||
|
||||
PerformanceMetrics::SetVerticalFrequency(vertical_frequency);
|
||||
|
||||
if (m_iTicks != ticks)
|
||||
m_iTicks = ticks;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "Gif_Unit.h"
|
||||
#include "MTVU.h"
|
||||
#include "Elfheader.h"
|
||||
#include "PerformanceMetrics.h"
|
||||
#include "gui/Dialogs/ModalPopups.h"
|
||||
|
||||
#include "common/WindowInfo.h"
|
||||
|
@ -134,6 +135,7 @@ SysMtgsThread::~SysMtgsThread()
|
|||
|
||||
void SysMtgsThread::OnResumeReady()
|
||||
{
|
||||
PerformanceMetrics::Reset();
|
||||
m_sem_OpenDone.Reset();
|
||||
}
|
||||
|
||||
|
@ -478,6 +480,8 @@ void SysMtgsThread::ExecuteTaskInThread()
|
|||
if (m_VsyncSignalListener.exchange(false))
|
||||
m_sem_Vsync.Post();
|
||||
|
||||
PerformanceMetrics::Update();
|
||||
|
||||
// Do not StateCheckInThread() here
|
||||
// Otherwise we could pause while there's still data in the queue
|
||||
// Which could make the MTVU thread wait forever for it to empty
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "PerformanceMetrics.h"
|
||||
#include "System.h"
|
||||
#include "System/SysThreads.h"
|
||||
|
||||
#include "GS.h"
|
||||
#include "MTVU.h"
|
||||
|
||||
static const float UPDATE_INTERVAL = 0.5f;
|
||||
|
||||
static float s_vertical_frequency = 0.0f;
|
||||
static float s_fps = 0.0f;
|
||||
static float s_worst_frame_time = 0.0f;
|
||||
static float s_average_frame_time = 0.0f;
|
||||
static float s_average_frame_time_accumulator = 0.0f;
|
||||
static float s_worst_frame_time_accumulator = 0.0f;
|
||||
static u32 s_frames_since_last_update = 0;
|
||||
static Common::Timer s_last_update_time;
|
||||
static Common::Timer s_last_frame_time;
|
||||
|
||||
static Common::ThreadCPUTimer s_cpu_thread_timer;
|
||||
static u64 s_last_gs_time = 0;
|
||||
static u64 s_last_vu_time = 0;
|
||||
static u64 s_last_ticks = 0;
|
||||
|
||||
static double s_cpu_thread_usage = 0.0f;
|
||||
static double s_cpu_thread_time = 0.0f;
|
||||
static float s_gs_thread_usage = 0.0f;
|
||||
static float s_gs_thread_time = 0.0f;
|
||||
static float s_vu_thread_usage = 0.0f;
|
||||
static float s_vu_thread_time = 0.0f;
|
||||
|
||||
void PerformanceMetrics::Clear()
|
||||
{
|
||||
Reset();
|
||||
|
||||
s_fps = 0.0f;
|
||||
s_worst_frame_time = 0.0f;
|
||||
s_average_frame_time = 0.0f;
|
||||
|
||||
s_cpu_thread_usage = 0.0f;
|
||||
s_cpu_thread_time = 0.0f;
|
||||
s_gs_thread_usage = 0.0f;
|
||||
s_gs_thread_time = 0.0f;
|
||||
s_vu_thread_usage = 0.0f;
|
||||
s_vu_thread_time = 0.0f;
|
||||
}
|
||||
|
||||
void PerformanceMetrics::Reset()
|
||||
{
|
||||
s_average_frame_time_accumulator = 0.0f;
|
||||
s_worst_frame_time_accumulator = 0.0f;
|
||||
|
||||
s_last_update_time.Reset();
|
||||
s_last_frame_time.Reset();
|
||||
|
||||
s_cpu_thread_timer.Reset();
|
||||
s_last_gs_time = GetMTGS().GetCpuTime();
|
||||
s_last_vu_time = THREAD_VU1 ? vu1Thread.GetCpuTime() : 0;
|
||||
s_last_ticks = GetCPUTicks();
|
||||
}
|
||||
|
||||
void PerformanceMetrics::Update()
|
||||
{
|
||||
const float frame_time = s_last_frame_time.GetTimeMillisecondsAndReset();
|
||||
s_average_frame_time_accumulator += frame_time;
|
||||
s_worst_frame_time_accumulator = std::max(s_worst_frame_time_accumulator, frame_time);
|
||||
s_frames_since_last_update++;
|
||||
|
||||
const Common::Timer::Value now_ticks = Common::Timer::GetCurrentValue();
|
||||
const Common::Timer::Value ticks_diff = now_ticks - s_last_update_time.GetStartValue();
|
||||
const float time = Common::Timer::ConvertValueToSeconds(ticks_diff);
|
||||
if (time < UPDATE_INTERVAL)
|
||||
return;
|
||||
|
||||
s_worst_frame_time = s_worst_frame_time_accumulator;
|
||||
s_worst_frame_time_accumulator = 0.0f;
|
||||
s_average_frame_time = s_average_frame_time_accumulator / static_cast<float>(s_frames_since_last_update);
|
||||
s_average_frame_time_accumulator = 0.0f;
|
||||
s_fps = static_cast<float>(s_frames_since_last_update) / time;
|
||||
|
||||
s_cpu_thread_timer.GetUsageInMillisecondsAndReset(ticks_diff, &s_cpu_thread_time, &s_cpu_thread_usage);
|
||||
s_cpu_thread_time /= static_cast<double>(s_frames_since_last_update);
|
||||
|
||||
const u64 gs_time = GetMTGS().GetCpuTime();
|
||||
const u64 vu_time = THREAD_VU1 ? vu1Thread.GetCpuTime() : 0;
|
||||
const u64 ticks = GetCPUTicks();
|
||||
|
||||
const u64 gs_delta = gs_time - s_last_gs_time;
|
||||
const u64 vu_delta = vu_time - s_last_vu_time;
|
||||
const u64 ticks_delta = ticks - s_last_ticks;
|
||||
|
||||
const double pct_divider =
|
||||
100.0 * (1.0 / ((static_cast<double>(ticks_delta) * static_cast<double>(GetThreadTicksPerSecond())) /
|
||||
static_cast<double>(GetTickFrequency())));
|
||||
const double time_divider = 1000.0 * (1.0 / static_cast<double>(GetThreadTicksPerSecond())) *
|
||||
(1.0 / static_cast<double>(s_frames_since_last_update));
|
||||
|
||||
s_gs_thread_usage = static_cast<double>(gs_delta) * pct_divider;
|
||||
s_vu_thread_usage = static_cast<double>(vu_delta) * pct_divider;
|
||||
s_gs_thread_time = static_cast<double>(gs_delta) * time_divider;
|
||||
s_vu_thread_time = static_cast<double>(vu_delta) * time_divider;
|
||||
|
||||
s_last_gs_time = gs_time;
|
||||
s_last_vu_time = vu_time;
|
||||
s_last_ticks = ticks;
|
||||
|
||||
s_last_update_time.ResetTo(now_ticks);
|
||||
s_frames_since_last_update = 0;
|
||||
}
|
||||
|
||||
void PerformanceMetrics::SetCPUThreadTimer(Common::ThreadCPUTimer timer)
|
||||
{
|
||||
s_cpu_thread_timer = std::move(timer);
|
||||
}
|
||||
|
||||
void PerformanceMetrics::SetVerticalFrequency(float rate)
|
||||
{
|
||||
s_vertical_frequency = rate;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetFPS()
|
||||
{
|
||||
return s_fps;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetSpeed()
|
||||
{
|
||||
return (s_fps / s_vertical_frequency) * 100.0;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetAverageFrameTime()
|
||||
{
|
||||
return s_average_frame_time;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetWorstFrameTime()
|
||||
{
|
||||
return s_worst_frame_time;
|
||||
}
|
||||
|
||||
double PerformanceMetrics::GetCPUThreadUsage()
|
||||
{
|
||||
return s_cpu_thread_usage;
|
||||
}
|
||||
|
||||
double PerformanceMetrics::GetCPUThreadAverageTime()
|
||||
{
|
||||
return s_cpu_thread_time;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetGSThreadUsage()
|
||||
{
|
||||
return s_gs_thread_usage;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetGSThreadAverageTime()
|
||||
{
|
||||
return s_gs_thread_time;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetVUThreadUsage()
|
||||
{
|
||||
return s_vu_thread_usage;
|
||||
}
|
||||
|
||||
float PerformanceMetrics::GetVUThreadAverageTime()
|
||||
{
|
||||
return s_vu_thread_time;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "common/Timer.h"
|
||||
|
||||
namespace PerformanceMetrics
|
||||
{
|
||||
void Clear();
|
||||
void Reset();
|
||||
void Update();
|
||||
|
||||
/// Sets the EE thread for CPU usage calculations.
|
||||
void SetCPUThreadTimer(Common::ThreadCPUTimer timer);
|
||||
|
||||
/// Sets the vertical frequency, used in speed calculations.
|
||||
void SetVerticalFrequency(float rate);
|
||||
|
||||
float GetFPS();
|
||||
float GetSpeed();
|
||||
float GetAverageFrameTime();
|
||||
float GetWorstFrameTime();
|
||||
|
||||
double GetCPUThreadUsage();
|
||||
double GetCPUThreadAverageTime();
|
||||
float GetGSThreadUsage();
|
||||
float GetGSThreadAverageTime();
|
||||
float GetVUThreadUsage();
|
||||
float GetVUThreadAverageTime();
|
||||
} // namespace PerformanceMetrics
|
|
@ -19,6 +19,7 @@
|
|||
#include "IopBios.h"
|
||||
#include "R5900.h"
|
||||
|
||||
#include "common/Timer.h"
|
||||
#include "common/WindowInfo.h"
|
||||
extern WindowInfo g_gs_window_info;
|
||||
|
||||
|
@ -35,6 +36,7 @@ extern WindowInfo g_gs_window_info;
|
|||
#include "USB/USB.h"
|
||||
#include "MemoryCardFile.h"
|
||||
#include "PAD/Gamepad.h"
|
||||
#include "PerformanceMetrics.h"
|
||||
|
||||
#include "DebugTools/MIPSAnalyst.h"
|
||||
#include "DebugTools/SymbolMap.h"
|
||||
|
@ -317,10 +319,14 @@ void SysCoreThread::TearDownSystems(SystemsMask systemsToTearDown)
|
|||
if (systemsToTearDown & System_PAD) PADclose();
|
||||
if (systemsToTearDown & System_SPU2) SPU2close();
|
||||
if (systemsToTearDown & System_MCD) FileMcd_EmuClose();
|
||||
|
||||
PerformanceMetrics::SetCPUThreadTimer(Common::ThreadCPUTimer());
|
||||
}
|
||||
|
||||
void SysCoreThread::OnResumeInThread(SystemsMask systemsToReinstate)
|
||||
{
|
||||
PerformanceMetrics::SetCPUThreadTimer(Common::ThreadCPUTimer::GetForCallingThread());
|
||||
|
||||
GetMTGS().WaitForOpen();
|
||||
if (systemsToReinstate & System_DEV9) DEV9open();
|
||||
if (systemsToReinstate & System_USB) USBopen(g_gs_window_info);
|
||||
|
|
|
@ -284,29 +284,6 @@ public:
|
|||
virtual ~pxAppResources();
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// FramerateManager
|
||||
// --------------------------------------------------------------------------------------
|
||||
class FramerateManager
|
||||
{
|
||||
public:
|
||||
static const uint FramerateQueueDepth = 64;
|
||||
|
||||
protected:
|
||||
u64 m_fpsqueue[FramerateQueueDepth];
|
||||
int m_fpsqueue_writepos;
|
||||
uint m_initpause;
|
||||
|
||||
public:
|
||||
FramerateManager() { Reset(); }
|
||||
virtual ~FramerateManager() = default;
|
||||
|
||||
void Reset();
|
||||
void Resume();
|
||||
void DoFrame();
|
||||
double GetFramerate() const;
|
||||
};
|
||||
|
||||
class StartupOptions
|
||||
{
|
||||
public:
|
||||
|
@ -474,7 +451,6 @@ protected:
|
|||
Threading::Mutex m_mtx_LoadingGameDB;
|
||||
|
||||
public:
|
||||
FramerateManager FpsManager;
|
||||
std::unique_ptr<CommandDictionary> GlobalCommands;
|
||||
std::unique_ptr<AcceleratorDictionary> GlobalAccels;
|
||||
|
||||
|
|
|
@ -95,23 +95,6 @@ void Pcsx2App::DispatchEvent( AppEventType evt )
|
|||
|
||||
void Pcsx2App::DispatchEvent( CoreThreadStatus evt )
|
||||
{
|
||||
switch( evt )
|
||||
{
|
||||
case CoreThread_Indeterminate:
|
||||
break;
|
||||
|
||||
case CoreThread_Started:
|
||||
case CoreThread_Reset:
|
||||
case CoreThread_Stopped:
|
||||
FpsManager.Reset();
|
||||
break;
|
||||
|
||||
case CoreThread_Resumed:
|
||||
case CoreThread_Suspended:
|
||||
FpsManager.Resume();
|
||||
break;
|
||||
}
|
||||
|
||||
// Clear the sticky key statuses, because hell knows what'll change while PAD
|
||||
// is suspended.
|
||||
|
||||
|
|
|
@ -354,44 +354,6 @@ wxAppTraits* Pcsx2App::CreateTraits()
|
|||
return new Pcsx2AppTraits;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// FramerateManager (implementations)
|
||||
// --------------------------------------------------------------------------------------
|
||||
void FramerateManager::Reset()
|
||||
{
|
||||
//memzero( m_fpsqueue );
|
||||
m_initpause = FramerateQueueDepth;
|
||||
m_fpsqueue_writepos = 0;
|
||||
|
||||
for( uint i=0; i<FramerateQueueDepth; ++i )
|
||||
m_fpsqueue[i] = GetCPUTicks();
|
||||
|
||||
Resume();
|
||||
}
|
||||
|
||||
//
|
||||
void FramerateManager::Resume()
|
||||
{
|
||||
}
|
||||
|
||||
void FramerateManager::DoFrame()
|
||||
{
|
||||
m_fpsqueue_writepos = (m_fpsqueue_writepos + 1) % FramerateQueueDepth;
|
||||
m_fpsqueue[m_fpsqueue_writepos] = GetCPUTicks();
|
||||
|
||||
// intentionally leave 1 on the counter here, since ultimately we want to divide the
|
||||
// final result (in GetFramerate() by QueueDepth-1.
|
||||
if( m_initpause > 1 ) --m_initpause;
|
||||
}
|
||||
|
||||
double FramerateManager::GetFramerate() const
|
||||
{
|
||||
if( m_initpause > (FramerateQueueDepth/2) ) return 0.0;
|
||||
const u64 delta = m_fpsqueue[m_fpsqueue_writepos] - m_fpsqueue[(m_fpsqueue_writepos + 1) % FramerateQueueDepth];
|
||||
const u32 ticks_per_frame = (u32)(delta / (FramerateQueueDepth-m_initpause));
|
||||
return (double)GetTickFrequency() / (double)ticks_per_frame;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Pcsx2App Event Handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -412,8 +374,6 @@ void Pcsx2App::LogicalVsync()
|
|||
|
||||
// Update / Calculate framerate!
|
||||
|
||||
FpsManager.DoFrame();
|
||||
|
||||
if (EmuConfig.GS.FMVAspectRatioSwitch != FMVAspectRatioSwitchType::Off) {
|
||||
if (EnableFMV) {
|
||||
DevCon.Warning("FMV on");
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
|
||||
#include "CpuUsageProvider.h"
|
||||
#include "System.h"
|
||||
|
||||
#ifndef __POSIX__
|
||||
#include "System/SysThreads.h"
|
||||
#endif
|
||||
|
||||
#include "GS.h"
|
||||
#include "MTVU.h"
|
||||
|
||||
void AllPCSX2Threads::LoadWithCurrentTimes()
|
||||
{
|
||||
ee = GetCoreThread().GetCpuTime();
|
||||
gs = GetMTGS().GetCpuTime();
|
||||
vu = vu1Thread.GetCpuTime();
|
||||
ui = GetThreadCpuTime();
|
||||
update = GetCPUTicks();
|
||||
}
|
||||
|
||||
AllPCSX2Threads AllPCSX2Threads::operator-( const AllPCSX2Threads& right ) const
|
||||
{
|
||||
AllPCSX2Threads retval;
|
||||
|
||||
retval.ee = ee - right.ee;
|
||||
retval.gs = gs - right.gs;
|
||||
retval.vu = vu - right.vu;
|
||||
retval.ui = ui - right.ui;
|
||||
retval.update = update - right.update;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
CpuUsageProvider::CpuUsageProvider()
|
||||
{
|
||||
m_pct_ee = 0;
|
||||
m_pct_gs = 0;
|
||||
m_pct_vu = 0;
|
||||
m_pct_ui = 0;
|
||||
m_writepos = 0;
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CpuUsageProvider::Reset()
|
||||
{
|
||||
for( uint i=0; i<QueueDepth; ++i )
|
||||
m_queue[i].LoadWithCurrentTimes();
|
||||
}
|
||||
|
||||
bool CpuUsageProvider::IsImplemented() const
|
||||
{
|
||||
return GetThreadTicksPerSecond() != 0;
|
||||
}
|
||||
|
||||
void CpuUsageProvider::UpdateStats()
|
||||
{
|
||||
// Measure deltas between the first and last positions in the ring buffer:
|
||||
|
||||
AllPCSX2Threads& newone( m_queue[m_writepos] );
|
||||
newone.LoadWithCurrentTimes();
|
||||
m_writepos = (m_writepos+1) % QueueDepth;
|
||||
const AllPCSX2Threads deltas( newone - m_queue[m_writepos] );
|
||||
|
||||
// get the real time passed, scaled to the Thread's tick frequency.
|
||||
u64 timepass = (deltas.update * GetThreadTicksPerSecond()) / GetTickFrequency();
|
||||
|
||||
m_pct_ee = (deltas.ee * 100) / timepass;
|
||||
m_pct_gs = (deltas.gs * 100) / timepass;
|
||||
m_pct_vu = (deltas.vu * 100) / timepass;
|
||||
m_pct_ui = (deltas.ui * 100) / timepass;
|
||||
}
|
||||
|
||||
int CpuUsageProvider::GetEEcorePct() const
|
||||
{
|
||||
return m_pct_ee;
|
||||
}
|
||||
|
||||
int CpuUsageProvider::GetGsPct() const
|
||||
{
|
||||
return m_pct_gs;
|
||||
}
|
||||
|
||||
int CpuUsageProvider::GetVUPct() const
|
||||
{
|
||||
return m_pct_vu;
|
||||
}
|
||||
|
||||
int CpuUsageProvider::GetGuiPct() const
|
||||
{
|
||||
return m_pct_ui;
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AppEventListeners.h"
|
||||
#include <memory>
|
||||
|
||||
class BaseCpuUsageProvider
|
||||
{
|
||||
public:
|
||||
BaseCpuUsageProvider() {}
|
||||
virtual ~BaseCpuUsageProvider() = default;
|
||||
|
||||
virtual bool IsImplemented() const=0;
|
||||
virtual void UpdateStats()=0;
|
||||
virtual int GetEEcorePct() const=0;
|
||||
virtual int GetGsPct() const=0;
|
||||
virtual int GetVUPct() const=0;
|
||||
virtual int GetGuiPct() const=0;
|
||||
};
|
||||
|
||||
struct AllPCSX2Threads
|
||||
{
|
||||
u64 ee, gs, vu, ui;
|
||||
u64 update;
|
||||
|
||||
void LoadWithCurrentTimes();
|
||||
AllPCSX2Threads operator-( const AllPCSX2Threads& right ) const;
|
||||
};
|
||||
|
||||
class CpuUsageProvider :
|
||||
public BaseCpuUsageProvider,
|
||||
public EventListener_CoreThread
|
||||
{
|
||||
public:
|
||||
static const uint QueueDepth = 4;
|
||||
|
||||
protected:
|
||||
AllPCSX2Threads m_queue[QueueDepth];
|
||||
|
||||
uint m_writepos;
|
||||
u32 m_pct_ee;
|
||||
u32 m_pct_gs;
|
||||
u32 m_pct_vu;
|
||||
u32 m_pct_ui;
|
||||
|
||||
public:
|
||||
CpuUsageProvider();
|
||||
virtual ~CpuUsageProvider() = default;
|
||||
|
||||
bool IsImplemented() const;
|
||||
void Reset();
|
||||
void UpdateStats();
|
||||
int GetEEcorePct() const;
|
||||
int GetGsPct() const;
|
||||
int GetVUPct() const;
|
||||
int GetGuiPct() const;
|
||||
|
||||
protected:
|
||||
void CoreThread_OnResumed() { Reset(); }
|
||||
};
|
|
@ -29,6 +29,7 @@
|
|||
#include "gui/AppConfig.h"
|
||||
#include "gui/GSFrame.h"
|
||||
#include "Counters.h"
|
||||
#include "PerformanceMetrics.h"
|
||||
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/listctrl.h>
|
||||
|
@ -656,7 +657,7 @@ void Dialogs::GSDumpDialog::ProcessDumpEvent(const GSData& event, char* regs)
|
|||
g_FrameCount++;
|
||||
Pcsx2App* app = (Pcsx2App*)wxApp::GetInstance();
|
||||
if (app)
|
||||
app->FpsManager.DoFrame();
|
||||
PerformanceMetrics::Update();
|
||||
break;
|
||||
}
|
||||
case ReadFIFO2:
|
||||
|
@ -769,7 +770,7 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread()
|
|||
GSFrame* window = nullptr;
|
||||
if (app)
|
||||
{
|
||||
app->FpsManager.Reset();
|
||||
PerformanceMetrics::Reset();
|
||||
window = app->GetGsFramePtr();
|
||||
g_FrameCount = 0;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "MainFrame.h"
|
||||
#include "MSWstuff.h"
|
||||
#include "PAD/Gamepad.h"
|
||||
#include "PerformanceMetrics.h"
|
||||
|
||||
#include "gui/Dialogs/ModalPopups.h"
|
||||
|
||||
|
@ -859,32 +860,23 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
|
|||
if (g_FrameCount == 0)
|
||||
return;
|
||||
|
||||
double fps = wxGetApp().FpsManager.GetFramerate();
|
||||
|
||||
FastFormatUnicode cpuUsage;
|
||||
if (m_CpuUsage.IsImplemented()) {
|
||||
m_CpuUsage.UpdateStats();
|
||||
|
||||
if (!IsFullScreen()) {
|
||||
cpuUsage.Write(L"EE: %3d%%", m_CpuUsage.GetEEcorePct());
|
||||
cpuUsage.Write(L" | GS: %3d%%", m_CpuUsage.GetGsPct());
|
||||
cpuUsage.Write(L"EE: %3.0f%%", PerformanceMetrics::GetCPUThreadUsage());
|
||||
cpuUsage.Write(L" | GS: %3.0f%%", PerformanceMetrics::GetGSThreadUsage());
|
||||
|
||||
if (THREAD_VU1)
|
||||
cpuUsage.Write(L" | VU: %3d%%", m_CpuUsage.GetVUPct());
|
||||
|
||||
pxNonReleaseCode(cpuUsage.Write(L" | UI: %3d%%", m_CpuUsage.GetGuiPct()));
|
||||
{
|
||||
cpuUsage.Write(L" | VU: %3.0f%%", PerformanceMetrics::GetVUThreadUsage());
|
||||
OSDmonitor(Color_StrongGreen, "VU:", std::to_string(lround(PerformanceMetrics::GetVUThreadUsage())).c_str());
|
||||
}
|
||||
|
||||
if (THREAD_VU1)
|
||||
OSDmonitor(Color_StrongGreen, "VU:", std::to_string(m_CpuUsage.GetVUPct()).c_str());
|
||||
|
||||
OSDmonitor(Color_StrongGreen, "EE:", std::to_string(m_CpuUsage.GetEEcorePct()).c_str());
|
||||
OSDmonitor(Color_StrongGreen, "GS:", std::to_string(m_CpuUsage.GetGsPct()).c_str());
|
||||
pxNonReleaseCode(OSDmonitor(Color_StrongGreen, "UI:", std::to_string(m_CpuUsage.GetGuiPct()).c_str()));
|
||||
OSDmonitor(Color_StrongGreen, "EE:", std::to_string(lround(PerformanceMetrics::GetCPUThreadUsage())).c_str());
|
||||
OSDmonitor(Color_StrongGreen, "GS:", std::to_string(lround(PerformanceMetrics::GetGSThreadUsage())).c_str());
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << std::setprecision(2) << fps;
|
||||
out << std::fixed << std::setprecision(2) << PerformanceMetrics::GetFPS();
|
||||
OSDmonitor(Color_StrongGreen, "FPS:", out.str());
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -895,8 +887,6 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
|
|||
|
||||
AppConfig::UiTemplateOptions& templates = g_Conf->Templates;
|
||||
|
||||
const float percentage = (fps * 100) / GetVerticalFrequency();
|
||||
|
||||
char gsDest[128];
|
||||
gsDest[0] = 0; // No need to set whole array to NULL.
|
||||
GSgetTitleInfo2( gsDest, sizeof(gsDest) );
|
||||
|
@ -934,8 +924,8 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
|
|||
|
||||
title.Replace(L"${slot}", pxsFmt(L"%d", States_GetCurrentSlot()));
|
||||
title.Replace(L"${limiter}", limiterStr);
|
||||
title.Replace(L"${speed}", pxsFmt(L"%3d%%", lround(percentage)));
|
||||
title.Replace(L"${vfps}", pxsFmt(L"%.02f", fps));
|
||||
title.Replace(L"${speed}", pxsFmt(L"%3d%%", lround(PerformanceMetrics::GetSpeed())));
|
||||
title.Replace(L"${vfps}", pxsFmt(L"%.02f", PerformanceMetrics::GetFPS()));
|
||||
title.Replace(L"${cpuusage}", cpuUsage);
|
||||
title.Replace(L"${omodef}", omodef);
|
||||
title.Replace(L"${omodei}", omodei);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "AppCommon.h"
|
||||
#include "CpuUsageProvider.h"
|
||||
#include "common/WindowInfo.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
@ -106,8 +105,6 @@ protected:
|
|||
wxWindowID m_id_gspanel;
|
||||
wxStatusBar* m_statusbar;
|
||||
|
||||
CpuUsageProvider m_CpuUsage;
|
||||
|
||||
public:
|
||||
GSFrame( const wxString& title);
|
||||
virtual ~GSFrame() = default;
|
||||
|
|
|
@ -352,6 +352,7 @@
|
|||
<ClCompile Include="PAD\Windows\WindowsMouse.cpp" />
|
||||
<ClCompile Include="PAD\Windows\WndProcEater.cpp" />
|
||||
<ClCompile Include="PAD\Windows\XInputEnum.cpp" />
|
||||
<ClCompile Include="PerformanceMetrics.cpp" />
|
||||
<ClCompile Include="Recording\Utilities\InputRecordingLogger.cpp" />
|
||||
<ClCompile Include="SPU2\DplIIdecoder.cpp" />
|
||||
<ClCompile Include="SPU2\debug.cpp" />
|
||||
|
@ -647,7 +648,6 @@
|
|||
<ClCompile Include="gui\AppMain.cpp" />
|
||||
<ClCompile Include="gui\AppRes.cpp" />
|
||||
<ClCompile Include="gui\ConsoleLogger.cpp" />
|
||||
<ClCompile Include="gui\CpuUsageProvider.cpp" />
|
||||
<ClCompile Include="gui\ExecutorThread.cpp" />
|
||||
<ClCompile Include="gui\FrameForGS.cpp" />
|
||||
<ClCompile Include="gui\GlobalCommands.cpp" />
|
||||
|
@ -791,6 +791,7 @@
|
|||
<ClInclude Include="PAD\Windows\WindowsMouse.h" />
|
||||
<ClInclude Include="PAD\Windows\WndProcEater.h" />
|
||||
<ClInclude Include="PAD\Windows\XInputEnum.h" />
|
||||
<ClInclude Include="PerformanceMetrics.h" />
|
||||
<ClInclude Include="SPU2\Config.h" />
|
||||
<ClInclude Include="SPU2\Global.h" />
|
||||
<ClInclude Include="SPU2\interpolate_table.h" />
|
||||
|
@ -1076,7 +1077,6 @@
|
|||
<ClInclude Include="gui\ApplyState.h" />
|
||||
<ClInclude Include="gui\AppSaveStates.h" />
|
||||
<ClInclude Include="gui\ConsoleLogger.h" />
|
||||
<ClInclude Include="gui\CpuUsageProvider.h" />
|
||||
<ClInclude Include="gui\GSFrame.h" />
|
||||
<ClInclude Include="gui\IsoDropTarget.h" />
|
||||
<ClInclude Include="gui\MainFrame.h" />
|
||||
|
|
|
@ -746,9 +746,6 @@
|
|||
<ClCompile Include="gui\ConsoleLogger.cpp">
|
||||
<Filter>AppHost</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="gui\CpuUsageProvider.cpp">
|
||||
<Filter>AppHost</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="gui\FrameForGS.cpp">
|
||||
<Filter>AppHost</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1646,6 +1643,10 @@
|
|||
<ClCompile Include="gui\AppHost.cpp">
|
||||
<Filter>AppHost</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GS\Renderers\SW\GSSetupPrimCodeGenerator.all.cpp" />
|
||||
<ClCompile Include="PerformanceMetrics.cpp">
|
||||
<Filter>System</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Patch.h">
|
||||
|
@ -1966,9 +1967,6 @@
|
|||
<ClInclude Include="gui\ConsoleLogger.h">
|
||||
<Filter>AppHost\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="gui\CpuUsageProvider.h">
|
||||
<Filter>AppHost\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="gui\IsoDropTarget.h">
|
||||
<Filter>AppHost\Include</Filter>
|
||||
</ClInclude>
|
||||
|
@ -2752,6 +2750,9 @@
|
|||
<ClInclude Include="PAD\Gamepad.h">
|
||||
<Filter>System\Ps2\PAD</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PerformanceMetrics.h">
|
||||
<Filter>System</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="windows\wxResources.rc">
|
||||
|
|
Loading…
Reference in New Issue