GS-TC: Only reset age when it's definitely an EE write

This commit is contained in:
refractionpcsx2 2022-11-22 19:32:20 +00:00
parent 90a4025bcc
commit e8ce1e3445
8 changed files with 26 additions and 22 deletions

View File

@ -1765,7 +1765,7 @@ void GSState::FlushWrite()
r.right = r.left + m_env.TRXREG.RRW;
r.bottom = r.top + m_env.TRXREG.RRH;
ExpandTarget(m_env.BITBLTBUF, r);
InvalidateVideoMem(m_env.BITBLTBUF, r);
InvalidateVideoMem(m_env.BITBLTBUF, r, true);
const GSLocalMemory::writeImage wi = GSLocalMemory::m_psm[m_env.BITBLTBUF.DPSM].wi;
@ -2027,7 +2027,7 @@ void GSState::Write(const u8* mem, int len)
r.right = r.left + m_env.TRXREG.RRW;
r.bottom = r.top + m_env.TRXREG.RRH;
ExpandTarget(m_env.BITBLTBUF, r);
InvalidateVideoMem(blit, r);
InvalidateVideoMem(blit, r, true);
(m_mem.*psm.wi)(m_tr.x, m_tr.y, mem, m_tr.total, blit, m_env.TRXPOS, m_env.TRXREG);
@ -2116,7 +2116,7 @@ void GSState::Move()
sx, sy, dx, dy, w, h);
InvalidateLocalMem(m_env.BITBLTBUF, GSVector4i(sx, sy, sx + w, sy + h));
InvalidateVideoMem(m_env.BITBLTBUF, GSVector4i(dx, dy, dx + w, dy + h));
InvalidateVideoMem(m_env.BITBLTBUF, GSVector4i(dx, dy, dx + w, dy + h), true);
int xinc = 1;
int yinc = 1;

View File

@ -371,7 +371,7 @@ public:
void FlushWrite();
virtual void Draw() = 0;
virtual void PurgePool() = 0;
virtual void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) {}
virtual void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool eewrite = false) {}
virtual void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false) {}
virtual void ExpandTarget(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) {}

View File

@ -858,11 +858,11 @@ void GSRendererHW::ExpandTarget(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector
m_tc->ExpandTarget(BITBLTBUF, r);
}
void GSRendererHW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
void GSRendererHW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool eewrite)
{
// printf("[%d] InvalidateVideoMem %d,%d - %d,%d %05x (%d)\n", (int)m_perfmon.GetFrame(), r.left, r.top, r.right, r.bottom, (int)BITBLTBUF.DBP, (int)BITBLTBUF.DPSM);
m_tc->InvalidateVideoMem(m_mem.GetOffset(BITBLTBUF.DBP, BITBLTBUF.DBW, BITBLTBUF.DPSM), r);
m_tc->InvalidateVideoMem(m_mem.GetOffset(BITBLTBUF.DBP, BITBLTBUF.DBW, BITBLTBUF.DPSM), r, eewrite);
}
void GSRendererHW::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut)
@ -1703,18 +1703,18 @@ void GSRendererHW::Draw()
&& m_r.x == 0 && m_r.y == 0) // Likely full buffer write
{
if (OI_GsMemClear() && m_r.w > 1024)
if (OI_GsMemClear() /*&& m_r.w > 1024*/)
{
if ((fm & fm_mask) != fm_mask)
{
m_tc->InvalidateVideoMem(context->offset.fb, m_r, true);
m_tc->InvalidateVideoMem(context->offset.fb, m_r, false, true);
m_tc->InvalidateVideoMemType(GSTextureCache::RenderTarget, context->FRAME.Block());
}
if (zm != 0xffffffff)
{
m_tc->InvalidateVideoMem(context->offset.zb, m_r, false);
m_tc->InvalidateVideoMem(context->offset.zb, m_r, false, false);
m_tc->InvalidateVideoMemType(GSTextureCache::DepthStencil, context->ZBUF.Block());
}
@ -1916,7 +1916,7 @@ void GSRendererHW::Draw()
//rt->m_valid = rt->m_valid.runion(r);
rt->UpdateValidity(m_r);
m_tc->InvalidateVideoMem(context->offset.fb, m_r, false);
m_tc->InvalidateVideoMem(context->offset.fb, m_r, false, false);
m_tc->InvalidateVideoMemType(GSTextureCache::DepthStencil, context->FRAME.Block());
}
@ -1926,7 +1926,7 @@ void GSRendererHW::Draw()
//ds->m_valid = ds->m_valid.runion(r);
ds->UpdateValidity(m_r);
m_tc->InvalidateVideoMem(context->offset.zb, m_r, false);
m_tc->InvalidateVideoMem(context->offset.zb, m_r, false, false);
m_tc->InvalidateVideoMemType(GSTextureCache::RenderTarget, context->ZBUF.Block());
}

View File

@ -199,7 +199,7 @@ public:
GSTexture* GetOutput(int i, int& y_offset) override;
GSTexture* GetFeedbackOutput() override;
void ExpandTarget(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) override;
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool eewrite = false) override;
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false) override;
void Move() override;
void Draw() override;

View File

@ -785,7 +785,7 @@ void GSTextureCache::InvalidateVideoMemType(int type, u32 bp)
// Goal: invalidate data sent to the GPU when the source (GS memory) is modified
// Called each time you want to write to the GS memory
void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& rect, bool target)
void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& rect, bool eewrite, bool target)
{
u32 bp = off.bp();
u32 bw = off.bw();
@ -950,7 +950,8 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
t->m_texture ? t->m_texture->GetID() : 0,
t->m_TEX0.TBP0, r.x, r.y, r.z, r.w);
t->m_TEX0.TBW = bw;
t->m_age = 0;
if(eewrite && t->m_age < 30)
t->m_age = 0;
t->m_dirty.push_back(GSDirtyRect(r, psm, bw));
}
else
@ -963,6 +964,8 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
const SurfaceOffset so = ComputeSurfaceOffset(off, r, t);
if (so.is_valid)
{
if (eewrite && t->m_age < 30)
t->m_age = 0;
// Offset from Target to Write in Target coords.
t->m_dirty.push_back(GSDirtyRect(so.b2a_offset, psm, bw));
GL_CACHE("TC: Dirty in the middle [aggressive] of Target(%s) %d [PSM:%s BP:0x%x->0x%x BW:%u rect(%d,%d=>%d,%d)] write[PSM:%s BP:0x%x BW:%u rect(%d,%d=>%d,%d)]",
@ -1035,7 +1038,8 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
t->m_TEX0.TBP0);
// TODO: do not add this rect above too
t->m_TEX0.TBW = bw;
t->m_age = 0;
if (eewrite && t->m_age < 30)
t->m_age = 0;
t->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top - y, r.right, r.bottom - y), psm, bw));
continue;
}
@ -1062,7 +1066,8 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
t->m_texture ? t->m_texture->GetID() : 0,
t->m_TEX0.TBP0, t->m_end_block,
r.left, r.top + y, r.right, r.bottom + y, bw);
t->m_age = 0;
if (eewrite && t->m_age < 30)
t->m_age = 0;
t->m_TEX0.TBW = bw;
t->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top + y, r.right, r.bottom + y), psm, bw));
continue;
@ -1073,8 +1078,7 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
const SurfaceOffset so = ComputeSurfaceOffset(off, r, t);
if (so.is_valid)
{
// Don't reset the age on old targets, possibly misdetection, it upsets Urban Reign.
if (t->m_age < 30)
if (eewrite && t->m_age < 30)
t->m_age = 0;
t->m_dirty.push_back(GSDirtyRect(so.b2a_offset, psm, bw));
@ -1335,7 +1339,7 @@ bool GSTextureCache::Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u
scaled_dx, scaled_dy);
// Invalidate any sources that overlap with the target (since they're now stale).
InvalidateVideoMem(g_gs_renderer->m_mem.GetOffset(DBP, DBW, DPSM), GSVector4i(dx, dy, dx + w, dy + h), false);
InvalidateVideoMem(g_gs_renderer->m_mem.GetOffset(DBP, DBW, DPSM), GSVector4i(dx, dy, dx + w, dy + h),false, false);
return true;
}

View File

@ -348,7 +348,7 @@ public:
void ExpandTarget(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
void InvalidateVideoMemType(int type, u32 bp);
void InvalidateVideoMemSubTarget(GSTextureCache::Target* rt);
void InvalidateVideoMem(const GSOffset& off, const GSVector4i& r, bool target = true);
void InvalidateVideoMem(const GSOffset& off, const GSVector4i& r, bool eewrite = false, bool target = true);
void InvalidateLocalMem(const GSOffset& off, const GSVector4i& r);
bool Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u32 DBW, u32 DPSM, int dx, int dy, int w, int h);
bool ShuffleMove(u32 BP, u32 BW, u32 PSM, int sx, int sy, int dx, int dy, int w, int h);

View File

@ -618,7 +618,7 @@ void GSRendererSW::Sync(int reason)
void GSRendererSW::ExpandTarget(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) {}
void GSRendererSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
void GSRendererSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool eewrite)
{
if (LOG)
{

View File

@ -76,7 +76,7 @@ protected:
void Queue(GSRingHeap::SharedPtr<GSRasterizerData>& item);
void Sync(int reason);
void ExpandTarget(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) override;
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool eewrite = false) override;
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false) override;
void UsePages(const GSOffset::PageLooper& pages, const int type);