From 3b74d4b680eb4d4ac8169e069ce6a2a119eb88e9 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 11 Apr 2020 23:41:59 -0700 Subject: [PATCH 1/2] GE Debugger: Prevent crash when stopping execution. --- GPU/Debugger/Playback.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GPU/Debugger/Playback.cpp b/GPU/Debugger/Playback.cpp index 806d43db9fdd..b11e0a7dda7d 100644 --- a/GPU/Debugger/Playback.cpp +++ b/GPU/Debugger/Playback.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include "profiler/profiler.h" @@ -43,6 +44,7 @@ namespace GPURecord { static std::string lastExecFilename; static std::vector lastExecCommands; static std::vector lastExecPushbuf; +static std::mutex executeLock; // This class maps pushbuffer (dump data) sections to PSP memory. // Dumps can be larger than available PSP memory, because they include generated data too. @@ -654,6 +656,8 @@ static bool ReadCompressed(u32 fp, void *dest, size_t sz) { } static void ReplayStop() { + // This can happen from a separate thread. + std::lock_guard guard(executeLock); lastExecFilename.clear(); lastExecCommands.clear(); lastExecPushbuf.clear(); @@ -662,6 +666,7 @@ static void ReplayStop() { bool RunMountedReplay(const std::string &filename) { _assert_msg_(SYSTEM, !GPURecord::IsActivePending(), "Cannot run replay while recording."); + std::lock_guard guard(executeLock); Core_ListenStopRequest(&ReplayStop); if (lastExecFilename != filename) { PROFILE_THIS_SCOPE("ReplayLoad"); From dbdb72eac0f09b0a32ae458cea9d99024ff4f5af Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 12 Apr 2020 00:02:48 -0700 Subject: [PATCH 2/2] UI: Respect insets with on-device debug stats. --- UI/EmuScreen.cpp | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 61eda92850a2..ce0b44141876 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1244,22 +1244,25 @@ void EmuScreen::checkPowerDown() { } } -static void DrawDebugStats(DrawBuffer *draw2d) { +static void DrawDebugStats(DrawBuffer *draw2d, const Bounds &bounds) { FontID ubuntu24("UBUNTU24"); + float left = std::max(bounds.w / 2 - 20.0f, 550.0f); + float right = bounds.w - left - 20.0f; + char statbuf[4096]; __DisplayGetDebugStats(statbuf, sizeof(statbuf)); draw2d->SetFontScale(.7f, .7f); - draw2d->DrawText(ubuntu24, statbuf, 11, 31, 0xc0000000, FLAG_DYNAMIC_ASCII); - draw2d->DrawText(ubuntu24, statbuf, 10, 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); + draw2d->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, left, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT); + draw2d->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, left, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT); __SasGetDebugStats(statbuf, sizeof(statbuf)); - draw2d->DrawText(ubuntu24, statbuf, PSP_CoreParameter().pixelWidth / 2 + 11, 31, 0xc0000000, FLAG_DYNAMIC_ASCII); - draw2d->DrawText(ubuntu24, statbuf, PSP_CoreParameter().pixelWidth / 2 + 10, 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); + draw2d->DrawTextRect(ubuntu24, statbuf, bounds.x + left + 21, bounds.y + 31, right, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT); + draw2d->DrawTextRect(ubuntu24, statbuf, bounds.x + left + 20, bounds.y + 30, right, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT); draw2d->SetFontScale(1.0f, 1.0f); } -static void DrawAudioDebugStats(DrawBuffer *draw2d) { +static void DrawAudioDebugStats(DrawBuffer *draw2d, const Bounds &bounds) { FontID ubuntu24("UBUNTU24"); char statbuf[1024] = { 0 }; const AudioDebugStats *stats = __AudioGetDebugStats(); @@ -1275,8 +1278,8 @@ static void DrawAudioDebugStats(DrawBuffer *draw2d) { stats->instantSampleRate, stats->lastPushSize); draw2d->SetFontScale(0.7f, 0.7f); - draw2d->DrawText(ubuntu24, statbuf, 11, 31, 0xc0000000, FLAG_DYNAMIC_ASCII); - draw2d->DrawText(ubuntu24, statbuf, 10, 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); + draw2d->DrawTextRect(ubuntu24, statbuf, bounds.x + 11, bounds.y + 31, bounds.w - 20, bounds.h - 30, 0xc0000000, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT); + draw2d->DrawTextRect(ubuntu24, statbuf, bounds.x + 10, bounds.y + 30, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT); draw2d->SetFontScale(1.0f, 1.0f); } @@ -1302,7 +1305,7 @@ static void DrawFPS(DrawBuffer *draw2d, const Bounds &bounds) { draw2d->SetFontScale(1.0f, 1.0f); } -static void DrawFrameTimes(UIContext *ctx) { +static void DrawFrameTimes(UIContext *ctx, const Bounds &bounds) { FontID ubuntu24("UBUNTU24"); int valid, pos; double *sleepHistory; @@ -1312,22 +1315,22 @@ static void DrawFrameTimes(UIContext *ctx) { ctx->Flush(); ctx->BeginNoTex(); - int bottom = ctx->GetBounds().y2(); + int bottom = bounds.y2(); for (int i = 0; i < valid; ++i) { double activeTime = history[i] - sleepHistory[i]; - ctx->Draw()->vLine(i, bottom, bottom - activeTime * scale, 0xFF3FFF3F); - ctx->Draw()->vLine(i, bottom - activeTime * scale, bottom - history[i] * scale, 0x7F3FFF3F); + ctx->Draw()->vLine(bounds.x + i, bottom, bottom - activeTime * scale, 0xFF3FFF3F); + ctx->Draw()->vLine(bounds.x + i, bottom - activeTime * scale, bottom - history[i] * scale, 0x7F3FFF3F); } - ctx->Draw()->vLine(pos, bottom, bottom - 512, 0xFFff3F3f); + ctx->Draw()->vLine(bounds.x + pos, bottom, bottom - 512, 0xFFff3F3f); - ctx->Draw()->hLine(0, bottom - 0.0333*scale, width, 0xFF3f3Fff); - ctx->Draw()->hLine(0, bottom - 0.0167*scale, width, 0xFF3f3Fff); + ctx->Draw()->hLine(bounds.x, bottom - 0.0333 * scale, bounds.x + width, 0xFF3f3Fff); + ctx->Draw()->hLine(bounds.x, bottom - 0.0167 * scale, bounds.x + width, 0xFF3f3Fff); ctx->Flush(); ctx->Begin(); ctx->Draw()->SetFontScale(0.5f, 0.5f); - ctx->Draw()->DrawText(ubuntu24, "33.3ms", width, bottom - 0.0333*scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII); - ctx->Draw()->DrawText(ubuntu24, "16.7ms", width, bottom - 0.0167*scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII); + ctx->Draw()->DrawText(ubuntu24, "33.3ms", bounds.x + width, bottom - 0.0333 * scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII); + ctx->Draw()->DrawText(ubuntu24, "16.7ms", bounds.x + width, bottom - 0.0167 * scale, 0xFF3f3Fff, ALIGN_BOTTOMLEFT | FLAG_DYNAMIC_ASCII); ctx->Draw()->SetFontScale(1.0f, 1.0f); } @@ -1499,19 +1502,19 @@ void EmuScreen::renderUI() { } if (g_Config.bShowDebugStats && !invalid_) { - DrawDebugStats(draw2d); + DrawDebugStats(draw2d, ctx->GetLayoutBounds()); } if (g_Config.bShowAudioDebug && !invalid_) { - DrawAudioDebugStats(draw2d); + DrawAudioDebugStats(draw2d, ctx->GetLayoutBounds()); } if (g_Config.iShowFPSCounter && !invalid_) { - DrawFPS(draw2d, ctx->GetBounds()); + DrawFPS(draw2d, ctx->GetLayoutBounds()); } if (g_Config.bDrawFrameGraph && !invalid_) { - DrawFrameTimes(ctx); + DrawFrameTimes(ctx, ctx->GetLayoutBounds()); } #if !PPSSPP_PLATFORM(UWP)