[Mesa-dev] [PATCH] egl_dri2: Lower __DRI_IMAGE version requirement back to 1

Kristian Høgsberg krh at bitplanet.net
Tue Mar 19 10:32:31 PDT 2013


We check the extension version manually instead and verify that we have
the createImageFromFds function before enabling prime fd passing.
---
 src/egl/drivers/dri2/egl_dri2.c         | 6 ++++--
 src/egl/drivers/dri2/platform_wayland.c | 9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

This should fix the piglit EGL regressions.  I guess we can still do a
better job of falling back gracefully and disable EGLImage extensions
when __DRI_IMAGE isn't available, but this at least brings us back to
where we were before.

Kristian

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index a3aabf5..06a21d7 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -320,7 +320,7 @@ static struct dri2_extension_match dri2_driver_extensions[] = {
 static struct dri2_extension_match dri2_core_extensions[] = {
    { __DRI2_FLUSH, 1, offsetof(struct dri2_egl_display, flush) },
    { __DRI_TEX_BUFFER, 2, offsetof(struct dri2_egl_display, tex_buffer) },
-   { __DRI_IMAGE, 7, offsetof(struct dri2_egl_display, image) },
+   { __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
    { NULL, 0, 0 }
 };
 
@@ -1573,7 +1573,9 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
       (int(*)(void *, uint32_t)) dri2_dpy->authenticate;
 
    ret = drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap);
-   if (ret == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT))
+   if (ret == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
+       dri2_dpy->image->base.version >= 7 &&
+       dri2_dpy->image->createImageFromFds != NULL)
       flags |= WAYLAND_DRM_PRIME;
 
    dri2_dpy->wl_server_drm =
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 740fc7d..8e4b3ce 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -773,6 +773,15 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
    if (!dri2_create_screen(disp))
       goto cleanup_driver;
 
+   /* The server shouldn't advertise WL_DRM_CAPABILITY_PRIME if the driver
+    * doesn't have createImageFromFds, since we're using the same driver on
+    * both sides.  We don't want crash if that happens anyway, so fall back to
+    * gem names if we don't have prime support. */
+
+   if (dri2_dpy->image->base.version < 7 ||
+       dri2_dpy->image->createImageFromFds == NULL)
+      dri2_dpy->capabilities &= WL_DRM_CAPABILITY_PRIME;
+
    types = EGL_WINDOW_BIT;
    for (i = 0; dri2_dpy->driver_configs[i]; i++) {
       config = dri2_dpy->driver_configs[i];
-- 
1.8.1.2



More information about the mesa-dev mailing list