From 0d6981bd549a9a6b943a64af9fe5a2801f0a871b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 3 Jul 2024 03:56:47 +0200 Subject: [PATCH] gpu: Make the cache track if it's empty Only if a non-stale item is in the cache do we consider the cache not empty. Once the cache is empty, the device frees it and stops running the periodic GC. --- gsk/gpu/gskgpucache.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gsk/gpu/gskgpucache.c b/gsk/gpu/gskgpucache.c index 43bb056d51..4000fabd51 100644 --- a/gsk/gpu/gskgpucache.c +++ b/gsk/gpu/gskgpucache.c @@ -490,6 +490,7 @@ gsk_gpu_cache_gc (GskGpuCache *self, { GskGpuCached *cached, *prev; gint64 before G_GNUC_UNUSED = GDK_PROFILER_CURRENT_TIME; + gboolean is_empty = TRUE; /* We walk the cache from the end so we don't end up with prev * being a leftover glyph on the atlas we are freeing @@ -499,6 +500,8 @@ gsk_gpu_cache_gc (GskGpuCache *self, prev = cached->prev; if (gsk_gpu_cached_should_collect (self, cached, cache_timeout, timestamp)) gsk_gpu_cached_free (self, cached); + else + is_empty &= cached->stale; } g_atomic_pointer_set (&self->dead_texture_pixels, 0); @@ -508,7 +511,7 @@ gsk_gpu_cache_gc (GskGpuCache *self, gdk_profiler_end_mark (before, "Glyph cache GC", NULL); - return self->last_cached == NULL; + return is_empty; } gsize