mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00
Reorganise way profiling stats are collected.
Info needs to be updated when VM thread completes a frame.
This commit is contained in:
parent
2a16227256
commit
6be7755785
6 changed files with 43 additions and 48 deletions
|
@ -902,13 +902,12 @@ void CPS2VM::EmuThread()
|
|||
m_pad->Update(m_ee->m_ram);
|
||||
}
|
||||
#ifdef PROFILE
|
||||
{
|
||||
CProfiler::GetInstance().CountCurrentZone();
|
||||
auto stats = CProfiler::GetInstance().GetStats();
|
||||
ProfileFrameDone(stats);
|
||||
CProfiler::GetInstance().Reset();
|
||||
}
|
||||
|
||||
//Finish up profile
|
||||
CProfiler::GetInstance().CountCurrentZone();
|
||||
#endif
|
||||
OnNewFrame();
|
||||
#ifdef PROFILE
|
||||
CProfiler::GetInstance().Reset();
|
||||
#endif
|
||||
m_cpuUtilisation = CPU_UTILISATION_INFO();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
typedef std::unique_ptr<COpticalMedia> OpticalMediaPtr;
|
||||
typedef std::unique_ptr<Ee::CSubSystem> EeSubSystemPtr;
|
||||
typedef std::unique_ptr<Iop::CSubSystem> IopSubSystemPtr;
|
||||
typedef Framework::CSignal<void(const CProfiler::ZoneArray&)> ProfileFrameDoneSignal;
|
||||
typedef Framework::CSignal<void()> NewFrameEvent;
|
||||
typedef std::function<void(CPS2VM*)> ExecutableReloadedHandler;
|
||||
|
||||
CPS2VM();
|
||||
|
@ -95,7 +95,7 @@ public:
|
|||
EeSubSystemPtr m_ee;
|
||||
IopSubSystemPtr m_iop;
|
||||
|
||||
ProfileFrameDoneSignal ProfileFrameDone;
|
||||
NewFrameEvent OnNewFrame;
|
||||
|
||||
ExecutableReloadedHandler BeforeExecutableReloaded;
|
||||
ExecutableReloadedHandler AfterExecutableReloaded;
|
||||
|
|
|
@ -196,10 +196,6 @@ void MainWindow::InitVirtualMachine()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
m_profileFrameDoneConnection = m_virtualMachine->ProfileFrameDone.Connect(std::bind(&CStatsManager::OnProfileFrameDone, &CStatsManager::GetInstance(), std::placeholders::_1));
|
||||
#endif
|
||||
|
||||
//OnExecutableChange might be called from another thread, we need to wrap it around a Qt signal
|
||||
m_OnExecutableChangeConnection = m_virtualMachine->m_ee->m_os->OnExecutableChange.Connect(std::bind(&MainWindow::EmitOnExecutableChange, this));
|
||||
connect(this, SIGNAL(onExecutableChange()), this, SLOT(HandleOnExecutableChange()));
|
||||
|
@ -258,7 +254,8 @@ void MainWindow::SetupGsHandler()
|
|||
connect(m_outputwindow, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(outputWindow_mousePressEvent(QMouseEvent*)));
|
||||
connect(m_outputwindow, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(outputWindow_mouseReleaseEvent(QMouseEvent*)));
|
||||
|
||||
m_OnNewFrameConnection = m_virtualMachine->m_ee->m_gs->OnNewFrame.Connect(std::bind(&CStatsManager::OnNewFrame, &CStatsManager::GetInstance(), m_virtualMachine, std::placeholders::_1));
|
||||
m_OnNewFrameConnection = m_virtualMachine->OnNewFrame.Connect(std::bind(&CStatsManager::OnNewFrame, &CStatsManager::GetInstance(), m_virtualMachine));
|
||||
m_OnGsNewFrameConnection = m_virtualMachine->m_ee->m_gs->OnNewFrame.Connect(std::bind(&CStatsManager::OnGsNewFrame, &CStatsManager::GetInstance(), std::placeholders::_1));
|
||||
}
|
||||
|
||||
void MainWindow::SetupSoundHandler()
|
||||
|
|
|
@ -103,7 +103,6 @@ private:
|
|||
QLabel* m_gsLabel = nullptr;
|
||||
#ifdef PROFILE
|
||||
QLabel* m_profileStatsLabel = nullptr;
|
||||
CPS2VM::ProfileFrameDoneSignal::Connection m_profileFrameDoneConnection;
|
||||
#endif
|
||||
ElidedLabel* m_msgLabel = nullptr;
|
||||
QTimer* m_fpsTimer = nullptr;
|
||||
|
@ -117,7 +116,8 @@ private:
|
|||
fs::path m_lastPath;
|
||||
|
||||
Framework::CSignal<void()>::Connection m_OnExecutableChangeConnection;
|
||||
CGSHandler::NewFrameEvent::Connection m_OnNewFrameConnection;
|
||||
CPS2VM::NewFrameEvent::Connection m_OnNewFrameConnection;
|
||||
CGSHandler::NewFrameEvent::Connection m_OnGsNewFrameConnection;
|
||||
CScreenShotUtils::Connection m_screenShotCompleteConnection;
|
||||
CVirtualMachine::RunningStateChangeEvent::Connection m_onRunningStateChangeConnection;
|
||||
|
||||
|
|
|
@ -3,17 +3,39 @@
|
|||
#include "string_format.h"
|
||||
#include "PS2VM.h"
|
||||
|
||||
void CStatsManager::OnNewFrame(CPS2VM* virtualMachine, uint32 drawCalls)
|
||||
void CStatsManager::OnNewFrame(CPS2VM* virtualMachine)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> statsLock(m_statsMutex);
|
||||
auto cpuUtilisation = virtualMachine->GetCpuUtilisationInfo();
|
||||
m_cpuUtilisation.eeTotalTicks += cpuUtilisation.eeTotalTicks;
|
||||
m_cpuUtilisation.eeIdleTicks += cpuUtilisation.eeIdleTicks;
|
||||
m_cpuUtilisation.iopTotalTicks += cpuUtilisation.iopTotalTicks;
|
||||
m_cpuUtilisation.iopIdleTicks += cpuUtilisation.iopIdleTicks;
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
std::lock_guard<std::mutex> profileZonesLock(m_profilerZonesMutex);
|
||||
|
||||
auto zones = CProfiler::GetInstance().GetStats();
|
||||
for(auto& zone : zones)
|
||||
{
|
||||
auto& zoneInfo = m_profilerZones[zone.name];
|
||||
zoneInfo.currentValue += zone.totalTime;
|
||||
if(zone.totalTime != 0)
|
||||
{
|
||||
zoneInfo.minValue = std::min<uint64>(zoneInfo.minValue, zone.totalTime);
|
||||
}
|
||||
zoneInfo.maxValue = std::max<uint64>(zoneInfo.maxValue, zone.totalTime);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CStatsManager::OnGsNewFrame(uint32 drawCalls)
|
||||
{
|
||||
std::lock_guard<std::mutex> statsLock(m_statsMutex);
|
||||
m_frames++;
|
||||
m_drawCalls += drawCalls;
|
||||
|
||||
auto cpuUtilisation = virtualMachine->GetCpuUtilisationInfo();
|
||||
m_cpuUtilisation.eeTotalTicks += cpuUtilisation.eeTotalTicks;
|
||||
m_cpuUtilisation.eeIdleTicks += cpuUtilisation.eeIdleTicks;
|
||||
m_cpuUtilisation.iopTotalTicks += cpuUtilisation.iopTotalTicks;
|
||||
m_cpuUtilisation.iopIdleTicks += cpuUtilisation.iopIdleTicks;
|
||||
}
|
||||
|
||||
float CStatsManager::ComputeCpuUsageRatio(int32 idleTicks, int32 totalTicks)
|
||||
|
@ -103,23 +125,3 @@ void CStatsManager::ClearStats()
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
|
||||
void CStatsManager::OnProfileFrameDone(const CProfiler::ZoneArray& zones)
|
||||
{
|
||||
std::lock_guard<std::mutex> profileZonesLock(m_profilerZonesMutex);
|
||||
|
||||
for(auto& zone : zones)
|
||||
{
|
||||
auto& zoneInfo = m_profilerZones[zone.name];
|
||||
zoneInfo.currentValue += zone.totalTime;
|
||||
if(zone.totalTime != 0)
|
||||
{
|
||||
zoneInfo.minValue = std::min<uint64>(zoneInfo.minValue, zone.totalTime);
|
||||
}
|
||||
zoneInfo.maxValue = std::max<uint64>(zoneInfo.maxValue, zone.totalTime);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
class CStatsManager : public CSingleton<CStatsManager>
|
||||
{
|
||||
public:
|
||||
void OnNewFrame(CPS2VM*, uint32);
|
||||
void OnNewFrame(CPS2VM*);
|
||||
void OnGsNewFrame(uint32);
|
||||
|
||||
static float ComputeCpuUsageRatio(int32 idleTicks, int32 totalTicks);
|
||||
|
||||
|
@ -23,10 +24,6 @@ public:
|
|||
|
||||
void ClearStats();
|
||||
|
||||
#ifdef PROFILE
|
||||
void OnProfileFrameDone(const CProfiler::ZoneArray&);
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::mutex m_statsMutex;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue