s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
screen = get_xcb_screen(s, dri2_dpy->screen);
if (!screen) {
- _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
+ _eglError(EGL_BAD_ALLOC, "failed to get xcb screen");
goto cleanup_surf;
}
dri2_surf->base.Width, dri2_surf->base.Height);
} else {
if (!drawable) {
- _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
+ if (type == EGL_WINDOW_BIT)
+ _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
+ else
+ _eglError(EGL_BAD_NATIVE_PIXMAP, "dri2_create_surface");
goto cleanup_surf;
}
dri2_surf->drawable = drawable;
xcb_generic_error_t *error;
xcb_screen_iterator_t s;
xcb_screen_t *screen;
- char *driver_name, *device_name;
+ char *driver_name, *loader_driver_name, *device_name;
const xcb_query_extension_reply_t *extension;
xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_xfixes_id);
s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
screen = get_xcb_screen(s, dri2_dpy->screen);
if (!screen) {
- _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_x11_connect");
+ _eglLog(_EGL_WARNING, "DRI2: failed to get xcb screen");
return EGL_FALSE;
}
connect_cookie = xcb_dri2_connect_unchecked(dri2_dpy->conn, screen->root,
}
driver_name = xcb_dri2_connect_driver_name (connect);
- dri2_dpy->driver_name =
- strndup(driver_name,
- xcb_dri2_connect_driver_name_length(connect));
+
+ /* If Mesa knows about the appropriate driver for this fd, then trust it.
+ * Otherwise, default to the server's value.
+ */
+ loader_driver_name = loader_get_driver_for_fd(dri2_dpy->fd, 0);
+ if (loader_driver_name) {
+ dri2_dpy->driver_name = loader_driver_name;
+ } else {
+ dri2_dpy->driver_name =
+ strndup(driver_name,
+ xcb_dri2_connect_driver_name_length(connect));
+ }
if (dri2_dpy->device_name == NULL || dri2_dpy->driver_name == NULL) {
close(dri2_dpy->fd);
screen = get_xcb_screen(s, dri2_dpy->screen);
if (!screen) {
- _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_x11_authenticate");
+ _eglLog(_EGL_WARNING, "DRI2: failed to get xcb screen");
return -1;
}
dri2_dpy->screen = DefaultScreen(dpy);
}
- if (xcb_connection_has_error(dri2_dpy->conn)) {
+ if (!dri2_dpy->conn || xcb_connection_has_error(dri2_dpy->conn)) {
_eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
goto cleanup_dpy;
}
if (!dri2_create_screen(disp))
goto cleanup_driver;
- if (dri2_dpy->conn) {
- if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp))
- goto cleanup_configs;
- }
+ if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp))
+ goto cleanup_configs;
/* Fill vtbl last to prevent accidentally calling virtual function during
* initialization.
if (!dri2_x11_connect(dri2_dpy))
goto cleanup_conn;
- if (!dri2_load_driver(disp))
+ if (!dri2_x11_local_authenticate(disp))
goto cleanup_fd;
- if (!dri2_x11_local_authenticate(disp))
- goto cleanup_driver;
+ if (!dri2_load_driver(disp))
+ goto cleanup_fd;
if (dri2_dpy->dri2_minor >= 1) {
dri2_dpy->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;