From 156484ac80d3930c1db6874db498893d1a3662f3 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sun, 10 Jul 2022 06:24:49 +0100 Subject: [PATCH] GS: Invalidate CLUT by page Some games (We Love Katamari) write offset inside the CLUT, and one block is only 32 colours (in 32bit) anyway, so by block is insufficient. Also add check for CLUT invalidation from Z writes, because it *could* happen, weirder things have been done in games. --- pcsx2/GS/GSClut.cpp | 4 +++- pcsx2/GS/GSState.cpp | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pcsx2/GS/GSClut.cpp b/pcsx2/GS/GSClut.cpp index 981e564f5a..10d2f6ff4c 100644 --- a/pcsx2/GS/GSClut.cpp +++ b/pcsx2/GS/GSClut.cpp @@ -108,9 +108,11 @@ 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::Invalidate(u32 block) { - if (block == m_write.TEX0.CBP) + if (!((block ^ m_write.TEX0.CBP) & ~0x1F)) { m_write.dirty = true; } diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index 7b1b90a9ca..d301a233f8 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -710,8 +710,12 @@ __inline void GSState::CheckFlushes() Flush(); } } - if (m_index.tail > 0 && (m_context->FRAME.FBMSK & GSLocalMemory::m_psm[m_context->FRAME.PSM].fmsk) != GSLocalMemory::m_psm[m_context->FRAME.PSM].fmsk) + if ((m_context->FRAME.FBMSK & GSLocalMemory::m_psm[m_context->FRAME.PSM].fmsk) != GSLocalMemory::m_psm[m_context->FRAME.PSM].fmsk) m_mem.m_clut.Invalidate(m_context->FRAME.Block()); + + // Hey, why not check? I mean devs have done crazier things.. + if(!m_context->ZBUF.ZMSK) + m_mem.m_clut.Invalidate(m_context->ZBUF.Block()); } void GSState::GIFPackedRegHandlerNull(const GIFPackedReg* RESTRICT r)