[mutter/gbsneto/software-picking: 64/67] cogl/framebuffer: Check buffer bits before modifying it



commit 856889cc5a31217f1f59ffbee94bdffb215eceab
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Jan 21 10:56:42 2019 -0200

    cogl/framebuffer: Check buffer bits before modifying it
    
    CoglFramebuffer checks the passed buffer bits in order to
    detect when the fast path (that uses the journal) should
    be used.
    
    However, it also modifies one of the buffer bits that is
    checked for the fast path, meaning we never actually hit
    the fast path on cogl_framebuffer_cleaf4f().
    
    Fix that by checking the depth and color buffer bits before
    modifying them.

 cogl/cogl/cogl-framebuffer.c             | 10 +++++++---
 src/backends/x11/meta-stage-x11-nested.c |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index 8660f910a..6bfbc5384 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -267,6 +267,11 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
   int scissor_x1;
   int scissor_y1;
   CoglBool saved_viewport_scissor_workaround;
+  gboolean has_depth_and_color_buffer_bits;
+
+  has_depth_and_color_buffer_bits =
+      (buffers & COGL_BUFFER_BIT_DEPTH) &&
+      (buffers & COGL_BUFFER_BIT_COLOR);
 
   if (!framebuffer->depth_buffer_clear_needed &&
       (buffers & COGL_BUFFER_BIT_DEPTH))
@@ -313,8 +318,7 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
    * Note: Comparing without an epsilon is considered
    * appropriate here.
    */
-  if (buffers & COGL_BUFFER_BIT_COLOR &&
-      buffers & COGL_BUFFER_BIT_DEPTH &&
+  if (has_depth_and_color_buffer_bits &&
       !framebuffer->clear_clip_dirty &&
       framebuffer->clear_color_red == red &&
       framebuffer->clear_color_green == green &&
@@ -425,7 +429,7 @@ cleared:
   if (buffers & COGL_BUFFER_BIT_DEPTH)
     framebuffer->depth_buffer_clear_needed = FALSE;
 
-  if (buffers & COGL_BUFFER_BIT_COLOR && buffers & COGL_BUFFER_BIT_DEPTH)
+  if (has_depth_and_color_buffer_bits)
     {
       /* For our fast-path for reading back a single pixel of simple
        * scenes where the whole frame is in the journal we need to
diff --git a/src/backends/x11/meta-stage-x11-nested.c b/src/backends/x11/meta-stage-x11-nested.c
index f77e13ade..3f5be96ad 100644
--- a/src/backends/x11/meta-stage-x11-nested.c
+++ b/src/backends/x11/meta-stage-x11-nested.c
@@ -258,7 +258,7 @@ meta_stage_x11_nested_finish_frame (ClutterStageWindow *stage_window)
     stage_nested->pipeline = cogl_pipeline_new (clutter_backend->cogl_context);
 
   cogl_framebuffer_clear4f (onscreen,
-                            COGL_BUFFER_BIT_COLOR,
+                            COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_DEPTH,
                             0.0f, 0.0f, 0.0f, 1.0f);
 
   for (l = meta_renderer_get_views (renderer); l; l = l->next)


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