From 03f86f364fbcfb99c1728ae05affb669cf231cb7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 14 Jun 2014 08:42:18 -0700 Subject: [PATCH] Skip debug stepping time in list/func time. Just makes the debug stats actually useful while stepping. A bit of overengineering, but it makes it easy to go frame-by-frame looking for perf issues. --- Core/HLE/HLE.cpp | 10 ++++- Core/HLE/HLE.h | 2 + GPU/Common/GPUDebugInterface.h | 4 ++ GPU/Debugger/Stepping.cpp | 3 ++ GPU/GPUCommon.cpp | 24 +++++++++++- GPU/GPUCommon.h | 72 +++++++++++++++++----------------- 6 files changed, 78 insertions(+), 37 deletions(-) diff --git a/Core/HLE/HLE.cpp b/Core/HLE/HLE.cpp index 05fae6678..7bdf11e4f 100644 --- a/Core/HLE/HLE.cpp +++ b/Core/HLE/HLE.cpp @@ -510,6 +510,12 @@ void *GetQuickSyscallFunc(MIPSOpcode op) return (void *)&CallSyscallWithoutFlags; } +static double hleSteppingTime = 0.0; +void hleSetSteppingTime(double t) +{ + hleSteppingTime += t; +} + void CallSyscall(MIPSOpcode op) { double start = 0.0; // need to initialize to fix the race condition where g_Config.bShowDebugStats is enabled in the middle of this func. @@ -540,6 +546,8 @@ void CallSyscall(MIPSOpcode op) u32 callno = (op >> 6) & 0xFFFFF; //20 bits int funcnum = callno & 0xFFF; int modulenum = (callno & 0xFF000) >> 12; - updateSyscallStats(modulenum, funcnum, time_now_d() - start); + double total = time_now_d() - start - hleSteppingTime; + hleSteppingTime = 0.0; + updateSyscallStats(modulenum, funcnum, total); } } diff --git a/Core/HLE/HLE.h b/Core/HLE/HLE.h index 78c6158a6..dac4527bf 100644 --- a/Core/HLE/HLE.h +++ b/Core/HLE/HLE.h @@ -91,6 +91,8 @@ void hleRunInterrupts(); void hleDebugBreak(); // Don't set temp regs to 0xDEADBEEF. void hleSkipDeadbeef(); +// Set time spent in debugger (for more useful debug stats while debugging.) +void hleSetSteppingTime(double t); // Delays the result for usec microseconds, allowing other threads to run during this time. u32 hleDelayResult(u32 result, const char *reason, int usec); diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index 5c9ef9cd6..0905413bd 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -200,6 +200,10 @@ public: virtual GPUDebugOp DissassembleOp(u32 pc, u32 op) = 0; virtual std::vector DissassembleOpRange(u32 startpc, u32 endpc) = 0; + // Enter/exit stepping mode. Mainly for better debug stats on time taken. + virtual void NotifySteppingEnter() = 0; + virtual void NotifySteppingExit() = 0; + virtual u32 GetRelativeAddress(u32 data) = 0; virtual u32 GetVertexAddress() = 0; virtual u32 GetIndexAddress() = 0; diff --git a/GPU/Debugger/Stepping.cpp b/GPU/Debugger/Stepping.cpp index f9bb65940..19167b986 100644 --- a/GPU/Debugger/Stepping.cpp +++ b/GPU/Debugger/Stepping.cpp @@ -118,6 +118,8 @@ bool EnterStepping(std::function callback) { return false; } + gpuDebug->NotifySteppingEnter(); + // Just to be sure. if (pauseAction == PAUSE_CONTINUE) { pauseAction = PAUSE_BREAK; @@ -131,6 +133,7 @@ bool EnterStepping(std::function callback) { pauseWait.wait(pauseLock); } while (pauseAction != PAUSE_CONTINUE); + gpuDebug->NotifySteppingExit(); isStepping = false; return true; } diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index dfbc12b5c..e1097d125 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -10,6 +10,7 @@ #include "Core/MemMap.h" #include "Core/Host.h" #include "Core/Reporting.h" +#include "Core/HLE/HLE.h" #include "Core/HLE/sceKernelMemory.h" #include "Core/HLE/sceKernelInterrupt.h" #include "Core/HLE/sceKernelThread.h" @@ -36,6 +37,7 @@ void GPUCommon::Reinitialize() { isbreak = false; drawCompleteTicks = 0; busyTicks = 0; + timeSpentStepping_ = 0.0; interruptsEnabled_ = true; UpdateTickEstimate(0); } @@ -446,6 +448,23 @@ u32 GPUCommon::Break(int mode) { return currentList->id; } +void GPUCommon::NotifySteppingEnter() { + if (g_Config.bShowDebugStats) { + time_update(); + timeSteppingStarted_ = time_now_d(); + } +} +void GPUCommon::NotifySteppingExit() { + if (g_Config.bShowDebugStats) { + if (timeSteppingStarted_ <= 0.0) { + ERROR_LOG(G3D, "Mismatched stepping enter/exit."); + } + time_update(); + timeSpentStepping_ += time_now_d() - timeSteppingStarted_; + timeSteppingStarted_ = 0.0; + } +} + bool GPUCommon::InterpretList(DisplayList &list) { // Initialized to avoid a race condition with bShowDebugStats changing. double start = 0.0; @@ -518,7 +537,10 @@ bool GPUCommon::InterpretList(DisplayList &list) { if (g_Config.bShowDebugStats) { time_update(); - gpuStats.msProcessingDisplayLists += time_now_d() - start; + double total = time_now_d() - start - timeSpentStepping_; + hleSetSteppingTime(timeSpentStepping_); + timeSpentStepping_ = 0.0; + gpuStats.msProcessingDisplayLists += total; } return gpuState == GPUSTATE_DONE || gpuState == GPUSTATE_ERROR; } diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index ec6c43c2a..7ec808f53 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -85,6 +85,40 @@ public: return false; } + // From GPUDebugInterface. + virtual bool GetCurrentDisplayList(DisplayList &list); + virtual std::vector ActiveDisplayLists(); + virtual void ResetListPC(int listID, u32 pc); + virtual void ResetListStall(int listID, u32 stall); + virtual void ResetListState(int listID, DisplayListState state); + + virtual GPUDebugOp DissassembleOp(u32 pc, u32 op); + virtual std::vector DissassembleOpRange(u32 startpc, u32 endpc); + + virtual void NotifySteppingEnter(); + virtual void NotifySteppingExit(); + + virtual u32 GetRelativeAddress(u32 data); + virtual u32 GetVertexAddress(); + virtual u32 GetIndexAddress(); + virtual GPUgstate GetGState(); + virtual void SetCmdValue(u32 op); + + virtual DisplayList* getList(int listid) { + return &dls[listid]; + } + + const std::list& GetDisplayLists() { + return dlQueue; + } + virtual bool DecodeTexture(u8* dest, GPUgstate state) { + return false; + } + std::vector GetFramebufferList() { + return std::vector(); + } + virtual void ClearShaderCache() {} + protected: // To avoid virtual calls to PreExecuteOp(). virtual void FastRunLoop(DisplayList &list) = 0; @@ -162,39 +196,7 @@ private: #endif } -public: - // From GPUDebugInterface. - virtual bool GetCurrentDisplayList(DisplayList &list); - virtual std::vector ActiveDisplayLists(); - virtual void ResetListPC(int listID, u32 pc); - virtual void ResetListStall(int listID, u32 stall); - virtual void ResetListState(int listID, DisplayListState state); - - virtual GPUDebugOp DissassembleOp(u32 pc, u32 op); - virtual std::vector DissassembleOpRange(u32 startpc, u32 endpc); - - virtual u32 GetRelativeAddress(u32 data); - virtual u32 GetVertexAddress(); - virtual u32 GetIndexAddress(); - virtual GPUgstate GetGState(); - virtual void SetCmdValue(u32 op); - - virtual DisplayList* getList(int listid) - { - return &dls[listid]; - } - - const std::list& GetDisplayLists() - { - return dlQueue; - } - virtual bool DecodeTexture(u8* dest, GPUgstate state) - { - return false; - } - std::vector GetFramebufferList() - { - return std::vector(); - } - virtual void ClearShaderCache() {} + // Debug stats. + double timeSteppingStarted_; + double timeSpentStepping_; };