summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorFredrik Höglund <[email protected]>2011-12-20 17:17:02 +0100
committerKristian Høgsberg <[email protected]>2011-12-20 22:11:17 -0500
commit655f2c1d6593064b83f64a527798f48cd300fa16 (patch)
tree7772ebc5b5ce0fff5f8fc7b012a7e283537188ab /src/egl
parent3a2e71874b630fe5d7ec36bbbd69a6dacab7cd15 (diff)
egl_dri2/x11: Add support for eglSwapInterval
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c8
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h1
-rw-r--r--src/egl/drivers/dri2/platform_x11.c28
3 files changed, 36 insertions, 1 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 4c9ece351af..47de978404d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -259,9 +259,15 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
return NULL;
}
- if (double_buffer)
+ if (double_buffer) {
surface_type &= ~EGL_PIXMAP_BIT;
+ if (dri2_dpy->swap_available) {
+ conf->base.MinSwapInterval = 0;
+ conf->base.MaxSwapInterval = 1000; /* XXX arbitrary value */
+ }
+ }
+
conf->base.SurfaceType |= surface_type;
return conf;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 193a866324f..bead446dad6 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -102,6 +102,7 @@ struct dri2_egl_display
int fd;
int own_device;
+ int swap_available;
#ifdef HAVE_DRM_PLATFORM
struct gbm_dri_device *gbm_dri;
#endif
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index d789ec6793a..d761fe053d6 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -764,6 +764,31 @@ dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw,
}
static EGLBoolean
+dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint interval)
+{
+#if XCB_DRI2_MINOR_VERSION >= 3
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+ /* XXX Check vblank_mode here? */
+
+ if (interval > surf->Config->MaxSwapInterval)
+ interval = surf->Config->MaxSwapInterval;
+ else if (interval < surf->Config->MinSwapInterval)
+ interval = surf->Config->MinSwapInterval;
+
+ if (interval != surf->SwapInterval && dri2_dpy->swap_available)
+ xcb_dri2_swap_interval(dri2_dpy->conn, dri2_surf->drawable, interval);
+
+ surf->SwapInterval = interval;
+
+ return EGL_TRUE;
+#else
+ return EGL_FALSE;
+#endif
+}
+
+static EGLBoolean
dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
EGLNativePixmapType target)
{
@@ -987,6 +1012,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
drv->API.CreateImageKHR = dri2_x11_create_image_khr;
drv->API.SwapBuffersRegionNOK = dri2_swap_buffers_region;
drv->API.PostSubBufferNV = dri2_post_sub_buffer;
+ drv->API.SwapInterval = dri2_swap_interval;
dri2_dpy = malloc(sizeof *dri2_dpy);
if (!dri2_dpy)
@@ -1046,6 +1072,8 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
dri2_dpy->extensions[1] = &image_lookup_extension.base;
dri2_dpy->extensions[2] = NULL;
+ dri2_dpy->swap_available = (dri2_dpy->dri2_minor >= 2);
+
if (!dri2_create_screen(disp))
goto cleanup_fd;