From 9b8dc448f6ad2872f5cdb28ee2ca54363f6770ee Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Wed, 30 Aug 2023 21:10:11 +0100 Subject: [PATCH] GS/TC: Only look up alternate depth sources if inside the target --- pcsx2/GS/Renderers/HW/GSTextureCache.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index 2dd6532097..e2da86d9fd 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -1493,13 +1493,19 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con if (!found_t && !dst && !GSConfig.UserHacks_DisableDepthSupport) { + GSVector4i new_rect = r; + + // Just in case the TextureMinMax trolls us as it does, when checking if inside the target. + new_rect.z -= 2; + new_rect.w -= 2; + // Let's try a trick to avoid to use wrongly a depth buffer // Unfortunately, I don't have any Arc the Lad testcase // // 1/ Check only current frame, I guess it is only used as a postprocessing effect for (auto t : m_dst[DepthStencil]) { - if (t->m_age <= 1 && t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM)) + if (t->m_age <= 1 && t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM) && t->Inside(bp, bw, psm, new_rect)) { GL_INS("TC: Warning depth format read as color format. Pixels will be scrambled"); // Let's fetch a depth format texture. Rational, it will avoid the texture allocation and the