Blame SOURCES/more-performance-backports.patch

8156c2
From f86e33e1ea32c4208809e8de33bed05ddbce9a4c Mon Sep 17 00:00:00 2001
8156c2
From: Carlos Garnacho <carlosg@gnome.org>
8156c2
Date: Sun, 7 May 2017 03:00:10 +0200
8156c2
Subject: [PATCH 1/3] compositor: Avoid changing pipeline/source if shadow is
8156c2
 not being painted
8156c2
8156c2
Avoids some context invalidations in cogl.
8156c2
8156c2
https://bugzilla.gnome.org/show_bug.cgi?id=782344
8156c2
---
8156c2
 src/compositor/meta-shadow-factory.c | 15 ++++++++++++---
8156c2
 1 file changed, 12 insertions(+), 3 deletions(-)
8156c2
8156c2
diff --git a/src/compositor/meta-shadow-factory.c b/src/compositor/meta-shadow-factory.c
8156c2
index cd006008b..19147ca9f 100644
8156c2
--- a/src/compositor/meta-shadow-factory.c
8156c2
+++ b/src/compositor/meta-shadow-factory.c
8156c2
@@ -220,9 +220,7 @@ meta_shadow_paint (MetaShadow     *shadow,
8156c2
   int dest_x[4];
8156c2
   int dest_y[4];
8156c2
   int n_x, n_y;
8156c2
-
8156c2
-  cogl_pipeline_set_color4ub (shadow->pipeline,
8156c2
-                              opacity, opacity, opacity, opacity);
8156c2
+  gboolean source_updated = FALSE;
8156c2
 
8156c2
   cogl_set_source (shadow->pipeline);
8156c2
 
8156c2
@@ -300,6 +298,17 @@ meta_shadow_paint (MetaShadow     *shadow,
8156c2
           else
8156c2
             overlap = CAIRO_REGION_OVERLAP_IN;
8156c2
 
8156c2
+          if (overlap == CAIRO_REGION_OVERLAP_OUT)
8156c2
+            continue;
8156c2
+
8156c2
+          if (!source_updated)
8156c2
+            {
8156c2
+              cogl_pipeline_set_color4ub (shadow->pipeline,
8156c2
+                                          opacity, opacity, opacity, opacity);
8156c2
+              cogl_set_source (shadow->pipeline);
8156c2
+              source_updated = TRUE;
8156c2
+            }
8156c2
+
8156c2
           /* There's quite a bit of overhead from allocating a new
8156c2
            * region in order to find an exact intersection and
8156c2
            * generating more geometry - we make the assumption that
8156c2
-- 
8156c2
2.23.0
8156c2
8156c2
8156c2
From f530bc4c3391cabe2b084cd59def00d81c13286c Mon Sep 17 00:00:00 2001
8156c2
From: Carlos Garnacho <carlosg@gnome.org>
8156c2
Date: Fri, 5 May 2017 14:15:30 +0200
8156c2
Subject: [PATCH 2/3] clutter: Avoid rounding compensation when invalidating 2D
8156c2
 actors
8156c2
8156c2
This allows the redraw clip to be more constrained, so MetaCullable doesn't
8156c2
end up rendering portions of window shadows, frame and background when a
8156c2
window invalidates (part of) its contents.
8156c2
8156c2
https://bugzilla.gnome.org/show_bug.cgi?id=782344
8156c2
---
8156c2
 clutter/clutter/clutter-paint-volume.c | 15 +++++++++++++++
8156c2
 1 file changed, 15 insertions(+)
8156c2
8156c2
diff --git a/clutter/clutter/clutter-paint-volume.c b/clutter/clutter/clutter-paint-volume.c
8156c2
index b48f7f9d6..f3405138b 100644
8156c2
--- a/clutter/clutter/clutter-paint-volume.c
8156c2
+++ b/clutter/clutter/clutter-paint-volume.c
8156c2
@@ -1166,6 +1166,21 @@ _clutter_paint_volume_get_stage_paint_box (ClutterPaintVolume *pv,
8156c2
 
8156c2
   _clutter_paint_volume_get_bounding_box (&projected_pv, box);
8156c2
 
8156c2
+  if (pv->is_2d && pv->actor &&
8156c2
+      clutter_actor_get_z_position (pv->actor) == 0)
8156c2
+    {
8156c2
+      /* If the volume/actor are perfectly 2D, take the bounding box as
8156c2
+       * good. We won't need to add any extra room for sub-pixel positioning
8156c2
+       * in this case.
8156c2
+       */
8156c2
+      clutter_paint_volume_free (&projected_pv);
8156c2
+      box->x1 = CLUTTER_NEARBYINT (box->x1);
8156c2
+      box->y1 = CLUTTER_NEARBYINT (box->y1);
8156c2
+      box->x2 = CLUTTER_NEARBYINT (box->x2);
8156c2
+      box->y2 = CLUTTER_NEARBYINT (box->y2);
8156c2
+      return;
8156c2
+    }
8156c2
+
8156c2
   /* The aim here is that for a given rectangle defined with floating point
8156c2
    * coordinates we want to determine a stable quantized size in pixels
8156c2
    * that doesn't vary due to the original box's sub-pixel position.
8156c2
-- 
8156c2
2.23.0
8156c2
8156c2
8156c2
From 676369000658c6121d0c3b5e1286aa68dc79eb35 Mon Sep 17 00:00:00 2001
8156c2
From: Carlos Garnacho <carlosg@gnome.org>
8156c2
Date: Mon, 8 May 2017 15:10:58 +0200
8156c2
Subject: [PATCH 3/3] cogl: Ensure to only clear the depth buffer if depth
8156c2
 testing is enabled
8156c2
8156c2
The depth buffer is marked as invalid when 1) the framebuffer is just created,
8156c2
and 2) whenever GL_DEPTH_TEST is enabled on it. This will ensure the
8156c2
framebuffers attached depth buffer (if any) is properly cleared before it's
8156c2
actually used, while saving needless clears while depth testing is disabled
8156c2
(the default).
8156c2
8156c2
https://bugzilla.gnome.org/show_bug.cgi?id=782344
8156c2
---
8156c2
 cogl/cogl/cogl-framebuffer-private.h       |  5 +++++
8156c2
 cogl/cogl/cogl-framebuffer.c               | 11 +++++++++++
8156c2
 cogl/cogl/driver/gl/cogl-pipeline-opengl.c |  6 +++++-
8156c2
 3 files changed, 21 insertions(+), 1 deletion(-)
8156c2
8156c2
diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h
8156c2
index 99ac2fba9..756e34dfe 100644
8156c2
--- a/cogl/cogl/cogl-framebuffer-private.h
8156c2
+++ b/cogl/cogl/cogl-framebuffer-private.h
8156c2
@@ -193,6 +193,11 @@ struct _CoglFramebuffer
8156c2
   CoglFramebufferBits bits;
8156c2
 
8156c2
   int                 samples_per_pixel;
8156c2
+
8156c2
+  /* Whether the depth buffer was enabled for this framebuffer,
8156c2
+   * usually means it needs to be cleared before being reused next.
8156c2
+   */
8156c2
+  CoglBool            depth_buffer_clear_needed;
8156c2
 };
8156c2
 
8156c2
 typedef enum {
8156c2
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
8156c2
index 55b9e3756..6b105087d 100644
8156c2
--- a/cogl/cogl/cogl-framebuffer.c
8156c2
+++ b/cogl/cogl/cogl-framebuffer.c
8156c2
@@ -117,6 +117,7 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
8156c2
   framebuffer->viewport_age_for_scissor_workaround = -1;
8156c2
   framebuffer->dither_enabled = TRUE;
8156c2
   framebuffer->depth_writing_enabled = TRUE;
8156c2
+  framebuffer->depth_buffer_clear_needed = TRUE;
8156c2
 
8156c2
   framebuffer->modelview_stack = cogl_matrix_stack_new (ctx);
8156c2
   framebuffer->projection_stack = cogl_matrix_stack_new (ctx);
8156c2
@@ -268,6 +269,13 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
8156c2
   int scissor_y1;
8156c2
   CoglBool saved_viewport_scissor_workaround;
8156c2
 
8156c2
+  if (!framebuffer->depth_buffer_clear_needed &&
8156c2
+      (buffers & COGL_BUFFER_BIT_DEPTH))
8156c2
+    buffers &= ~(COGL_BUFFER_BIT_DEPTH);
8156c2
+
8156c2
+  if (buffers == 0)
8156c2
+    return;
8156c2
+
8156c2
   _cogl_clip_stack_get_bounds (clip_stack,
8156c2
                                &scissor_x0, &scissor_y0,
8156c2
                                &scissor_x1, &scissor_y1);
8156c2
@@ -415,6 +423,9 @@ cleared:
8156c2
   _cogl_framebuffer_mark_mid_scene (framebuffer);
8156c2
   _cogl_framebuffer_mark_clear_clip_dirty (framebuffer);
8156c2
 
8156c2
+  if (buffers & COGL_BUFFER_BIT_DEPTH)
8156c2
+    framebuffer->depth_buffer_clear_needed = FALSE;
8156c2
+
8156c2
   if (buffers & COGL_BUFFER_BIT_COLOR && buffers & COGL_BUFFER_BIT_DEPTH)
8156c2
     {
8156c2
       /* For our fast-path for reading back a single pixel of simple
8156c2
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
8156c2
index 178269646..4f1f69f96 100644
8156c2
--- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
8156c2
+++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
8156c2
@@ -418,7 +418,11 @@ flush_depth_state (CoglContext *ctx,
8156c2
   if (ctx->depth_test_enabled_cache != depth_state->test_enabled)
8156c2
     {
8156c2
       if (depth_state->test_enabled == TRUE)
8156c2
-        GE (ctx, glEnable (GL_DEPTH_TEST));
8156c2
+        {
8156c2
+          GE (ctx, glEnable (GL_DEPTH_TEST));
8156c2
+          if (ctx->current_draw_buffer)
8156c2
+            ctx->current_draw_buffer->depth_buffer_clear_needed = TRUE;
8156c2
+        }
8156c2
       else
8156c2
         GE (ctx, glDisable (GL_DEPTH_TEST));
8156c2
       ctx->depth_test_enabled_cache = depth_state->test_enabled;
8156c2
-- 
8156c2
2.23.0
8156c2