GS/TextureCache: Don't count replacements in hash cache budget

Large replacement textures were causing the hash cache to disable
itself. There's plenty of other massive VRAM sinks in PCSX2 that we need
to consider before we can say we're managing VRAM well anyway.
This commit is contained in:
Connor McLaughlin 2022-02-27 16:31:10 +10:00 committed by refractionpcsx2
parent 866e5bd929
commit ba27a46ac6
2 changed files with 10 additions and 8 deletions

View File

@ -1550,9 +1550,8 @@ GSTextureCache::HashCacheEntry* GSTextureCache::LookupHashCache(const GIFRegTEX0
if (replacement_tex)
{
// found a replacement texture! insert it into the hash cache, and clear paltex (since it's not indexed)
const HashCacheEntry entry{replacement_tex, 1u, 0u};
m_hash_cache_memory_usage += replacement_tex->GetMemUsage();
paltex = false;
const HashCacheEntry entry{replacement_tex, 1u, 0u, true};
return &m_hash_cache.emplace(key, entry).first->second;
}
else if (replacement_texture_pending)
@ -1597,7 +1596,7 @@ GSTextureCache::HashCacheEntry* GSTextureCache::LookupHashCache(const GIFRegTEX0
key.RemoveCLUTHash();
// insert into the cache cache, and we're done
const HashCacheEntry entry{tex, 1u, 0u};
const HashCacheEntry entry{tex, 1u, 0u, false};
m_hash_cache_memory_usage += tex->GetMemUsage();
return &m_hash_cache.emplace(key, entry).first->second;
}
@ -2480,8 +2479,7 @@ void GSTextureCache::InjectHashCacheTexture(const HashCacheKey& key, GSTexture*
{
// We must've got evicted before we finished loading. No matter, add it in there anyway;
// if it's not used again, it'll get tossed out later.
const HashCacheEntry entry{ tex, 1u, 0u };
m_hash_cache_memory_usage += tex->GetMemUsage();
const HashCacheEntry entry{tex, 1u, 0u, true};
m_hash_cache.emplace(key, entry).first->second;
return;
}
@ -2490,8 +2488,11 @@ void GSTextureCache::InjectHashCacheTexture(const HashCacheKey& key, GSTexture*
it->second.age = 0;
// Update memory usage, swap the textures, and recycle the old one for reuse.
if (!it->second.is_replacement)
{
m_hash_cache_memory_usage -= it->second.texture->GetMemUsage();
m_hash_cache_memory_usage += tex->GetMemUsage();
it->second.is_replacement = true;
}
it->second.texture->Swap(tex);
g_gs_device->Recycle(tex);
}

View File

@ -70,7 +70,8 @@ public:
{
GSTexture* texture;
u32 refcount;
u32 age;
u16 age;
bool is_replacement;
};
class Surface : public GSAlignedClass<32>