From f01aaeafb179fa4a74dae46906cc4219600ddf8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 7 Feb 2026 18:16:54 +0100 Subject: [PATCH] Split CopyDisplayToOutput in preparation for the next step --- Core/HLE/sceDisplay.cpp | 3 ++- Core/HLE/sceNetAdhoc.cpp | 2 +- GPU/GPUCommon.h | 3 ++- GPU/GPUCommonHW.cpp | 5 +++-- GPU/GPUCommonHW.h | 6 ++++-- GPU/Software/SoftGpu.cpp | 2 +- GPU/Software/SoftGpu.h | 3 ++- UI/EmuScreen.cpp | 6 ++++-- headless/Headless.cpp | 6 ++++-- 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index b68bb5797c..56669862eb 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -661,7 +661,8 @@ void __DisplayFlip(int cyclesLate) { } } if (nextFrame) { - gpu->CopyDisplayToOutput(g_displayLayoutConfigCached, fbReallyDirty); + gpu->SetCurFramebufferDirty(fbReallyDirty); + gpu->CopyDisplayToOutput(g_displayLayoutConfigCached); if (fbReallyDirty) { DisplayFireActualFlip(); } diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 6e04ddebc6..0e6dfdbe8d 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -795,7 +795,7 @@ static int ptp_send_postoffice(int idx, const void *data, int *len) { } if (ptp_send_status == AEMU_POSTOFFICE_CLIENT_OUT_OF_MEMORY) { // this is pretty critical - ERROR_LOG(Log::sceNet, "%s: critical: huge client buf %d what is going on please fix", __func__, len); + ERROR_LOG(Log::sceNet, "%s: critical: huge client buf %d what is going on please fix", __func__, len ? *len : 0); } return 0; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 8e999d5f52..49d185caa6 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -124,7 +124,8 @@ public: uint32_t GetAddrTranslation() override; virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) = 0; - virtual void CopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty) = 0; + virtual void SetCurFramebufferDirty(bool dirty) = 0; + virtual void CopyDisplayToOutput(const DisplayLayoutConfig &config) = 0; virtual bool PresentedThisFrame() const = 0; // Invalidate any cached content sourced from the specified range. diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index b07273fc59..f2f1c199d1 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -530,7 +530,7 @@ void GPUCommonHW::PreExecuteOp(u32 op, u32 diff) { CheckFlushOp(op >> 24, diff); } -void GPUCommonHW::CopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty) { +void GPUCommonHW::CopyDisplayToOutput(const DisplayLayoutConfig &config) { drawEngineCommon_->FlushQueuedDepth(); // Flush anything left over. drawEngineCommon_->Flush(); @@ -538,7 +538,8 @@ void GPUCommonHW::CopyDisplayToOutput(const DisplayLayoutConfig &config, bool re shaderManager_->DirtyLastShader(); // after this, render pass is active. - framebufferManager_->CopyDisplayToOutput(config, reallyDirty); + framebufferManager_->CopyDisplayToOutput(config, curFramebufferDirty_); + curFramebufferDirty_ = false; gstate_c.Dirty(DIRTY_TEXTURE_IMAGE); } diff --git a/GPU/GPUCommonHW.h b/GPU/GPUCommonHW.h index 5e62ffc826..f2179e6b9a 100644 --- a/GPU/GPUCommonHW.h +++ b/GPU/GPUCommonHW.h @@ -7,10 +7,11 @@ class GPUCommonHW : public GPUCommon { public: GPUCommonHW(GraphicsContext *gfxCtx, Draw::DrawContext *draw); - ~GPUCommonHW(); + ~GPUCommonHW() override; // This can fail, and if so no render pass is active. - void CopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty) override; + void SetCurFramebufferDirty(bool dirty) override { curFramebufferDirty_ = dirty; } + void CopyDisplayToOutput(const DisplayLayoutConfig &config) override; void DoState(PointerWrap &p) override; void DeviceLost() override; void DeviceRestore(Draw::DrawContext *draw) override; @@ -105,4 +106,5 @@ protected: int msaaLevel_ = 0; bool sawExactEqualDepth_ = false; ShaderManagerCommon *shaderManager_ = nullptr; + bool curFramebufferDirty_ = false; }; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index f4b79a2b0e..17b3e2058f 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -646,7 +646,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(const DisplayLayoutConfig &config, presentation_->CopyToOutput(config, outputFlags, config.iInternalScreenRotation, u0, v0, u1, v1); } -void SoftGPU::CopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty) { +void SoftGPU::CopyDisplayToOutput(const DisplayLayoutConfig &config) { drawEngine_->transformUnit.Flush(this, "output"); // The display always shows 480x272. CopyToCurrentFboFromDisplayRam(config, FB_WIDTH, FB_HEIGHT); diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index 434caef499..8c276d304c 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -137,7 +137,8 @@ public: void UpdateCmdInfo() override {} void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override; - void CopyDisplayToOutput(const DisplayLayoutConfig &config, bool reallyDirty) override; + void SetCurFramebufferDirty(bool dirty) override {} + void CopyDisplayToOutput(const DisplayLayoutConfig &config) override; void GetStats(char *buffer, size_t bufsize) override; std::vector GetFramebufferList() const override { return std::vector(); } void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index b0247fb39e..00a225e528 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1690,7 +1690,8 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { if (PSP_IsInited() && !skipBufferEffects) { _dbg_assert_(gpu); gpu->BeginHostFrame(displayLayoutConfig); - gpu->CopyDisplayToOutput(displayLayoutConfig, true); + gpu->SetCurFramebufferDirty(true); + gpu->CopyDisplayToOutput(displayLayoutConfig); gpu->EndHostFrame(); } if (gpu && gpu->PresentedThisFrame()) { @@ -1803,7 +1804,8 @@ ScreenRenderFlags EmuScreen::RunEmulation(ScreenRenderMode mode, bool framebuffe // This won't work in non-buffered, but that's fine. if (!framebufferBound && PSP_IsInited()) { // draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, clearColor }, "EmuScreen_Stepping"); - gpu->CopyDisplayToOutput(displayLayoutConfig, true); + gpu->SetCurFramebufferDirty(true); + gpu->CopyDisplayToOutput(displayLayoutConfig); framebufferBound = true; } } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 139a26d18b..520e84ce4c 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -268,8 +268,10 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const if (draw) { draw->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Headless"); // Vulkan may get angry if we don't do a final present. - if (gpu) - gpu->CopyDisplayToOutput(g_Config.GetDisplayLayoutConfig(DeviceOrientation::Landscape), true); + if (gpu) { + gpu->SetCurFramebufferDirty(true); + gpu->CopyDisplayToOutput(g_Config.GetDisplayLayoutConfig(DeviceOrientation::Landscape)); + } draw->EndFrame(); }