From 93c909a88e7b2fa49ebd0c7b7d2dd9e26093e21f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 23 Sep 2022 00:04:14 -0700 Subject: [PATCH] GPU: Upload depth only on first usage. Fixes various glitches in Kingdom Hearts, etc. --- GPU/Common/FramebufferManagerCommon.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 99ceb7ec36..330eda4796 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -548,6 +548,7 @@ void FramebufferManagerCommon::SetDepthFrameBuffer(bool isClearingDepth) { } // First time use of this framebuffer's depth buffer. + bool newlyUsingDepth = (currentRenderVfb_->usageFlags & FB_USAGE_RENDER_DEPTH) == 0; currentRenderVfb_->usageFlags |= FB_USAGE_RENDER_DEPTH; // If this first draw call is anything other than a clear, "resolve" the depth buffer, @@ -557,7 +558,7 @@ void FramebufferManagerCommon::SetDepthFrameBuffer(bool isClearingDepth) { // Need to upload the first line of depth buffers, for Burnout Dominator lens flares. See issue #11100 and comments to #16081. // Might make this more generic and upload the whole depth buffer if we find it's needed for something. - if (currentRenderVfb_->lastFrameNewSize == gpuStats.numFlips) { + if (newlyUsingDepth) { // Sanity check the depth buffer pointer. if (Memory::IsValidRange(currentRenderVfb_->z_address, currentRenderVfb_->width * 2)) { const u16 *src = (const u16 *)Memory::GetPointerUnchecked(currentRenderVfb_->z_address);