From 7d331f1928573d747a059901142a5a0c0beecd57 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 17:33:14 -0700 Subject: [PATCH] GPU: Ignore depth when masked and ALWAYS. Seen in NFS Pro Street, for example. Shouldn't be interpreted as depth usage. --- GPU/GPUCommon.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 9830984739..c5271b2705 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1715,13 +1715,22 @@ void GPUCommon::Execute_VertexTypeSkinning(u32 op, u32 diff) { void GPUCommon::CheckDepthUsage(VirtualFramebuffer *vfb) { if (!gstate_c.usingDepth) { - bool isClearingDepth = gstate.isModeClear() && gstate.isClearModeDepthMask(); + bool isReadingDepth = false; + bool isClearingDepth = false; + bool isWritingDepth = false; + if (gstate.isModeClear()) { + isClearingDepth = gstate.isClearModeDepthMask(); + isWritingDepth = isClearingDepth; + } else if (gstate.isDepthTestEnabled()) { + isWritingDepth = gstate.isDepthWriteEnabled(); + isReadingDepth = gstate.getDepthTestFunction() > GE_COMP_ALWAYS; + } - if ((gstate.isDepthTestEnabled() || isClearingDepth)) { + if (isWritingDepth || isReadingDepth) { gstate_c.usingDepth = true; gstate_c.clearingDepth = isClearingDepth; vfb->last_frame_depth_render = gpuStats.numFlips; - if (isClearingDepth || gstate.isDepthWriteEnabled()) { + if (isWritingDepth) { vfb->last_frame_depth_updated = gpuStats.numFlips; } framebufferManager_->SetDepthFrameBuffer(isClearingDepth);