From ee82c7834db9163edf0c33cb9cc726abd4fffdd3 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 26 Jan 2022 23:18:15 +1000 Subject: [PATCH] GS: Auto-disable hash cache when it's too large --- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 444bf3f058..f4a4ac855f 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "GSRendererHW.h" #include "GS/GSGL.h" +#include "Host.h" GSRendererHW::GSRendererHW() : GSRenderer() @@ -313,6 +314,15 @@ void GSRendererHW::VSync(u32 field, bool registers_written) m_tc->IncAge(); + if (m_tc->GetHashCacheMemoryUsage() > 1024 * 1024 * 1024) + { + Host::AddKeyedFormattedOSDMessage("HashCacheOverflow", 15.0f, "Hash cache has used %.2f MB of VRAM, disabling.", + static_cast(m_tc->GetHashCacheMemoryUsage()) / 1048576.0f); + m_tc->RemoveAll(); + g_gs_device->PurgePool(); + GSConfig.TexturePreloading = TexturePreloadingLevel::Partial; + } + m_tc->PrintMemoryUsage(); g_gs_device->PrintMemoryUsage();