From 7c42928b57e7323904d56d51ea157d46db3de63c Mon Sep 17 00:00:00 2001 From: Alessandro Vetere Date: Sun, 11 Aug 2019 14:42:29 +0200 Subject: [PATCH] GSdx-hw TC: invalidate Source with Target TEX0 Fixes eyes blinking in Jak games with tex in rt search enabled. - Target TEX0 in Source is Source TEX0 if the Source is not build from Target, otherwise it is the Target TEX0, allowing improved Source invalidation --- plugins/GSdx/Renderers/HW/GSTextureCache.cpp | 10 +++++++++- plugins/GSdx/Renderers/HW/GSTextureCache.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/Renderers/HW/GSTextureCache.cpp b/plugins/GSdx/Renderers/HW/GSTextureCache.cpp index b8b1924442..95dcf2000a 100644 --- a/plugins/GSdx/Renderers/HW/GSTextureCache.cpp +++ b/plugins/GSdx/Renderers/HW/GSTextureCache.cpp @@ -154,6 +154,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0 src->m_shared_texture = true; src->m_target = true; // So renderer can check if a conversion is required src->m_from_target = dst->m_texture; // avoid complex condition on the renderer + src->m_from_target_TEX0 = dst->m_TEX0; src->m_32_bits_fmt = dst->m_32_bits_fmt; src->m_valid_rect = dst->m_valid; @@ -698,7 +699,8 @@ void GSTextureCache::InvalidateVideoMem(GSOffset* off, const GSVector4i& rect, b Source* s = *i; ++i; - if(GSUtil::HasSharedBits(bp, psm, s->m_TEX0.TBP0, s->m_TEX0.PSM)) + if (GSUtil::HasSharedBits(bp, psm, s->m_TEX0.TBP0, s->m_TEX0.PSM) || + GSUtil::HasSharedBits(bp, psm, s->m_from_target_TEX0.TBP0, s->m_TEX0.PSM)) { m_src.RemoveAt(s); } @@ -805,6 +807,8 @@ void GSTextureCache::InvalidateVideoMem(GSOffset* off, const GSVector4i& rect, b // render target used as input texture // TODO + b |= bp == s->m_from_target_TEX0.TBP0; + if(b) { m_src.RemoveAt(s); @@ -1156,6 +1160,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con src->m_texture = dTex; src->m_target = true; src->m_from_target = dst->m_texture; + src->m_from_target_TEX0 = dst->m_TEX0; src->m_texture->SetScale(scale); if (psm.pal > 0) { @@ -1182,6 +1187,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con src->m_texture = dTex; src->m_target = true; src->m_from_target = dst->m_texture; + src->m_from_target_TEX0 = dst->m_TEX0; // Even if we sample the framebuffer directly we might need the palette // to handle the format conversion on GPU @@ -1213,6 +1219,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con // Keep a trace of origin of the texture src->m_target = true; src->m_from_target = dst->m_texture; + src->m_from_target_TEX0 = dst->m_TEX0; src->m_valid_rect = dst->m_valid; dst->Update(); @@ -1547,6 +1554,7 @@ GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFR , m_complete(false) , m_p2t(NULL) , m_from_target(NULL) + , m_from_target_TEX0(TEX0) { m_TEX0 = TEX0; m_TEXA = TEXA; diff --git a/plugins/GSdx/Renderers/HW/GSTextureCache.h b/plugins/GSdx/Renderers/HW/GSTextureCache.h index b9250eed67..1700e6a99a 100644 --- a/plugins/GSdx/Renderers/HW/GSTextureCache.h +++ b/plugins/GSdx/Renderers/HW/GSTextureCache.h @@ -113,6 +113,7 @@ public: // still be valid on future. However it ought to be good when the source is created // so it can be used to access un-converted data for the current draw call. GSTexture* m_from_target; + GIFRegTEX0 m_from_target_TEX0; // TEX0 of the target texture, if any, else equal to texture TEX0 GIFRegTEX0 m_layer_TEX0[7]; // Detect already loaded value // Keep a GSTextureCache::SourceMap::m_map iterator to allow fast erase std::array m_erase_it;