summaryrefslogtreecommitdiffstats
path: root/src/glx/dri3_glx.c
diff options
context:
space:
mode:
authorAdel Gadllah <[email protected]>2014-02-24 20:44:42 +0100
committerEric Anholt <[email protected]>2014-03-13 14:19:21 -0700
commita69fabc76cc5a8d744fb184bfc5a4096ee596c13 (patch)
treef17c9fe43fc9f9fe0f77c9de67f380cf20bfd254 /src/glx/dri3_glx.c
parent0b02d8a633da7ee19793eb12bb5ea407afe0de6f (diff)
dri3: Add GLX_EXT_buffer_age support
v2: Indent according to Mesa style, reuse sbc instead of making a new swap_count field, and actually get a usable back before returning the age of the back (fixing updated piglit tests). Changes by anholt. Signed-off-by: Adel Gadllah <[email protected]> Reviewed-by: Robert Bragg <[email protected]> (v1) Reviewed-by: Adel Gadllah <[email protected]> (v2) Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glx/dri3_glx.c')
-rw-r--r--src/glx/dri3_glx.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index ba801847671..b7dac8e67b5 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1340,6 +1340,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->send_sbc;
xcb_present_pixmap(c,
priv->base.xDrawable,
priv->buffers[buf_id]->pixmap,
@@ -1379,6 +1380,22 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
return ret;
}
+static int
+dri3_get_buffer_age(__GLXDRIdrawable *pdraw)
+{
+ xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
+ struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
+ int back_id = DRI3_BACK_ID(dri3_find_back(c, priv));
+
+ if (back_id < 0 || !priv->buffers[back_id])
+ return 0;
+
+ if (priv->buffers[back_id]->last_swap != 0)
+ return priv->send_sbc - priv->buffers[back_id]->last_swap + 1;
+ else
+ return 0;
+}
+
/** dri3_open
*
* Wrapper around xcb_dri3_open
@@ -1737,6 +1754,9 @@ dri3_create_screen(int screen, struct glx_display * priv)
psp->copySubBuffer = dri3_copy_sub_buffer;
__glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
+ psp->getBufferAge = dri3_get_buffer_age;
+ __glXEnableDirectExtension(&psc->base, "GLX_EXT_buffer_age");
+
free(driverName);
free(deviceName);