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



commit 5b03a82fa44183478d5591b375b8d41d2b5232dd
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().
    
    Check the depth and color buffer bits before modifying them.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/402

 cogl/cogl/cogl-framebuffer.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index 1120b2538..69863a4a0 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -256,11 +256,16 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
                           float alpha)
 {
   CoglClipStack *clip_stack = _cogl_framebuffer_get_clip_stack (framebuffer);
+  gboolean had_depth_and_color_buffer_bits;
   int scissor_x0;
   int scissor_y0;
   int scissor_x1;
   int scissor_y1;
 
+  had_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))
     buffers &= ~(COGL_BUFFER_BIT_DEPTH);
@@ -306,8 +311,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 (had_depth_and_color_buffer_bits &&
       !framebuffer->clear_clip_dirty &&
       framebuffer->clear_color_red == red &&
       framebuffer->clear_color_green == green &&
@@ -383,7 +387,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 (had_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


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