GS: Auto-disable hash cache when it's too large

This commit is contained in:
Connor McLaughlin 2022-01-26 23:18:15 +10:00 committed by lightningterror
parent b389c6e103
commit ee82c7834d
1 changed files with 10 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSRendererHW.h" #include "GSRendererHW.h"
#include "GS/GSGL.h" #include "GS/GSGL.h"
#include "Host.h"
GSRendererHW::GSRendererHW() GSRendererHW::GSRendererHW()
: GSRenderer() : GSRenderer()
@ -313,6 +314,15 @@ void GSRendererHW::VSync(u32 field, bool registers_written)
m_tc->IncAge(); 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<float>(m_tc->GetHashCacheMemoryUsage()) / 1048576.0f);
m_tc->RemoveAll();
g_gs_device->PurgePool();
GSConfig.TexturePreloading = TexturePreloadingLevel::Partial;
}
m_tc->PrintMemoryUsage(); m_tc->PrintMemoryUsage();
g_gs_device->PrintMemoryUsage(); g_gs_device->PrintMemoryUsage();