[Mesa-dev,4/4] dri3: Fix EXT_buffer_age when the backbuffer actually changes.

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

Details

Message ID 1394242021-23124-4-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:27 a.m.
If get_buffers() hadn't been called yet, we would return the age of the
last back, rather than the one that's actually going to be used for this
frame.

Note that get_buffers() can sometimes reallocate.  We're covered on that
front, though -- it does a copy_area() when it reallocates, which fulfills
the requirement that pixels whose ownership passes both before and after
are of the correct age.

Fixes piglit glx_buffer_age with vblank_mode=0 set.
---
 src/glx/dri3_glx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index e5862f3..f66f322 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1386,11 +1386,15 @@  dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
 static int
 dri3_get_buffer_age(__GLXDRIdrawable *pdraw)
 {
+   xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
    struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
-   const struct dri3_buffer *const back = dri3_back_buffer(priv);
+   int back_id = DRI3_BACK_ID(dri3_find_back(c, priv));
+
+   if (back_id < 0 || !priv->buffers[back_id])
+      return 0;
 
-   if (back->last_swap != 0)
-      return priv->send_sbc - back->last_swap + 1;
+   if (priv->buffers[back_id]->last_swap != 0)
+      return priv->send_sbc - priv->buffers[back_id]->last_swap + 1;
    else
       return 0;
 }