diff --git a/pcsx2/GS/GSClut.cpp b/pcsx2/GS/GSClut.cpp index a123346cd1dce..9b85500086f6c 100644 --- a/pcsx2/GS/GSClut.cpp +++ b/pcsx2/GS/GSClut.cpp @@ -168,10 +168,8 @@ bool GSClut::InvalidateRange(u32 start_block, u32 end_block, bool is_draw) return m_write.dirty; } -bool GSClut::WriteTest(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT) +bool GSClut::CanLoadCLUT(const GIFRegTEX0& TEX0, const bool update_CBP) { - // Check if PSM is an indexed format BEFORE the load condition, updating CBP0/1 on an invalid format is not allowed - // and can break games. Corvette (NTSC) is a good example of this. if ((TEX0.PSM & 0x7) < 3) return false; @@ -182,20 +180,24 @@ bool GSClut::WriteTest(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT) case 1: break; case 2: - m_CBP[0] = TEX0.CBP; + if (update_CBP) + m_CBP[0] = TEX0.CBP; break; case 3: - m_CBP[1] = TEX0.CBP; + if (update_CBP) + m_CBP[1] = TEX0.CBP; break; case 4: if (m_CBP[0] == TEX0.CBP) return false; - m_CBP[0] = TEX0.CBP; + if(update_CBP) + m_CBP[0] = TEX0.CBP; break; case 5: if (m_CBP[1] == TEX0.CBP) return false; - m_CBP[1] = TEX0.CBP; + if (update_CBP) + m_CBP[1] = TEX0.CBP; break; case 6: return false; // ffx2 menu. @@ -205,6 +207,19 @@ bool GSClut::WriteTest(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT) __assume(0); } + return true; +} + +bool GSClut::WriteTest(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT) +{ + // Check if PSM is an indexed format BEFORE the load condition, updating CBP0/1 on an invalid format is not allowed + // and can break games. Corvette (NTSC) is a good example of this. + if ((TEX0.PSM & 0x7) < 3) + return false; + + if (!CanLoadCLUT(TEX0, true)) + return false; + // CLUT only reloads if PSM is a valid index type, avoid unnecessary flushes. return m_write.IsDirty(TEX0, TEXCLUT); } diff --git a/pcsx2/GS/GSClut.h b/pcsx2/GS/GSClut.h index f616ee86d20e4..c42d663477928 100644 --- a/pcsx2/GS/GSClut.h +++ b/pcsx2/GS/GSClut.h @@ -114,6 +114,7 @@ class alignas(32) GSClut final : public GSAlignedClass<32> u32 GetCLUTCBP(); u32 GetCLUTCPSM(); void SetNextCLUTTEX0(u64 CBP); + bool CanLoadCLUT(const GIFRegTEX0& TEX0, const bool update_CBP = false); bool WriteTest(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT); void Write(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT); //void Read(const GIFRegTEX0& TEX0); diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index a64d67062bc8b..9b6c7c2d5337c 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -830,7 +830,7 @@ void GSState::ApplyTEX0(GIFRegTEX0& TEX0) GL_REG("Apply TEX0_%d = 0x%x_%x", i, TEX0.U32[1], TEX0.U32[0]); - if ((TEX0.PSM & 0x7) >= 3 && TEX0.CLD) + if ((TEX0.PSM & 0x7) >= 3 && m_mem.m_clut.CanLoadCLUT(TEX0)) { m_mem.m_clut.ClearDrawInvalidity(); m_mem.m_clut.SetNextCLUTTEX0(TEX0.U64);