From 89c327f2632f3e54ee9a6cd8a5443aa0e878a04a Mon Sep 17 00:00:00 2001 From: Erik Kurzinger Date: Mon, 4 Mar 2024 17:11:59 +0100 Subject: [PATCH] xwayland: add detection for drivers that don't support implicit sync Signed-off-by: Erik Kurzinger Part-of: --- hw/xwayland/xwayland-glamor-gbm.c | 19 ++++++++++++++++++- hw/xwayland/xwayland-glamor.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 7cd4a6806..b22e89248 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -62,6 +62,7 @@ struct xwl_gbm_private { Bool drm_authenticated; Bool dmabuf_capable; Bool glamor_gles; + Bool implicit_sync; /* Set if wl_drm is available */ struct wl_drm *drm; @@ -1020,6 +1021,14 @@ xwl_glamor_gbm_has_egl_extension(void) epoxy_has_egl_extension(NULL, "EGL_KHR_platform_gbm")); } +Bool +xwl_glamor_supports_implicit_sync(struct xwl_screen *xwl_screen) +{ + /* absent glamor, implicit sync is irrelevant so just return TRUE */ + return !xwl_screen->glamor || + xwl_gbm_get(xwl_screen)->implicit_sync; +} + static Bool xwl_glamor_try_to_make_context_current(struct xwl_screen *xwl_screen) { @@ -1164,7 +1173,7 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen) struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); EGLint major, minor; const GLubyte *renderer; - const char *gbm_backend_name; + const char *gbm_backend_name, *egl_vendor; if (!xwl_gbm->drm && !xwl_glamor_gbm_init_main_dev(xwl_screen)) return FALSE; @@ -1229,6 +1238,14 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen) xwl_screen->glvnd_vendor = gbm_backend_name; xwl_gbm->glamor_gles = !epoxy_is_desktop_gl(); + egl_vendor = eglQueryString(xwl_screen->egl_display, EGL_VENDOR); + if (!egl_vendor) { + ErrorF("Could not determine EGL vendor\n"); + goto error; + } + /* NVIDIA driver does not support implicit sync */ + xwl_gbm->implicit_sync = !strstr(egl_vendor, "NVIDIA"); + return TRUE; error: if (xwl_screen->egl_display != EGL_NO_DISPLAY) { diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h index 297ae1786..ff019feda 100644 --- a/hw/xwayland/xwayland-glamor.h +++ b/hw/xwayland/xwayland-glamor.h @@ -57,6 +57,7 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen, void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen); Bool xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap); PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window); +Bool xwl_glamor_supports_implicit_sync(struct xwl_screen *xwl_screen); #ifdef XV /* glamor Xv Adaptor */