[mutter] background-content: Mipmap background texture rendering



commit 32dbcd935255c9df46a56d12ede323a8f464cecd
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Wed Jul 1 16:43:50 2020 +0800

    background-content: 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
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1347

 src/compositor/meta-background-content.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/compositor/meta-background-content.c b/src/compositor/meta-background-content.c
index df0ab763e8..1d4188c2b3 100644
--- a/src/compositor/meta-background-content.c
+++ b/src/compositor/meta-background-content.c
@@ -309,7 +309,7 @@ setup_pipeline (MetaBackgroundContent *self,
   guint8 opacity;
   float color_component;
   CoglFramebuffer *fb;
-  CoglPipelineFilter filter;
+  CoglPipelineFilter min_filter, mag_filter;
 
   opacity = clutter_actor_get_paint_opacity (actor);
   if (opacity < 255)
@@ -408,11 +408,17 @@ setup_pipeline (MetaBackgroundContent *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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]