dri3: Fix pixmap buf_id computation
[mesa.git] / src / glx / dri3_glx.c
index a78fc800bdbab25645ba115dd9f0f1bdf866b976..0c8e0646298398f95021c7e153cabcd1cd1b490a 100644 (file)
@@ -945,7 +945,7 @@ dri3_get_pixmap_buffer(__DRIdrawable *driDrawable,
                        void *loaderPrivate)
 {
    struct dri3_drawable                 *pdraw = loaderPrivate;
-   int                                  buf_id = buffer_type == dri3_pixmap_buf_id(buffer_type);
+   int                                  buf_id = dri3_pixmap_buf_id(buffer_type);
    struct dri3_buffer                   *buffer = pdraw->buffers[buf_id];
    Pixmap                               pixmap;
    xcb_dri3_buffer_from_pixmap_cookie_t bp_cookie;
@@ -1579,6 +1579,7 @@ static const struct glx_screen_vtable dri3_screen_vtable = {
 static struct glx_screen *
 dri3_create_screen(int screen, struct glx_display * priv)
 {
+   xcb_connection_t *c = XGetXCBConnection(priv->dpy);
    const __DRIconfig **driver_configs;
    const __DRIextension **extensions;
    const struct dri3_display *const pdp = (struct dri3_display *)
@@ -1602,9 +1603,15 @@ dri3_create_screen(int screen, struct glx_display * priv)
 
    psc->fd = dri3_open(priv->dpy, RootWindow(priv->dpy, screen), None);
    if (psc->fd < 0) {
+      int conn_error = xcb_connection_has_error(c);
+
       glx_screen_cleanup(&psc->base);
       free(psc);
       InfoMessageF("screen %d does not appear to be DRI3 capable\n", screen);
+
+      if (conn_error)
+         ErrorMessageF("Connection closed during DRI3 initialization failure");
+
       return NULL;
    }
    deviceName = NULL;