From 935e88a5805dfbeefb599da72d2ff8c41664073e Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Tue, 2 Feb 2021 20:43:41 -0600 Subject: [PATCH] gl_rasterizer_cache: Remove all fully invalid surfaces from the cache Some games (e.g. Pilotwings Resort) create many surfaces that are invalidated quickly but were never removed. This occasionally lead to large lag spikes due to high lookup times and other data structure management overhead. --- src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 88310a0acd..c85496d296 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -1858,9 +1858,9 @@ void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u32 size, const Surface cached_surface->invalid_regions.insert(interval); cached_surface->InvalidateAllWatcher(); - // Remove only "empty" fill surfaces to avoid destroying and recreating OGL textures - if (cached_surface->type == SurfaceType::Fill && - cached_surface->IsSurfaceFullyInvalid()) { + // If the surface has no salvageable data it should be removed from the cache to avoid + // clogging the data structure + if (cached_surface->IsSurfaceFullyInvalid()) { remove_surfaces.emplace(cached_surface); } }