Core: Separate collecting and displaying stats.

This commit is contained in:
Unknown W. Brackets committed 2017-03-23 18:57:18 -07:00
1 parent d408b9980a
commit 438af2f4fa
4 files changed
+36 -16

No files matched your search

+8 -10
View File
@@ -493,18 +493,16 @@ const HLEFunction *GetSyscallFuncPointer(MIPSOpcode op)
return &moduleDB[modulenum].funcTable[funcnum];
}
void *GetQuickSyscallFunc(MIPSOpcode op)
{
// TODO: Clear jit cache on g_Config.bShowDebugStats change?
if (g_Config.bShowDebugStats)
return NULL;
void *GetQuickSyscallFunc(MIPSOpcode op) {
if (coreCollectDebugStats)
return nullptr;
const HLEFunction *info = GetSyscallFuncPointer(op);
if (!info || !info->func)
return NULL;
return nullptr;
// TODO: Do this with a flag?
if (op == GetSyscallOp("FakeSysCalls", NID_IDLE))
if (op == idleOp)
return (void *)info->func;
if (info->flags != 0)
return (void *)&CallSyscallWithFlags;
@@ -520,8 +518,8 @@ void hleSetSteppingTime(double t)
void CallSyscall(MIPSOpcode op)
{
PROFILE_THIS_SCOPE("syscall");
double start = 0.0; // need to initialize to fix the race condition where g_Config.bShowDebugStats is enabled in the middle of this func.
if (g_Config.bShowDebugStats)
double start = 0.0; // need to initialize to fix the race condition where coreCollectDebugStats is enabled in the middle of this func.
if (coreCollectDebugStats)
{
time_update();
start = time_now_d();
@@ -546,7 +544,7 @@ void CallSyscall(MIPSOpcode op)
ERROR_LOG_REPORT(HLE, "Unimplemented HLE function %s", info->name ? info->name : "(\?\?\?)");
}
if (g_Config.bShowDebugStats)
if (coreCollectDebugStats)
{
time_update();
u32 callno = (op >> 6) & 0xFFFFF; //20 bits
+19
View File
@@ -86,6 +86,9 @@ static std::condition_variable cpuThreadReplyCond;
static u64 cpuThreadUntil;
bool audioInitialized;
bool coreCollectDebugStats = false;
bool coreCollectDebugStatsForced = false;
// This can be read and written from ANYWHERE.
volatile CoreState coreState = CORE_STEPPING;
// Note: intentionally not used for CORE_NEXTFRAME.
@@ -367,6 +370,20 @@ void Core_UpdateState(CoreState newState) {
Core_UpdateSingleStep();
}
void Core_ForceCollectDebugStats(bool flag) {
// Don't set the real flag yet, since it may trigger clearing jit cache.
coreCollectDebugStatsForced = flag;
}
static void Core_UpdateCollectDebugStats(bool flag) {
bool newFlag = flag || coreCollectDebugStatsForced;
if (coreCollectDebugStats != newFlag) {
coreCollectDebugStats = newFlag;
mipsr4k.ClearJitCache();
}
}
void System_Wake() {
// Ping the threads so they check coreState.
CPU_NextStateNot(CPU_THREAD_NOT_RUNNING, CPU_THREAD_SHUTDOWN);
@@ -517,6 +534,8 @@ void PSP_EndHostFrame() {
}
void PSP_RunLoopUntil(u64 globalticks) {
Core_UpdateCollectDebugStats(g_Config.bShowDebugStats);
SaveState::Process();
if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) {
return;
+3
View File
@@ -97,6 +97,9 @@ enum CoreState
CORE_ERROR,
};
extern bool coreCollectDebugStats;
void Core_ForceCollectDebugStats(bool flag);
extern volatile CoreState coreState;
extern volatile bool coreStatePending;
void Core_UpdateState(CoreState newState);
+6 -6
View File
@@ -848,13 +848,13 @@ u32 GPUCommon::Break(int mode) {
}
void GPUCommon::NotifySteppingEnter() {
if (g_Config.bShowDebugStats) {
if (coreCollectDebugStats) {
time_update();
timeSteppingStarted_ = time_now_d();
}
}
void GPUCommon::NotifySteppingExit() {
if (g_Config.bShowDebugStats) {
if (coreCollectDebugStats) {
if (timeSteppingStarted_ <= 0.0) {
ERROR_LOG(G3D, "Mismatched stepping enter/exit.");
}
@@ -867,7 +867,7 @@ void GPUCommon::NotifySteppingExit() {
bool GPUCommon::InterpretList(DisplayList &list) {
// Initialized to avoid a race condition with bShowDebugStats changing.
double start = 0.0;
if (g_Config.bShowDebugStats) {
if (coreCollectDebugStats) {
time_update();
start = time_now_d();
}
@@ -936,7 +936,7 @@ bool GPUCommon::InterpretList(DisplayList &list) {
list.offsetAddr = gstate_c.offsetAddr;
if (g_Config.bShowDebugStats) {
if (coreCollectDebugStats) {
time_update();
double total = time_now_d() - start - timeSpentStepping_;
hleSetSteppingTime(timeSpentStepping_);
@@ -984,7 +984,7 @@ void GPUCommon::UpdatePC(u32 currentPC, u32 newPC) {
cyclesExecuted += 2 * executed;
cycleLastPC = newPC;
if (g_Config.bShowDebugStats) {
if (coreCollectDebugStats) {
gpuStats.otherGPUCycles += 2 * executed;
gpuStats.gpuCommandsAtCallLevel[std::min(currentList->stackptr, 3)] += executed;
}
@@ -2459,4 +2459,4 @@ bool GPUCommon::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
bool GPUCommon::GetCurrentTexture(GPUDebugBuffer &buffer, int level) {
return textureCache_->GetCurrentTextureDebug(buffer, level);
}
}