From 7f8488771dbe89092e742fb4acad219f84129ee2 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Wed, 25 Jun 2025 03:42:12 +0100 Subject: [PATCH] GS/TC: Improve heuristics for sequenced draws inside targets --- pcsx2/GS/Renderers/HW/GSTextureCache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index 377f24e33e..1a70928b1d 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -2389,10 +2389,11 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(GIFRegTEX0 TEX0, const GSVe const bool ds_offset = !ds || offset != 0; const bool is_double_buffer = TEX0.TBP0 == ((((t->m_end_block + 1) - t->m_TEX0.TBP0) / 2) + t->m_TEX0.TBP0); const bool source_match = src && src->m_TEX0.TBP0 == bp && src->m_TEX0.TBW == TEX0.TBW && src->m_from_target && src->m_from_target == t; + const bool was_used_last_draw = t->m_last_draw == (GSState::s_n - 1); // if it's a shuffle, some games tend to offset back by a page, such as Tomb Raider, for no disernable reason, but it then causes problems. // This can also happen horizontally (Catwoman moves everything one page left with shuffles), but this is too messy to deal with right now. const bool overlaps = t->Overlaps(bp, TEX0.TBW, TEX0.PSM, min_rect) || (is_shuffle && src && GSLocalMemory::m_psm[src->m_TEX0.PSM].bpp == 8 && t->Overlaps(bp, TEX0.TBW, TEX0.PSM, min_rect + GSVector4i(0, 0, 0, 32))); - if (source_match || (no_target_or_newer && is_aligned_ok && width_match && overlaps && (is_shuffle || ds_offset || is_double_buffer))) + if (source_match || (no_target_or_newer && is_aligned_ok && width_match && overlaps && (is_shuffle || ds_offset || is_double_buffer || was_used_last_draw))) { const GSLocalMemory::psm_t& s_psm = GSLocalMemory::m_psm[TEX0.PSM];