[mutter/wip/xtoglsync-3-10: 1/4] compositor: Sync X drawing only once per frame



commit 1ed41b7ed3544b0e73c9003753f9bb495ce7661e
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon May 12 15:11:53 2014 +0200

    compositor: Sync X drawing only once per frame
    
    We only need to call XSync() once per frame to synchronize X with GL
    drawing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728464

 src/compositor/compositor-private.h |    2 ++
 src/compositor/compositor.c         |   29 +++++++++++++++++++++++++++++
 src/compositor/meta-window-actor.c  |   20 --------------------
 3 files changed, 31 insertions(+), 20 deletions(-)
---
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 0ebf3a4..622dd0b 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -32,6 +32,8 @@ struct _MetaCompositor
   guint           show_redraw : 1;
   guint           debug       : 1;
   guint           no_mipmaps  : 1;
+
+  gboolean need_sync_drawing;
 };
 
 struct _MetaCompScreen
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 71497e1..5eaca0c 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -173,6 +173,8 @@ process_damage (MetaCompositor     *compositor,
     return;
 
   meta_window_actor_process_damage (window_actor, event);
+
+  compositor->need_sync_drawing = TRUE;
 }
 
 static void
@@ -1484,6 +1486,33 @@ meta_repaint_func (gpointer data)
       pre_paint_windows (info);
     }
 
+  if (compositor->need_sync_drawing)
+    {
+      /* We need to make sure that any X drawing that happens before
+       * the XDamageSubtract() for each MWA above is visible to
+       * subsequent GL rendering; the only standardized way to do this
+       * is EXT_x11_sync_object, which isn't yet widely available. For
+       * now, we count on details of Xorg and the open source drivers,
+       * and hope for the best otherwise.
+       *
+       * Xorg and open source driver specifics:
+       *
+       * The X server makes sure to flush drawing to the kernel before
+       * sending out damage events, but since we use
+       * DamageReportBoundingBox there may be drawing between the last
+       * damage event and the XDamageSubtract() that needs to be
+       * flushed as well.
+       *
+       * Xorg always makes sure that drawing is flushed to the kernel
+       * before writing events or responses to the client, so any
+       * round trip request at this point is sufficient to flush the
+       * GLX buffers.
+       */
+      XSync (compositor->display->xdisplay, False);
+
+      compositor->need_sync_drawing = FALSE;
+    }
+
   return TRUE;
 }
 
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index ed19647..f65d649 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -2376,26 +2376,6 @@ meta_window_actor_handle_updates (MetaWindowActor *self)
       XDamageSubtract (xdisplay, priv->damage, None, None);
       meta_error_trap_pop (display);
 
-      /* We need to make sure that any X drawing that happens before the
-       * XDamageSubtract() above is visible to subsequent GL rendering;
-       * the only standardized way to do this is EXT_x11_sync_object,
-       * which isn't yet widely available. For now, we count on details
-       * of Xorg and the open source drivers, and hope for the best
-       * otherwise.
-       *
-       * Xorg and open source driver specifics:
-       *
-       * The X server makes sure to flush drawing to the kernel before
-       * sending out damage events, but since we use DamageReportBoundingBox
-       * there may be drawing between the last damage event and the
-       * XDamageSubtract() that needs to be flushed as well.
-       *
-       * Xorg always makes sure that drawing is flushed to the kernel
-       * before writing events or responses to the client, so any round trip
-       * request at this point is sufficient to flush the GLX buffers.
-       */
-      XSync (xdisplay, False);
-
       priv->received_damage = FALSE;
     }
 


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