Restore the clearing optimization, avoiding unnecessary depth copies

This commit is contained in:
Henrik Rydgård 2022-08-20 09:46:15 +02:00
parent 12db0e52d4
commit 29ea3ffe0c
3 changed files with 8 additions and 5 deletions

View File

@ -497,13 +497,16 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame
}
// Called on the first use of depth in a render pass.
void FramebufferManagerCommon::SetDepthFrameBuffer() {
void FramebufferManagerCommon::SetDepthFrameBuffer(bool isClearingDepth) {
if (!currentRenderVfb_) {
return;
}
// "Resolve" the depth buffer, by copying from any overlapping buffers with fresher content.
CopyToDepthFromOverlappingFramebuffers(currentRenderVfb_);
// If this first draw call is anything other than a clear, "resolve" the depth buffer,
// by copying from any overlapping buffers with fresher content.
if (!isClearingDepth) {
CopyToDepthFromOverlappingFramebuffers(currentRenderVfb_);
}
currentRenderVfb_->usageFlags |= FB_USAGE_RENDER_DEPTH;
currentRenderVfb_->depthBindSeq = GetBindSeqCount();

View File

@ -267,7 +267,7 @@ public:
return vfb;
}
}
void SetDepthFrameBuffer();
void SetDepthFrameBuffer(bool isClearingDepth);
void RebindFramebuffer(const char *tag);
std::vector<FramebufferInfo> GetFramebufferList() const;

View File

@ -1635,7 +1635,7 @@ void GPUCommon::CheckDepthUsage(VirtualFramebuffer *vfb) {
if (isClearingDepth || gstate.isDepthWriteEnabled()) {
vfb->last_frame_depth_updated = gpuStats.numFlips;
}
framebufferManager_->SetDepthFrameBuffer();
framebufferManager_->SetDepthFrameBuffer(isClearingDepth);
}
}
}