Blame SOURCES/0012-renderer-native-Separate-offscreen-and-shadowfb.patch

657d8e
From ca3e9e3b3b84fe95affbe5485212c6ecfa1a4b51 Mon Sep 17 00:00:00 2001
657d8e
From: Olivier Fourdan <ofourdan@redhat.com>
657d8e
Date: Tue, 22 Oct 2019 17:05:46 +0200
657d8e
Subject: [PATCH 12/12] renderer-native: Separate offscreen and shadowfb
657d8e
657d8e
Create the intermediate shadow framebuffer for use exclusively when a
657d8e
shadowfb is required.
657d8e
657d8e
Keep the previous offscreen framebuffer is as an intermediate
657d8e
framebuffer for transformations only.
657d8e
657d8e
This way, we can apply transformations between in-memory framebuffers
657d8e
prior to blit the result to screen, and achieve acceptable performance
657d8e
even with software rendering on discrete GPU.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/917
657d8e
657d8e
(cherry picked from commit 551641c74822ca2e3c685e49603836ebf5397df2)
657d8e
---
657d8e
 src/backends/native/meta-renderer-native.c | 29 ++++++++++++++++++----
657d8e
 1 file changed, 24 insertions(+), 5 deletions(-)
657d8e
657d8e
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
657d8e
index 3cd01bcb7..ffb64a6bd 100644
657d8e
--- a/src/backends/native/meta-renderer-native.c
657d8e
+++ b/src/backends/native/meta-renderer-native.c
657d8e
@@ -3287,7 +3287,6 @@ meta_renderer_native_create_onscreen (MetaRendererNative   *renderer_native,
657d8e
 static CoglOffscreen *
657d8e
 meta_renderer_native_create_offscreen (MetaRendererNative    *renderer,
657d8e
                                        CoglContext           *context,
657d8e
-                                       MetaMonitorTransform   transform,
657d8e
                                        gint                   view_width,
657d8e
                                        gint                   view_height,
657d8e
                                        GError               **error)
657d8e
@@ -3489,6 +3488,7 @@ meta_renderer_native_create_view (MetaRenderer       *renderer,
657d8e
   MetaMonitorTransform view_transform;
657d8e
   CoglOnscreen *onscreen = NULL;
657d8e
   CoglOffscreen *offscreen = NULL;
657d8e
+  CoglOffscreen *shadowfb = NULL;
657d8e
   float scale;
657d8e
   int width, height;
657d8e
   MetaRendererView *view;
657d8e
@@ -3515,18 +3515,35 @@ meta_renderer_native_create_view (MetaRenderer       *renderer,
657d8e
   if (!onscreen)
657d8e
     g_error ("Failed to allocate onscreen framebuffer: %s", error->message);
657d8e
 
657d8e
-  if (view_transform != META_MONITOR_TRANSFORM_NORMAL ||
657d8e
-      should_force_shadow_fb (renderer_native,
657d8e
-                              renderer_native->primary_gpu_kms))
657d8e
+ if (view_transform != META_MONITOR_TRANSFORM_NORMAL)
657d8e
     {
657d8e
       offscreen = meta_renderer_native_create_offscreen (renderer_native,
657d8e
                                                          cogl_context,
657d8e
-                                                         view_transform,
657d8e
                                                          width,
657d8e
                                                          height,
657d8e
                                                          &error);
657d8e
       if (!offscreen)
657d8e
         g_error ("Failed to allocate back buffer texture: %s", error->message);
657d8e
+
657d8e
+    }
657d8e
+
657d8e
+  if (should_force_shadow_fb (renderer_native,
657d8e
+                              renderer_native->primary_gpu_kms))
657d8e
+    {
657d8e
+      int shadow_width;
657d8e
+      int shadow_height;
657d8e
+
657d8e
+      /* The shadowfb must be the same size as the on-screen framebuffer */
657d8e
+      shadow_width = cogl_framebuffer_get_width (COGL_FRAMEBUFFER (onscreen));
657d8e
+      shadow_height = cogl_framebuffer_get_height (COGL_FRAMEBUFFER (onscreen));
657d8e
+
657d8e
+      shadowfb = meta_renderer_native_create_offscreen (renderer_native,
657d8e
+                                                        cogl_context,
657d8e
+                                                        shadow_width,
657d8e
+                                                        shadow_height,
657d8e
+                                                        &error);
657d8e
+      if (!shadowfb)
657d8e
+        g_error ("Failed to allocate shadow buffer texture: %s", error->message);
657d8e
     }
657d8e
 
657d8e
   view = g_object_new (META_TYPE_RENDERER_VIEW,
657d8e
@@ -3534,10 +3551,12 @@ meta_renderer_native_create_view (MetaRenderer       *renderer,
657d8e
                        "scale", scale,
657d8e
                        "framebuffer", onscreen,
657d8e
                        "offscreen", offscreen,
657d8e
+                       "shadowfb", shadowfb,
657d8e
                        "logical-monitor", logical_monitor,
657d8e
                        "transform", view_transform,
657d8e
                        NULL);
657d8e
   g_clear_pointer (&offscreen, cogl_object_unref);
657d8e
+  g_clear_pointer (&shadowfb, cogl_object_unref);
657d8e
 
657d8e
   meta_onscreen_native_set_view (onscreen, view);
657d8e
 
657d8e
-- 
657d8e
2.21.0
657d8e