From 01703f7ffc53de0a165bece2ad2d81c0827707ad Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 23 Mar 2017 19:16:17 -0700 Subject: [PATCH] Core: Add UI option to enable frame drop logging. --- Core/Config.cpp | 1 + Core/Config.h | 1 + Core/HLE/sceDisplay.cpp | 18 +++++++----------- Core/System.cpp | 13 +++---------- Core/System.h | 1 - UI/GameSettingsScreen.cpp | 1 + 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index fc198df165..41a76f23f0 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -520,6 +520,7 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("FragmentTestCache", &g_Config.bFragmentTestCache, true, true, true), ConfigSetting("GfxDebugOutput", &g_Config.bGfxDebugOutput, false, false, false), + ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 67c406a125..8031dbf128 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -235,6 +235,7 @@ public: bool bShowDebuggerOnLoad; int iShowFPSCounter; + bool bLogFrameDrops; bool bShowDebugStats; bool bShowAudioDebug; bool bAudioResampler; diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 611e288d44..6bf8a92f00 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -56,9 +56,6 @@ #include "GPU/Common/FramebufferCommon.h" #include "GPU/Common/PostShader.h" -// Enable to log info about any dropped frames. -static const bool logFrameDrops = true; - struct FrameBufferState { u32 topaddr; GEBufferFormat fmt; @@ -483,15 +480,15 @@ static bool FrameTimingThrottled() { } static void DoFrameDropLogging(float scaledTimestep) { - // Make sure we're collecting so we can log. - Core_ForceCollectDebugStats(true); - - if (lastFrameTime != 0.0 && lastFrameTime + scaledTimestep < curFrameTime) { + if (lastFrameTime != 0.0 && !wasPaused && lastFrameTime + scaledTimestep < curFrameTime) { const double actualTimestep = curFrameTime - lastFrameTime; char stats[4096]; __DisplayGetDebugStats(stats, sizeof(stats)); - NOTICE_LOG(HLE, "Dropping frames (budget = %.2fms / %.1ffps), actual = %.2fms (+%.2fms) %.1ffps\n%s", scaledTimestep * 1000.0, 1.0 / scaledTimestep, actualTimestep * 1000.0, (actualTimestep - scaledTimestep) * 1000.0, 1.0 / actualTimestep, stats); + NOTICE_LOG(HLE, "Dropping frames - budget = %.2fms / %.1ffps, actual = %.2fms (+%.2fms) / %.1ffps\n%s", scaledTimestep * 1000.0, 1.0 / scaledTimestep, actualTimestep * 1000.0, (actualTimestep - scaledTimestep) * 1000.0, 1.0 / actualTimestep, stats); + } else { + gpuStats.ResetFrame(); + kernelStats.ResetFrame(); } } @@ -527,8 +524,6 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) { if (lastFrameTime == 0.0 || wasPaused) { nextFrameTime = time_now_d() + scaledTimestep; - if (wasPaused) - wasPaused = false; } else { // Advance lastFrameTime by a constant amount each frame, // but don't let it get too far behind as things can get very jumpy. @@ -538,7 +533,7 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) { } curFrameTime = time_now_d(); - if (logFrameDrops) { + if (g_Config.bLogFrameDrops) { DoFrameDropLogging(scaledTimestep); } @@ -578,6 +573,7 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) { } lastFrameTime = nextFrameTime; + wasPaused = false; } static void DoFrameIdleTiming() { diff --git a/Core/System.cpp b/Core/System.cpp index 159d212fe5..62e5303b0a 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -370,16 +370,9 @@ 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; + if (coreCollectDebugStats != flag) { + coreCollectDebugStats = flag; mipsr4k.ClearJitCache(); } } @@ -534,7 +527,7 @@ void PSP_EndHostFrame() { } void PSP_RunLoopUntil(u64 globalticks) { - Core_UpdateCollectDebugStats(g_Config.bShowDebugStats); + Core_UpdateCollectDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops); SaveState::Process(); if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) { diff --git a/Core/System.h b/Core/System.h index 87851ee20a..f8f6472d25 100644 --- a/Core/System.h +++ b/Core/System.h @@ -98,7 +98,6 @@ enum CoreState }; extern bool coreCollectDebugStats; -void Core_ForceCollectDebugStats(bool flag); extern volatile CoreState coreState; extern volatile bool coreStatePending; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3149a489d6..5709c7ffa7 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1225,6 +1225,7 @@ void DeveloperToolsScreen::CreateViews() { #endif list->Add(new CheckBox(&g_Config.bEnableLogging, dev->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged); + list->Add(new CheckBox(&g_Config.bLogFrameDrops, dev->T("Log Dropped Frame Statistics"))); list->Add(new Choice(dev->T("Logging Channels")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLogConfig); list->Add(new ItemHeader(dev->T("Language"))); list->Add(new Choice(dev->T("Load language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoadLanguageIni);