[Mesa-dev,2/4] dri3: Reuse the sbc instead of tracking another copy of the swap count.

Submitted by Eric Anholt on March 8, 2014, 1:26 a.m.

Details

Message ID 1394242021-23124-2-git-send-email-eric@anholt.net
State New
Headers show

Not browsing as part of any series.

Commit Message

Eric Anholt March 8, 2014, 1:26 a.m.
---
 src/glx/dri3_glx.c  | 6 ++----
 src/glx/dri3_priv.h | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 4388b74..72ec8ec 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1346,7 +1346,7 @@  dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
          target_msc = priv->msc + priv->swap_interval * (priv->send_sbc - priv->recv_sbc);
 
       priv->buffers[buf_id]->busy = 1;
-      priv->buffers[buf_id]->last_swap = priv->swap_count;
+      priv->buffers[buf_id]->last_swap = priv->send_sbc;
       xcb_present_pixmap(c,
                          priv->base.xDrawable,
                          priv->buffers[buf_id]->pixmap,
@@ -1381,8 +1381,6 @@  dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
       xcb_flush(c);
       if (priv->stamp)
          ++(*priv->stamp);
-
-      priv->swap_count++;
    }
 
    return ret;
@@ -1395,7 +1393,7 @@  dri3_get_buffer_age(__GLXDRIdrawable *pdraw)
    const struct dri3_buffer *const back = dri3_back_buffer(priv);
 
    if (back->last_swap != 0)
-      return priv->swap_count - back->last_swap;
+      return priv->send_sbc - back->last_swap + 1;
    else
       return 0;
 }
diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h
index d00440a..316e313 100644
--- a/src/glx/dri3_priv.h
+++ b/src/glx/dri3_priv.h
@@ -97,7 +97,7 @@  struct dri3_buffer {
    uint32_t     cpp;
    uint32_t     flags;
    uint32_t     width, height;
-   uint32_t     last_swap;
+   uint64_t     last_swap;
 
    enum dri3_buffer_type        buffer_type;
 };
@@ -185,7 +185,6 @@  struct dri3_drawable {
    struct dri3_buffer *buffers[DRI3_NUM_BUFFERS];
    int cur_back;
    int num_back;
-   uint32_t swap_count;
 
    uint32_t *stamp;