[PATCH 1/3] present: Store current present mode in vblank instead of just flip boolean

Keith Packard keithp at keithp.com
Sat Dec 13 00:32:29 PST 2014


This changes the 'flip' boolean in the present structure to hold the
PresentComplete mode value, which gives us precise information about
whether the operation has been skipped, copied or flipped without
having to intuit that from the state of the pixmap, window and flip
values.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 present/present.c      | 44 +++++++++++++++++++-------------------------
 present/present_priv.h |  2 +-
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/present/present.c b/present/present.c
index e27fe30..6a414c2 100644
--- a/present/present.c
+++ b/present/present.c
@@ -179,18 +179,20 @@ present_flip(RRCrtcPtr crtc,
 }
 
 static void
-present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, uint64_t ust, uint64_t crtc_msc)
+present_vblank_notify(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
 {
     int         n;
 
     if (vblank->window)
-        present_send_complete_notify(vblank->window, kind, mode, vblank->serial, ust, crtc_msc - vblank->msc_offset);
+        present_send_complete_notify(vblank->window, vblank->kind, vblank->mode,
+                                     vblank->serial, ust, crtc_msc - vblank->msc_offset);
     for (n = 0; n < vblank->num_notifies; n++) {
         WindowPtr   window = vblank->notifies[n].window;
         CARD32      serial = vblank->notifies[n].serial;
 
         if (window)
-            present_send_complete_notify(window, kind, mode, serial, ust, crtc_msc - vblank->msc_offset);
+            present_send_complete_notify(window, vblank->kind, vblank->mode,
+                                         serial, ust, crtc_msc - vblank->msc_offset);
     }
 }
 
@@ -463,7 +465,7 @@ present_flip_notify(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
     if (vblank->abort_flip)
         present_unflip(screen);
 
-    present_vblank_notify(vblank, PresentCompleteKindPixmap, PresentCompleteModeFlip, ust, crtc_msc);
+    present_vblank_notify(vblank, ust, crtc_msc);
     present_vblank_destroy(vblank);
 
     present_flip_try_ready(screen);
@@ -548,8 +550,11 @@ present_check_flip_window (WindowPtr window)
 
     /* Now check any queued vblanks */
     xorg_list_for_each_entry(vblank, &window_priv->vblank, window_list) {
-        if (vblank->queued && vblank->flip && !present_check_flip(vblank->crtc, window, vblank->pixmap, FALSE, NULL, 0, 0))
-            vblank->flip = FALSE;
+        if (vblank->queued && vblank->mode == PresentCompleteModeFlip &&
+            !present_check_flip(vblank->crtc, window, vblank->pixmap, FALSE, NULL, 0, 0))
+        {
+            vblank->mode = PresentCompleteModeCopy;
+        }
     }
 }
 
@@ -581,7 +586,6 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
     WindowPtr                   window = vblank->window;
     ScreenPtr                   screen = window->drawable.pScreen;
     present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
-    uint8_t                     mode;
 
     if (vblank->wait_fence) {
         if (!present_fence_check_triggered(vblank->wait_fence)) {
@@ -590,7 +594,7 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
         }
     }
 
-    if (vblank->flip && vblank->pixmap && vblank->window) {
+    if (vblank->mode == PresentCompleteModeFlip && vblank->pixmap && vblank->window) {
         if (screen_priv->flip_pending || screen_priv->unflip_event_id) {
             DebugPresent(("\tr %lld %p (pending %p unflip %lld)\n",
                           vblank->event_id, vblank,
@@ -606,7 +610,7 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
 
     if (vblank->pixmap && vblank->window) {
 
-        if (vblank->flip) {
+        if (vblank->mode == PresentCompleteModeFlip) {
 
             DebugPresent(("\tf %lld %p %8lld: %08lx -> %08lx\n",
                           vblank->event_id, vblank, crtc_msc,
@@ -649,7 +653,7 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
             /* Oops, flip failed. Clear the flip_pending field
               */
             screen_priv->flip_pending = NULL;
-            vblank->flip = FALSE;
+            vblank->mode = PresentCompleteModeCopy;
         }
         DebugPresent(("\tc %p %8lld: %08lx -> %08lx\n", vblank, crtc_msc, vblank->pixmap->drawable.id, vblank->window->drawable.id));
         if (screen_priv->flip_pending) {
@@ -676,19 +680,7 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
         present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
     }
 
-    /* Compute correct CompleteMode
-     */
-    if (vblank->kind == PresentCompleteKindPixmap) {
-        if (vblank->pixmap && vblank->window)
-            mode = PresentCompleteModeCopy;
-        else
-            mode = PresentCompleteModeSkip;
-    }
-    else
-        mode = PresentCompleteModeCopy;
-
-
-    present_vblank_notify(vblank, vblank->kind, mode, ust, crtc_msc);
+    present_vblank_notify(vblank, ust, crtc_msc);
     present_vblank_destroy(vblank);
 }
 
@@ -790,7 +782,8 @@ present_pixmap(WindowPtr window,
 
             vblank->pixmap = NULL;
             vblank->idle_fence = NULL;
-            vblank->flip = FALSE;
+            vblank->mode = PresentCompleteModeSkip;
+
             if (vblank->flip_ready)
                 present_re_execute(vblank);
         }
@@ -833,6 +826,7 @@ present_pixmap(WindowPtr window,
     vblank->msc_offset = window_priv->msc_offset;
     vblank->notifies = notifies;
     vblank->num_notifies = num_notifies;
+    vblank->mode = PresentCompleteModeCopy;
 
     if (!(options & PresentOptionAsync))
         vblank->sync_flip = TRUE;
@@ -844,7 +838,7 @@ present_pixmap(WindowPtr window,
         pixmap != NULL &&
         present_check_flip (target_crtc, window, pixmap, vblank->sync_flip, valid, x_off, y_off))
     {
-        vblank->flip = TRUE;
+        vblank->mode = PresentCompleteModeFlip;
         if (vblank->sync_flip)
             target_msc--;
     }
diff --git a/present/present_priv.h b/present/present_priv.h
index f5c1652..1046952 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -62,6 +62,7 @@ struct present_vblank {
     int16_t             x_off;
     int16_t             y_off;
     CARD16              kind;
+    CARD16              mode;
     uint64_t            event_id;
     uint64_t            target_msc;
     uint64_t            msc_offset;
@@ -70,7 +71,6 @@ struct present_vblank {
     present_notify_ptr  notifies;
     int                 num_notifies;
     Bool                queued;         /* on present_exec_queue */
-    Bool                flip;           /* planning on using flip */
     Bool                flip_ready;     /* wants to flip, but waiting for previous flip or unflip */
     Bool                sync_flip;      /* do flip synchronous to vblank */
     Bool                abort_flip;     /* aborting this flip */
-- 
2.1.3



More information about the xorg-devel mailing list