diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index d7798fed8a..8a0055e5f1 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1576,7 +1576,19 @@ void FramebufferManagerCommon::SetViewport2D(int x, int y, int w, int h) { draw_->SetViewport(viewport); } -void FramebufferManagerCommon::CopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty) { +void FramebufferManagerCommon::CopyDisplayToOutput(const DisplayLayoutConfig &config) { + // PresentationCommon sets all kinds of state, we can't rely on anything. + gstate_c.Dirty(DIRTY_ALL); + DiscardFramebufferCopy(); + currentRenderVfb_ = nullptr; + if (useBufferedRendering_) { + presentation_->CopyToOutput(config); + } else { + presentation_->NotifyPresent(); + } +} + +void FramebufferManagerCommon::PrepareCopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty) { DownloadFramebufferOnSwitch(currentRenderVfb_); shaderManager_->DirtyLastShader(); @@ -1589,12 +1601,6 @@ void FramebufferManagerCommon::CopyDisplayToOutput(const DisplayLayoutConfig &co } // No framebuffer to display! Clear to black. presentation_->SourceBlank(); - gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE); - if (useBufferedRendering_) { - presentation_->CopyToOutput(config); - } else { - presentation_->NotifyPresent(); - } return; } @@ -1663,11 +1669,6 @@ void FramebufferManagerCommon::CopyDisplayToOutput(const DisplayLayoutConfig &co // No framebuffer to display! Clear to black. presentation_->SourceBlank(); } - if (useBufferedRendering_) { - presentation_->CopyToOutput(config); - } else { - presentation_->NotifyPresent(); - } return; } @@ -1685,6 +1686,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput(const DisplayLayoutConfig &co displayFramebuf_ = vfb; if (vfb->fbo) { + _dbg_assert_(useBufferedRendering_); if (GetUIState() != UISTATE_PAUSEMENU) { if (Core_IsStepping()) VERBOSE_LOG(Log::FrameBuf, "Displaying FBO %08x", vfb->fb_address); @@ -1729,22 +1731,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput(const DisplayLayoutConfig &co presentation_->UpdateUniforms(textureCache_->VideoIsPlaying()); presentation_->SourceFramebuffer(vfb->fbo, actualWidth, actualHeight); presentation_->RunPostshaderPasses(config, flags, uvRotation, u0, v0, u1, v1); - presentation_->CopyToOutput(config); - } else { - // This is OK because here we're in "skip buffered" mode, so even if we haven't presented - // we will have a render target. - if (useBufferedRendering_) { - presentation_->CopyToOutput(config); - } else { - presentation_->NotifyPresent(); - } } - - // This may get called mid-draw if the game uses an immediate flip. - // PresentationCommon sets all kinds of state, we can't rely on anything. - gstate_c.Dirty(DIRTY_ALL); - DiscardFramebufferCopy(); - currentRenderVfb_ = nullptr; } void FramebufferManagerCommon::DecimateFBOs() { diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index 2ca89b86a4..c0367ad365 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -334,7 +334,8 @@ public: void RebindFramebuffer(const char *tag); std::vector GetFramebufferList() const; - void CopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty); + void PrepareCopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty); + void CopyDisplayToOutput(const DisplayLayoutConfig &config); bool NotifyFramebufferCopy(u32 src, u32 dest, int size, GPUCopyFlag flags, u32 skipDrawReason); void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat fmt); diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index f2f1c199d1..7e87e6a9c1 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -538,10 +538,9 @@ void GPUCommonHW::CopyDisplayToOutput(const DisplayLayoutConfig &config) { shaderManager_->DirtyLastShader(); // after this, render pass is active. - framebufferManager_->CopyDisplayToOutput(config, curFramebufferDirty_); + framebufferManager_->PrepareCopyDisplayToOutput(config, curFramebufferDirty_); + framebufferManager_->CopyDisplayToOutput(config); curFramebufferDirty_ = false; - - gstate_c.Dirty(DIRTY_TEXTURE_IMAGE); } bool GPUCommonHW::PresentedThisFrame() const {