GS: CLUT - check the whole page range of transfer for CLUT clear.

This commit is contained in:
refractionpcsx2 2022-07-11 12:19:32 +01:00
parent 0eb963d491
commit 446b0c2dfa
3 changed files with 22 additions and 4 deletions

View File

@ -108,8 +108,15 @@ void GSClut::Invalidate()
m_write.dirty = true;
}
// This checks the whole page! Some games (like We Love Katamari) have the CLUT 1 block ahead of the DBP during a transfer.
// Safer to check if the whole page is being written anyway since it could modify only part of the CLUT.
void GSClut::InvalidateRange(u32 start_block, u32 end_block)
{
if (m_write.TEX0.CBP >= start_block && m_write.TEX0.CBP <= end_block)
{
m_write.dirty = true;
}
}
// Check the whole page, if the CLUT is slightly offset from a page boundary it could miss it.
void GSClut::Invalidate(u32 block)
{
if (!((block ^ m_write.TEX0.CBP) & ~0x1F))

View File

@ -102,6 +102,7 @@ public:
void Invalidate();
void Invalidate(u32 block);
void InvalidateRange(u32 start_block, u32 end_block);
bool WriteTest(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
void Write(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
//void Read(const GIFRegTEX0& TEX0);

View File

@ -1957,7 +1957,12 @@ void GSState::Write(const u8* mem, int len)
FlushWrite();
}
m_mem.m_clut.Invalidate(blit.DBP);
int page_width = std::max(1, (w / psm.pgs.x));
int page_height = std::max(1, (h / psm.pgs.y));
int pitch = (std::max(1U, blit.DBW) * 64) / psm.pgs.x;
// Try to avoid flushing draws if it doesn't cross paths
m_mem.m_clut.InvalidateRange(blit.DBP, blit.DBP + ((page_width << 5) + ((page_height * pitch) << 5)));
}
void GSState::InitReadFIFO(u8* mem, int len)
@ -2202,7 +2207,12 @@ void GSState::Move()
});
}
m_mem.m_clut.Invalidate(m_env.BITBLTBUF.DBP);
int page_width = std::max(1, (w / dpsm.pgs.x));
int page_height = std::max(1, (h / dpsm.pgs.y));
int pitch = (std::max(1, dbw) * 64) / dpsm.pgs.x;
// Try to avoid flushing draws if it doesn't cross paths
m_mem.m_clut.InvalidateRange(dbp, dbp + ((page_width << 5) + ((page_height * pitch) << 5)));
}
void GSState::SoftReset(u32 mask)