Skip to content

Commit 4d37e35

Browse files
refractionpcsx2lightningterror
authored andcommitted
GS/TC: Delete dirty rt's in src lookup + usert in rt on 3 draw old rt's
1 parent df3868a commit 4d37e35

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

pcsx2/GS/Renderers/HW/GSTextureCache.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,16 +1408,31 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const bool is_color, const
14081408

14091409
if (rect_clean)
14101410
{
1411+
bool can_use = true;
14111412
for (auto& dirty : t->m_dirty)
14121413
{
14131414
const GSVector4i dirty_rect = dirty.GetDirtyRect(t->m_TEX0, t->m_TEX0.PSM != dirty.psm);
14141415
if (!dirty_rect.rintersect(new_rect).rempty())
14151416
{
14161417
rect_clean = false;
1417-
partial |= !new_rect.rintersect(dirty_rect).eq(new_rect) || dirty_rect.eq(new_rect);
1418+
1419+
if(!dirty_rect.rintersect(t->m_valid).eq(t->m_valid) || GSUtil::GetChannelMask(t->m_TEX0.PSM) != t->m_dirty.GetDirtyChannels())
1420+
partial |= !new_rect.rintersect(dirty_rect).eq(new_rect) || dirty_rect.eq(new_rect);
1421+
else // Nothing is valid anymore, kill it.
1422+
{
1423+
can_use = false;
1424+
}
14181425
break;
14191426
}
14201427
}
1428+
1429+
if (!can_use)
1430+
{
1431+
InvalidateSourcesFromTarget(t);
1432+
i = list.erase(i);
1433+
delete t;
1434+
continue;
1435+
}
14211436
}
14221437

14231438
const u32 channel_mask = GSUtil::GetChannelMask(psm);
@@ -2340,11 +2355,11 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(GIFRegTEX0 TEX0, const GSVe
23402355
lookup_rect = lookup_rect & GSVector4i(~8);
23412356

23422357
const GSVector4i translated_rect = GSVector4i(0, 0, 0, 0).max_i32(TranslateAlignedRectByPage(t, TEX0.TBP0, TEX0.PSM, TEX0.TBW, lookup_rect));
2343-
const GSVector4i dirty_rect = t->m_dirty.empty() ? GSVector4i::zero() : t->m_dirty.GetTotalRect(t->m_TEX0, t->m_unscaled_size).rintersect(t->m_valid);
2358+
const GSVector4i dirty_rect = t->m_dirty.empty() ? GSVector4i::zero() : t->m_dirty.GetTotalRect(t->m_TEX0, t->m_unscaled_size);
23442359
const bool all_dirty = dirty_rect.eq(t->m_valid);
23452360

23462361

2347-
if (!is_shuffle && !t->m_dirty.empty() && (!preserve_alpha && !preserve_rgb) && (GSState::s_n - 1) != t->m_last_draw)
2362+
if (!is_shuffle && !dirty_rect.rempty() && (!preserve_alpha && !preserve_rgb) && (GSState::s_n - 3) > t->m_last_draw)
23482363
{
23492364
GL_INS("TC: Deleting RT BP 0x%x BW %d PSM %s due to dirty areas not preserved (Likely change in target)", t->m_TEX0.TBP0, t->m_TEX0.TBW, psm_str(t->m_TEX0.PSM));
23502365
InvalidateSourcesFromTarget(t);
@@ -2354,7 +2369,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(GIFRegTEX0 TEX0, const GSVe
23542369
continue;
23552370
}
23562371

2357-
if (!all_dirty && ((translated_rect.w <= t->m_valid.w) || widthpage_offset == 0 || (GSState::s_n - 1) == t->m_last_draw))
2372+
if (!all_dirty && ((translated_rect.w <= t->m_valid.w) || widthpage_offset == 0 || (GSState::s_n - 3) <= t->m_last_draw))
23582373
{
23592374
if (TEX0.TBW == t->m_TEX0.TBW && !is_shuffle && widthpage_offset == 0 && ((min_rect.w + 63) / 64) > 1)
23602375
{

0 commit comments

Comments
 (0)