From 3dab5120eddaf69f3450c9f190b8dbd847ed6da8 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Mon, 3 Aug 2020 14:29:46 +0800 Subject: [PATCH] background-actor: Mipmap background texture rendering gnome-shell displays workspace previews at one tenth scale. That's a few binary orders of magnitude so even using a LINEAR filter was resulting in visible jaggies. Now we apply mipmapping so they appear smooth. As an added bonus, the mipmaps used occupy roughly 1% the memory of the original image (0.1 x 0.1 = 0.01) so they actually fit into GPU/CPU caches now and rendering performance is improved. There's no need to traverse the original texture which at 4K resolution occupies 33MB, only a 331KB mipmap. In my case this reduces the render time for the overview by ~10%. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1416 Origin: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1347 (cherry picked from commit 32dbcd935255c9df46a56d12ede323a8f464cecd) --- src/compositor/meta-background-actor.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compositor/meta-background-actor.c b/src/compositor/meta-background-actor.c index 361fbeeb1..628fb3ff3 100644 --- a/src/compositor/meta-background-actor.c +++ b/src/compositor/meta-background-actor.c @@ -354,7 +354,7 @@ setup_pipeline (MetaBackgroundActor *self, guint8 opacity; float color_component; CoglFramebuffer *fb; - CoglPipelineFilter filter; + CoglPipelineFilter min_filter, mag_filter; opacity = clutter_actor_get_paint_opacity (CLUTTER_ACTOR (self)); if (opacity < 255) @@ -455,11 +455,17 @@ setup_pipeline (MetaBackgroundActor *self, actor_pixel_rect->width, actor_pixel_rect->height, NULL, NULL)) - filter = COGL_PIPELINE_FILTER_NEAREST; + { + min_filter = COGL_PIPELINE_FILTER_NEAREST; + mag_filter = COGL_PIPELINE_FILTER_NEAREST; + } else - filter = COGL_PIPELINE_FILTER_LINEAR; + { + min_filter = COGL_PIPELINE_FILTER_LINEAR_MIPMAP_NEAREST; + mag_filter = COGL_PIPELINE_FILTER_LINEAR; + } - cogl_pipeline_set_layer_filters (self->pipeline, 0, filter, filter); + cogl_pipeline_set_layer_filters (self->pipeline, 0, min_filter, mag_filter); } static void