mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Fix falling back to the old timing, also show audio timing in the frame timing overlay
This commit is contained in:
parent
fb4c167d37
commit
f86053d020
@ -150,6 +150,8 @@ void sleep_ms(int ms) {
|
||||
}
|
||||
|
||||
void sleep_s(double s) {
|
||||
if (s <= 0.0)
|
||||
return;
|
||||
#if defined(_WIN32) || defined(__EMSCRIPTEN__) || defined(HAVE_LIBNX)
|
||||
sleep_ms((int)(s * 1000.0));
|
||||
#else
|
||||
|
@ -471,7 +471,7 @@ public:
|
||||
|
||||
// Volatile development settings
|
||||
// Overlays
|
||||
int iDebugOverlay;
|
||||
int iDebugOverlay; // enum DebugOverlay
|
||||
|
||||
bool bGpuLogProfiler; // Controls the Vulkan logging profiler (profiles textures uploads etc).
|
||||
|
||||
|
@ -133,6 +133,11 @@ void FrameTiming::SetTimeStep(float scaledTimeStep) {
|
||||
setTimestepCalled_ = true;
|
||||
}
|
||||
|
||||
void FrameTiming::DontUse() {
|
||||
usePresentTiming = false;
|
||||
setTimestepCalled_ = true;
|
||||
}
|
||||
|
||||
void FrameTiming::AfterCPUSlice() {
|
||||
if (!setTimestepCalled_) {
|
||||
// We're in the menu or something.
|
||||
@ -147,17 +152,17 @@ void FrameTiming::BeforePresent() {
|
||||
|
||||
// Wait until we hit the next present time. Ideally we'll be fairly close here due to the previous AfterPresent wait.
|
||||
nextPresentTime = lastPresentTime + this->timeStep + nudge_;
|
||||
while (true) {
|
||||
// Not sure we need the while loop.
|
||||
double remaining = nextPresentTime - time_now_d();
|
||||
if (remaining <= 0.0)
|
||||
break;
|
||||
sleep_s(remaining);
|
||||
}
|
||||
|
||||
lastPresentTime = nextPresentTime;
|
||||
}
|
||||
|
||||
void FrameTiming::AfterPresent() {
|
||||
if (!usePresentTiming)
|
||||
return;
|
||||
|
||||
// Sleep slightly less time than all of the available room, in case of a CPU spike.
|
||||
// This should be a tweakable.
|
||||
const double margin = 2.0 * 0.001; // 4 ms
|
||||
@ -166,7 +171,4 @@ void FrameTiming::AfterPresent() {
|
||||
if (postSleep > 0.0) {
|
||||
sleep_s(postSleep);
|
||||
}
|
||||
|
||||
if (!usePresentTiming)
|
||||
return;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
|
||||
void BeforeCPUSlice(const FrameHistoryBuffer &frameHistory);
|
||||
void SetTimeStep(float scaledTimeStep);
|
||||
void DontUse();
|
||||
void AfterCPUSlice();
|
||||
void BeforePresent();
|
||||
void AfterPresent();
|
||||
|
@ -646,7 +646,7 @@ void __DisplayFlip(int cyclesLate) {
|
||||
int frameSkipNum;
|
||||
|
||||
// If the ideal case, use the new timing path.
|
||||
g_frameTiming.usePresentTiming = g_Config.iFrameSkip == 0 && !refreshRateNeedsSkip;
|
||||
g_frameTiming.usePresentTiming = g_Config.iFrameSkip == 0 && !refreshRateNeedsSkip && throttle;
|
||||
|
||||
if (g_frameTiming.usePresentTiming) {
|
||||
if (Core_NextFrame()) {
|
||||
@ -657,11 +657,12 @@ void __DisplayFlip(int cyclesLate) {
|
||||
goto finishUp;
|
||||
} else {
|
||||
// This should only happen if we're stepping in the debugger.
|
||||
// Go to the old path.
|
||||
g_frameTiming.usePresentTiming = false;
|
||||
// Fall through to the old path.
|
||||
}
|
||||
}
|
||||
|
||||
g_frameTiming.DontUse();
|
||||
|
||||
// Setting CORE_NEXTFRAME (which Core_NextFrame does) causes a swap.
|
||||
if (fbReallyDirty || noRecentFlip || postEffectRequiresFlip) {
|
||||
// Check first though, might've just quit / been paused.
|
||||
|
@ -108,7 +108,7 @@ static void DrawFrameTimes(UIContext *ctx, const Bounds &bounds) {
|
||||
static void DrawFrameTiming(UIContext *ctx, const Bounds &bounds) {
|
||||
FontID ubuntu24("UBUNTU24");
|
||||
|
||||
char statBuf[1024]{};
|
||||
char statBuf[2048]{};
|
||||
|
||||
ctx->Flush();
|
||||
ctx->BindFontTexture();
|
||||
@ -174,6 +174,12 @@ static void DrawFrameTiming(UIContext *ctx, const Bounds &bounds) {
|
||||
}
|
||||
ctx->Draw()->DrawTextRect(ubuntu24, statBuf, bounds.x + 10 + i * 150, bounds.y + 150, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
|
||||
// Also draw audio stats, because they're quite relevant.
|
||||
|
||||
System_AudioGetDebugStats(statBuf, sizeof(statBuf));
|
||||
ctx->Draw()->DrawTextRect(ubuntu24, statBuf, bounds.x + 10, bounds.y + 360, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
|
||||
|
||||
ctx->Draw()->SetFontScale(1.0f, 1.0f);
|
||||
ctx->Flush();
|
||||
ctx->RebindTexture();
|
||||
|
Loading…
Reference in New Issue
Block a user