Skip to content

Commit

Permalink
Merge pull request #17879 from hrydgard/move-present-out-of-screenman…
Browse files Browse the repository at this point in the history
…ager

Call draw->Begin/EndFrame from outside the screen manager.
  • Loading branch information
hrydgard committed Aug 10, 2023
2 parents 182e0c1 + 0d4a2a7 commit a246df4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
10 changes: 1 addition & 9 deletions Common/UI/UIScreen.cpp
Expand Up @@ -191,10 +191,7 @@ void UIScreen::deviceRestored() {
void UIScreen::preRender() {
using namespace Draw;
Draw::DrawContext *draw = screenManager()->getDrawContext();
if (!draw) {
return;
}
draw->BeginFrame();
_dbg_assert_(draw != nullptr);
// Bind and clear the back buffer
draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "UI");
screenManager()->getUIContext()->BeginFrame();
Expand All @@ -211,12 +208,7 @@ void UIScreen::preRender() {
}

void UIScreen::postRender() {
Draw::DrawContext *draw = screenManager()->getDrawContext();
if (!draw) {
return;
}
screenManager()->getUIContext()->Flush();
draw->EndFrame();
}

void UIScreen::render() {
Expand Down
2 changes: 0 additions & 2 deletions UI/EmuScreen.cpp
Expand Up @@ -1355,7 +1355,6 @@ static void DrawFPS(UIContext *ctx, const Bounds &bounds) {
void EmuScreen::preRender() {
using namespace Draw;
DrawContext *draw = screenManager()->getDrawContext();
draw->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
Expand Down Expand Up @@ -1389,7 +1388,6 @@ void EmuScreen::postRender() {
return;
if (stopRender_)
draw->WipeQueue();
draw->EndFrame();
}

void EmuScreen::render() {
Expand Down
5 changes: 5 additions & 0 deletions UI/NativeApp.cpp
Expand Up @@ -1135,12 +1135,17 @@ void NativeFrame(GraphicsContext *graphicsContext) {
debugFlags |= Draw::DebugFlags::PROFILE_SCOPES;
g_screenManager->getDrawContext()->SetDebugFlags(debugFlags);

g_draw->BeginFrame();

// All actual rendering happen in here.
g_screenManager->render();
if (g_screenManager->getUIContext()->Text()) {
g_screenManager->getUIContext()->Text()->OncePerFrame();
}

// This triggers present.
g_draw->EndFrame();

if (resized) {
INFO_LOG(G3D, "Resized flag set - recalculating bounds");
resized = false;
Expand Down

0 comments on commit a246df4

Please sign in to comment.