diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 3e1b322e0d..e68cf8b5d7 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1116,6 +1116,11 @@ void EmuScreen::preRender() { using namespace Draw; DrawContext *draw = screenManager()->getDrawContext(); draw->BeginFrame(); + // Let's be consistent for the entire frame. We skip the UI texture if we don't need it. + hasVisibleUI_ = hasVisibleUI(); + if (hasVisibleUI_) { + screenManager()->getUIContext()->BeginFrame(); + } // Here we do NOT bind the backbuffer or clear the screen, unless non-buffered. // The emuscreen is different than the others - we really want to allow the game to render to framebuffers // before we ever bind the backbuffer for rendering. On mobile GPUs, switching back and forth between render @@ -1216,9 +1221,7 @@ void EmuScreen::render() { if (invalid_) return; - const bool hasVisibleUI = !osm.IsEmpty() || saveStatePreview_->GetVisibility() != UI::V_GONE || g_Config.bShowTouchControls || loadingSpinner_->GetVisibility() == UI::V_VISIBLE; - const bool showDebugUI = g_Config.bShowDebugStats || g_Config.bShowDeveloperMenu || g_Config.bShowAudioDebug || g_Config.bShowFrameProfiler; - if (hasVisibleUI || showDebugUI || g_Config.iShowFPSCounter != 0) { + if (hasVisibleUI_) { renderUI(); } @@ -1240,6 +1243,20 @@ void EmuScreen::render() { */ } +bool EmuScreen::hasVisibleUI() { + // Regular but uncommon UI. + if (saveStatePreview_->GetVisibility() != UI::V_GONE || loadingSpinner_->GetVisibility() == UI::V_VISIBLE) + return true; + if (!osm.IsEmpty() || g_Config.bShowTouchControls || g_Config.iShowFPSCounter != 0) + return true; + + // Debug UI. + if (g_Config.bShowDebugStats || g_Config.bShowDeveloperMenu || g_Config.bShowAudioDebug || g_Config.bShowFrameProfiler) + return true; + + return false; +} + void EmuScreen::renderUI() { using namespace Draw; diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index dd1fd0ee5c..0dd44e614a 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -56,6 +56,7 @@ private: void bootGame(const std::string &filename); bool bootAllowStorage(const std::string &filename); void bootComplete(); + bool hasVisibleUI(); void renderUI(); void processAxis(const AxisInput &axis, int direction); @@ -79,6 +80,7 @@ private: bool invalid_; bool quit_; bool stopRender_ = false; + bool hasVisibleUI_ = true; std::string errorMessage_; // If set, pauses at the end of the frame.