dri3: Don't fail on version mismatch
authorDaniel Stone <daniels@collabora.com>
Mon, 19 Mar 2018 15:03:22 +0000 (15:03 +0000)
committerDaniel Stone <daniels@collabora.com>
Tue, 20 Mar 2018 08:52:59 +0000 (08:52 +0000)
The previous commit to make DRI3 modifier support optional, breaks with
an updated server and old client.

Make sure we never set multibuffers_available unless we also support it
locally. Make sure we don't call stubs of new-DRI3 functions (or empty
branches) which will never succeed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Fixes: 7aeef2d4efdc ("dri3: allow building against older xcb (v3)")
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/platform_x11_dri3.c
src/glx/dri3_glx.c
src/loader/loader_dri3_helper.c
src/vulkan/wsi/wsi_common_x11.c

index 535806e4bfe4769eab50ee33abb66cb36b930c4c..45d0c7275c515c30ed8b381983563979275fb5ea 100644 (file)
@@ -882,7 +882,7 @@ dri2_setup_extensions(_EGLDisplay *disp)
    if (!dri2_bind_extensions(dri2_dpy, mandatory_core_extensions, extensions, false))
       return EGL_FALSE;
 
-#ifdef HAVE_DRI3
+#ifdef HAVE_DRI3_MODIFIERS
    dri2_dpy->multibuffers_available =
       (dri2_dpy->dri3_major_version > 1 || (dri2_dpy->dri3_major_version == 1 &&
                                             dri2_dpy->dri3_minor_version >= 2)) &&
index de60e952da872b5ffcf310c5ef8f7a84f631d39a..5e531e21cb01efaf5536047a356dd0a98751735f 100644 (file)
@@ -322,12 +322,12 @@ dri3_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
    return &dri2_img->base;
 }
 
+#ifdef HAVE_DRI3_MODIFIERS
 static _EGLImage *
 dri3_create_image_khr_pixmap_from_buffers(_EGLDisplay *disp, _EGLContext *ctx,
                                           EGLClientBuffer buffer,
                                           const EGLint *attr_list)
 {
-#ifdef HAVE_DRI3_MODIFIERS
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_image *dri2_img;
    xcb_dri3_buffers_from_pixmap_cookie_t bp_cookie;
@@ -377,23 +377,25 @@ dri3_create_image_khr_pixmap_from_buffers(_EGLDisplay *disp, _EGLContext *ctx,
    }
 
    return &dri2_img->base;
-#else
-   return NULL;
-#endif
 }
+#endif
 
 static _EGLImage *
 dri3_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
                       _EGLContext *ctx, EGLenum target,
                       EGLClientBuffer buffer, const EGLint *attr_list)
 {
+#ifdef HAVE_DRI3_MODIFIERS
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+#endif
 
    switch (target) {
    case EGL_NATIVE_PIXMAP_KHR:
+#ifdef HAVE_DRI3_MODIFIERS
       if (dri2_dpy->multibuffers_available)
          return dri3_create_image_khr_pixmap_from_buffers(disp, ctx, buffer,
                                                           attr_list);
+#endif
       return dri3_create_image_khr_pixmap(disp, ctx, buffer, attr_list);
    default:
       return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list);
index aec803adfd8bd09d78e6a0bef3cf0105433df8fc..c48a8ba532730d255c755ce02831bdfc6d302f1a 100644 (file)
@@ -357,10 +357,12 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable,
 {
    struct dri3_drawable *pdraw;
    struct dri3_screen *psc = (struct dri3_screen *) base;
-   const struct dri3_display *const pdp = (struct dri3_display *)
-      base->display->dri3Display;
    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
    bool has_multibuffer = false;
+#ifdef HAVE_DRI3_MODIFIERS
+   const struct dri3_display *const pdp = (struct dri3_display *)
+      base->display->dri3Display;
+#endif
 
    pdraw = calloc(1, sizeof(*pdraw));
    if (!pdraw)
@@ -371,11 +373,13 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable,
    pdraw->base.drawable = drawable;
    pdraw->base.psc = &psc->base;
 
+#ifdef HAVE_DRI3_MODIFIERS
    if ((psc->image && psc->image->base.version >= 15) &&
        (pdp->dri3Major > 1 || (pdp->dri3Major == 1 && pdp->dri3Minor >= 2)) &&
        (pdp->presentMajor > 1 ||
         (pdp->presentMajor == 1 && pdp->presentMinor >= 2)))
       has_multibuffer = true;
+#endif
 
    (void) __glXInitialize(psc->base.dpy);
 
index c1d94c3c21efb7db57be7a78b100f227f2980efd..fe17df14738369d464e2b08ac2113d7aa79928e8 100644 (file)
@@ -1274,9 +1274,9 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
       buffer->modifier = DRM_FORMAT_MOD_INVALID;
 
    pixmap = xcb_generate_id(draw->conn);
+#ifdef HAVE_DRI3_MODIFIERS
    if (draw->multiplanes_available &&
        buffer->modifier != DRM_FORMAT_MOD_INVALID) {
-#ifdef HAVE_DRI3_MODIFIERS
       xcb_dri3_pixmap_from_buffers(draw->conn,
                                    pixmap,
                                    draw->drawable,
@@ -1289,8 +1289,9 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
                                    depth, buffer->cpp * 8,
                                    buffer->modifier,
                                    buffer_fds);
+   } else
 #endif
-   } else {
+   {
       xcb_dri3_pixmap_from_buffer(draw->conn,
                                   pixmap,
                                   draw->drawable,
index 71d62cb4cb76bc0bb8da4c9d65a68e0eeb8d7950..3a00caddfb90f9384faf836f3c56cfdfb981a484 100644 (file)
@@ -168,6 +168,7 @@ wsi_x11_connection_create(const VkAllocationCallbacks *alloc,
    }
 
    wsi_conn->has_dri3 = dri3_reply->present != 0;
+#ifdef HAVE_DRI3_MODIFIERS
    if (wsi_conn->has_dri3) {
       xcb_dri3_query_version_cookie_t ver_cookie;
       xcb_dri3_query_version_reply_t *ver_reply;
@@ -178,8 +179,10 @@ wsi_x11_connection_create(const VkAllocationCallbacks *alloc,
          (ver_reply->major_version > 1 || ver_reply->minor_version >= 2);
       free(ver_reply);
    }
+#endif
 
    wsi_conn->has_present = pres_reply->present != 0;
+#ifdef HAVE_DRI3_MODIFIERS
    if (wsi_conn->has_present) {
       xcb_present_query_version_cookie_t ver_cookie;
       xcb_present_query_version_reply_t *ver_reply;
@@ -190,6 +193,7 @@ wsi_x11_connection_create(const VkAllocationCallbacks *alloc,
         (ver_reply->major_version > 1 || ver_reply->minor_version >= 2);
       free(ver_reply);
    }
+#endif
 
    wsi_conn->has_dri3_modifiers = has_dri3_v1_2 && has_present_v1_2;
    wsi_conn->is_proprietary_x11 = false;