Skip to content

Commit

Permalink
Core: Add a feature to log stats on any frame drop.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Mar 24, 2017
1 parent 438af2f commit 47565e1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Core/HLE/sceDisplay.cpp
Expand Up @@ -56,6 +56,9 @@
#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;
Expand Down Expand Up @@ -479,6 +482,19 @@ static bool FrameTimingThrottled() {
return !PSP_CoreParameter().unthrottle;
}

static void DoFrameDropLogging(float scaledTimestep) {
// Make sure we're collecting so we can log.
Core_ForceCollectDebugStats(true);

if (lastFrameTime != 0.0 && 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);
}
}

// Let's collect all the throttling and frameskipping logic here.
static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) {
PROFILE_THIS_SCOPE("timing");
Expand Down Expand Up @@ -522,6 +538,10 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) {
}
curFrameTime = time_now_d();

if (logFrameDrops) {
DoFrameDropLogging(scaledTimestep);
}

// Auto-frameskip automatically if speed limit is set differently than the default.
bool useAutoFrameskip = g_Config.bAutoFrameSkip && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
if (g_Config.bAutoFrameSkip || (g_Config.iFrameSkip == 0 && fpsLimiter == FPS_LIMIT_CUSTOM && g_Config.iFpsLimit > 60)) {
Expand Down

0 comments on commit 47565e1

Please sign in to comment.