Core: Allow forcing debug statistics collection.

Useful for remote debugging.
This commit is contained in:
Unknown W. Brackets 2021-09-19 15:17:13 -07:00
parent a06efdd222
commit 1532a729d7
3 changed files with 19 additions and 7 deletions

View file

@ -497,7 +497,7 @@ static void CalculateFPS() {
}
}
if (g_Config.bDrawFrameGraph) {
if (g_Config.bDrawFrameGraph || coreCollectDebugStats) {
frameTimeHistory[frameTimeHistoryPos++] = now - lastFrameTimeHistory;
lastFrameTimeHistory = now;
frameTimeHistoryPos = frameTimeHistoryPos % frameTimeHistorySize;
@ -682,7 +682,7 @@ static void DoFrameIdleTiming() {
#endif
}
if (g_Config.bDrawFrameGraph) {
if (g_Config.bDrawFrameGraph || coreCollectDebugStats) {
frameSleepHistory[frameTimeHistoryPos] += time_now_d() - before;
}
}
@ -848,7 +848,7 @@ void __DisplayFlip(int cyclesLate) {
CoreTiming::ScheduleEvent(0 - cyclesLate, afterFlipEvent, 0);
numVBlanksSinceFlip = 0;
if (g_Config.bDrawFrameGraph) {
if (g_Config.bDrawFrameGraph || coreCollectDebugStats) {
// Track how long we sleep (whether vsync or sleep_ms.)
frameSleepHistory[frameSleepPos] += time_now_d() - lastFrameTimeHistory;
}
@ -913,7 +913,7 @@ void hleLagSync(u64 userdata, int cyclesLate) {
const int over = (int)((now - goal) * 1000000);
ScheduleLagSync(over - emuOver);
if (g_Config.bDrawFrameGraph) {
if (g_Config.bDrawFrameGraph || coreCollectDebugStats) {
frameSleepHistory[frameTimeHistoryPos] += now - before;
}
}

View file

@ -98,7 +98,7 @@ static std::string loadingReason;
bool audioInitialized;
bool coreCollectDebugStats = false;
bool coreCollectDebugStatsForced = false;
static int coreCollectDebugStatsCounter = 0;
// This can be read and written from ANYWHERE.
volatile CoreState coreState = CORE_STEPPING;
@ -385,8 +385,9 @@ void Core_UpdateState(CoreState newState) {
}
void Core_UpdateDebugStats(bool collectStats) {
if (coreCollectDebugStats != collectStats) {
coreCollectDebugStats = collectStats;
bool newState = collectStats || coreCollectDebugStatsCounter > 0;
if (coreCollectDebugStats != newState) {
coreCollectDebugStats = newState;
mipsr4k.ClearJitCache();
}
@ -394,6 +395,15 @@ void Core_UpdateDebugStats(bool collectStats) {
gpuStats.ResetFrame();
}
void Core_ForceDebugStats(bool enable) {
if (enable) {
coreCollectDebugStatsCounter++;
} else {
coreCollectDebugStatsCounter--;
}
_assert_(coreCollectDebugStatsCounter >= 0);
}
bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) {
if (pspIsIniting || pspIsQuitting) {
return false;

View file

@ -94,6 +94,8 @@ struct PSP_LoadingLock {
// Call before PSP_BeginHostFrame() in order to not miss any GPU stats.
void Core_UpdateDebugStats(bool collectStats);
// Increments or decrements an internal counter. Intended to be used by debuggers.
void Core_ForceDebugStats(bool enable);
void Audio_Init();
void Audio_Shutdown();