Perform garbage collection for efb copies

This checks every TEXTURE_KILL_THRESHOLD frames, to see if the hash for the memory area of the efb copy has hanged. If it has changed, the efb copy can be removed, it wouldn't be used anymore. Before this pr, some efb copies would never be deleted.

Fixes issue https://bugs.dolphin-emu.org/issues/6101 and possibly some other VRAM leaks.
This commit is contained in:
mimimi085181 2015-09-07 20:53:38 +02:00
parent 921bab6b4d
commit 38f6cf2089

View File

@ -150,10 +150,16 @@ void TextureCache::Cleanup(int _frameCount)
if (iter->second->frameCount == FRAMECOUNT_INVALID)
{
iter->second->frameCount = _frameCount;
++iter;
}
if (_frameCount > TEXTURE_KILL_THRESHOLD + iter->second->frameCount &&
// EFB copies living on the host GPU are unrecoverable and thus shouldn't be deleted
!iter->second->IsEfbCopy())
else if (_frameCount > TEXTURE_KILL_THRESHOLD + iter->second->frameCount)
{
if (iter->second->IsEfbCopy())
{
// Only remove EFB copies when they wouldn't be used anymore(changed hash), because EFB copies living on the
// host GPU are unrecoverable. Perform this check only every TEXTURE_KILL_THRESHOLD for performance reasons
if ((_frameCount - iter->second->frameCount) % TEXTURE_KILL_THRESHOLD == 1 &&
iter->second->hash != GetHash64(Memory::GetPointer(iter->second->addr), iter->second->size_in_bytes, g_ActiveConfig.iSafeTextureCache_ColorSamples))
{
iter = FreeTexture(iter);
}
@ -162,6 +168,16 @@ void TextureCache::Cleanup(int _frameCount)
++iter;
}
}
else
{
iter = FreeTexture(iter);
}
}
else
{
++iter;
}
}
TexPool::iterator iter2 = texture_pool.begin();
TexPool::iterator tcend2 = texture_pool.end();