diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 891fefa5849..cab322c9819 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -960,16 +960,15 @@ dri2_setup_extensions(_EGLDisplay *disp) } #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)) && - (dri2_dpy->present_major_version > 1 || - (dri2_dpy->present_major_version == 1 && - dri2_dpy->present_minor_version >= 2)) && - (dri2_dpy->image && dri2_dpy->image->base.version >= 15); +#ifdef HAVE_X11_PLATFORM + if (dri2_dpy->conn) { + bool err; + dri2_dpy->multibuffers_available = loader_dri3_check_multibuffer(dri2_dpy->conn, &err) && + !err && + (dri2_dpy->image && dri2_dpy->image->base.version >= 15); + } +#endif if (disp->Options.Zink && !disp->Options.ForceSoftware && - dri2_dpy->dri3_major_version != -1 && !dri2_dpy->multibuffers_available && /* this is enum _egl_platform_type */ (disp->Platform == _EGL_PLATFORM_X11 || @@ -1192,13 +1191,6 @@ dri2_display_create(void) dri2_dpy->fd_render_gpu = -1; dri2_dpy->fd_display_gpu = -1; -#ifdef HAVE_DRI3_MODIFIERS - dri2_dpy->dri3_major_version = -1; - dri2_dpy->dri3_minor_version = -1; - dri2_dpy->present_major_version = -1; - dri2_dpy->present_minor_version = -1; -#endif - return dri2_dpy; } diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index c8356180597..52f60053e96 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -289,10 +289,6 @@ struct dri2_egl_display { bool swap_available; #ifdef HAVE_DRI3 bool multibuffers_available; - int dri3_major_version; - int dri3_minor_version; - int present_major_version; - int present_minor_version; struct loader_dri3_extensions loader_dri3_ext; struct loader_screen_resources screen_resources; #endif diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index c66b2e3206e..bde561e2cc0 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -1778,7 +1778,7 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp) if (disp->Options.Zink && !debug_get_bool_option("LIBGL_DRI3_DISABLE", false) && !debug_get_bool_option("LIBGL_KOPPER_DRI2", false)) - dri3_x11_connect(dri2_dpy); + dri3_x11_connect(dri2_dpy, disp->Options.ForceSoftware); #endif if (!dri2_load_driver_swrast(disp)) goto cleanup; @@ -1863,7 +1863,7 @@ dri2_initialize_x11_dri3(_EGLDisplay *disp) if (!dri2_get_xcb_connection(disp, dri2_dpy)) goto cleanup; - status = dri3_x11_connect(dri2_dpy); + status = dri3_x11_connect(dri2_dpy, disp->Options.ForceSoftware); if (status != DRI2_EGL_DRIVER_LOADED) goto cleanup; diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c index 6cd63362020..527d19049b2 100644 --- a/src/egl/drivers/dri2/platform_x11_dri3.c +++ b/src/egl/drivers/dri2/platform_x11_dri3.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "drm-uapi/drm_fourcc.h" @@ -527,105 +526,19 @@ struct dri2_egl_display_vtbl dri3_x11_display_vtbl = { .close_screen_notify = dri3_close_screen_notify, }; -/* Only request versions of these protocols which we actually support. */ -#define DRI3_SUPPORTED_MAJOR 1 -#define PRESENT_SUPPORTED_MAJOR 1 - -#ifdef HAVE_DRI3_MODIFIERS -#define DRI3_SUPPORTED_MINOR 2 -#define PRESENT_SUPPORTED_MINOR 2 -#else -#define PRESENT_SUPPORTED_MINOR 0 -#define DRI3_SUPPORTED_MINOR 0 -#endif - enum dri2_egl_driver_fail -dri3_x11_connect(struct dri2_egl_display *dri2_dpy) +dri3_x11_connect(struct dri2_egl_display *dri2_dpy, bool swrast) { - xcb_dri3_query_version_reply_t *dri3_query; - xcb_dri3_query_version_cookie_t dri3_query_cookie; - xcb_present_query_version_reply_t *present_query; - xcb_present_query_version_cookie_t present_query_cookie; - xcb_xfixes_query_version_reply_t *xfixes_query; - xcb_xfixes_query_version_cookie_t xfixes_query_cookie; - xcb_generic_error_t *error; - const xcb_query_extension_reply_t *extension; - - dri2_dpy->dri3_major_version = 0; - dri2_dpy->dri3_minor_version = 0; - dri2_dpy->present_major_version = 0; - dri2_dpy->present_minor_version = 0; - - xcb_prefetch_extension_data(dri2_dpy->conn, &xcb_dri3_id); - xcb_prefetch_extension_data(dri2_dpy->conn, &xcb_present_id); - xcb_prefetch_extension_data(dri2_dpy->conn, &xcb_xfixes_id); - - extension = xcb_get_extension_data(dri2_dpy->conn, &xcb_dri3_id); - if (!(extension && extension->present)) - return DRI2_EGL_DRIVER_FAILED; - - extension = xcb_get_extension_data(dri2_dpy->conn, &xcb_present_id); - if (!(extension && extension->present)) - return DRI2_EGL_DRIVER_FAILED; - - extension = xcb_get_extension_data(dri2_dpy->conn, &xcb_xfixes_id); - if (!(extension && extension->present)) - return DRI2_EGL_DRIVER_FAILED; - - dri3_query_cookie = xcb_dri3_query_version( - dri2_dpy->conn, DRI3_SUPPORTED_MAJOR, DRI3_SUPPORTED_MINOR); - - present_query_cookie = xcb_present_query_version( - dri2_dpy->conn, PRESENT_SUPPORTED_MAJOR, PRESENT_SUPPORTED_MINOR); - - xfixes_query_cookie = xcb_xfixes_query_version( - dri2_dpy->conn, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION); - - dri3_query = - xcb_dri3_query_version_reply(dri2_dpy->conn, dri3_query_cookie, &error); - if (dri3_query == NULL || error != NULL) { - _eglLog(_EGL_WARNING, "DRI3: failed to query the version"); - free(dri3_query); - free(error); - return DRI2_EGL_DRIVER_FAILED; - } - - dri2_dpy->dri3_major_version = dri3_query->major_version; - dri2_dpy->dri3_minor_version = dri3_query->minor_version; - free(dri3_query); - - present_query = xcb_present_query_version_reply( - dri2_dpy->conn, present_query_cookie, &error); - if (present_query == NULL || error != NULL) { - _eglLog(_EGL_WARNING, "DRI3: failed to query Present version"); - free(present_query); - free(error); - return DRI2_EGL_DRIVER_FAILED; - } - - dri2_dpy->present_major_version = present_query->major_version; - dri2_dpy->present_minor_version = present_query->minor_version; - free(present_query); - - xfixes_query = xcb_xfixes_query_version_reply(dri2_dpy->conn, - xfixes_query_cookie, &error); - if (xfixes_query == NULL || error != NULL || - xfixes_query->major_version < 2) { - _eglLog(_EGL_WARNING, "DRI3: failed to query xfixes version"); - free(error); - free(xfixes_query); - return DRI2_EGL_DRIVER_FAILED; - } - free(xfixes_query); - dri2_dpy->fd_render_gpu = loader_dri3_open(dri2_dpy->conn, dri2_dpy->screen->root, 0); if (dri2_dpy->fd_render_gpu < 0) { int conn_error = xcb_connection_has_error(dri2_dpy->conn); - _eglLog(_EGL_WARNING, "DRI3: Screen seems not DRI3 capable"); + if (!swrast) { + _eglLog(_EGL_WARNING, "DRI3: Screen seems not DRI3 capable"); - if (conn_error) - _eglLog(_EGL_WARNING, "DRI3: Failed to initialize"); + if (conn_error) + _eglLog(_EGL_WARNING, "DRI3: Failed to initialize"); + } return DRI2_EGL_DRIVER_FAILED; } diff --git a/src/egl/drivers/dri2/platform_x11_dri3.h b/src/egl/drivers/dri2/platform_x11_dri3.h index ca3d12e4ae1..fdcc28a4e53 100644 --- a/src/egl/drivers/dri2/platform_x11_dri3.h +++ b/src/egl/drivers/dri2/platform_x11_dri3.h @@ -36,6 +36,6 @@ extern const __DRIimageLoaderExtension dri3_image_loader_extension; extern struct dri2_egl_display_vtbl dri3_x11_display_vtbl; enum dri2_egl_driver_fail -dri3_x11_connect(struct dri2_egl_display *dri2_dpy); +dri3_x11_connect(struct dri2_egl_display *dri2_dpy, bool swrast); #endif