From 2f972b91a3ef36528fd69bf81c903342d78d9b54 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 11 Jan 2017 22:10:41 +0100 Subject: [PATCH] gsdx tc: allow a hit on older depth buffer Avoid an issue when rendering take some shortcut (Full Spectrum Warrior) Close #1757 --- plugins/GSdx/GSTextureCache.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 92e5ae33cb..102c3fec6b 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -99,11 +99,17 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0 uint32 psm = TEX0.PSM; for(auto t : m_dst[DepthStencil]) { - if(!t->m_age && t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM)) + if(t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM)) { ASSERT(GSLocalMemory::m_psm[t->m_TEX0.PSM].depth); - dst = t; - break; + if (t->m_age == 0) { + // Perfect Match + dst = t; + break; + } else if (t->m_age == 1) { + // Better than nothing (Full Spectrum Warrior) + dst = t; + } } } @@ -121,6 +127,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0 if (!dst) { // Retry on the render target (Silent Hill 4) for(auto t : m_dst[RenderTarget]) { + // FIXME: do I need to allow m_age == 1 as a potential match (as DepthStencil) ??? if(!t->m_age && t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM)) { ASSERT(GSLocalMemory::m_psm[t->m_TEX0.PSM].depth);