Mesa (master): dri3: Prefer the last chosen back when finding a new one.

Eric Anholt anholt at kemper.freedesktop.org
Thu Mar 13 21:41:26 UTC 2014


Module: Mesa
Branch: master
Commit: 0b02d8a633da7ee19793eb12bb5ea407afe0de6f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b02d8a633da7ee19793eb12bb5ea407afe0de6f

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Mar  7 15:56:06 2014 -0800

dri3: Prefer the last chosen back when finding a new one.

With the buffer_age code, I need to be able to potentially call this more
than once per frame, and it would be bad if a new special event showing up
meant I chose a different back mid-frame.  Now, once we've chosen a back
for the frame, another find_back will choose it again since we know that
it won't have ->busy set until swap.

Note that this makes find_back return a buffer id instead of a backbuffer
index.  That's kind of a silly distinction anyway, since it's an identity
mapping between the two (it's the front buffer that is at an offset).

Reviewed-By: Adel Gadllah <adel.gadllah at gmail.com>

---

 src/glx/dri3_glx.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index f27a773..ba80184 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1090,13 +1090,13 @@ dri3_find_back(xcb_connection_t *c, struct dri3_drawable *priv)
 
    for (;;) {
       for (b = 0; b < priv->num_back; b++) {
-         int id = DRI3_BACK_ID(b);
+         int id = DRI3_BACK_ID((b + priv->cur_back) % priv->num_back);
          struct dri3_buffer *buffer = priv->buffers[id];
 
-         if (!buffer)
-            return b;
-         if (!buffer->busy)
-            return b;
+         if (!buffer || !buffer->busy) {
+            priv->cur_back = id;
+            return id;
+         }
       }
       xcb_flush(c);
       ev = xcb_wait_for_special_event(c, priv->special_event);
@@ -1123,13 +1123,10 @@ dri3_get_buffer(__DRIdrawable *driDrawable,
    int                  buf_id;
 
    if (buffer_type == dri3_buffer_back) {
-      int back = dri3_find_back(c, priv);
+      buf_id = dri3_find_back(c, priv);
 
-      if (back < 0)
+      if (buf_id < 0)
          return NULL;
-
-      priv->cur_back = back;
-      buf_id = DRI3_BACK_ID(priv->cur_back);
    } else {
       buf_id = DRI3_FRONT_ID;
    }




More information about the mesa-commit mailing list