From d482f4482b5aa8dfc8a83547cfa9660c0624d0fe Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Tue, 9 Jun 2026 14:44:46 +0300 Subject: [PATCH] glamor/glamor_egl: Set gl vendor to "nvidia" by default for nvidia cards Also pick an `EGLDeviceEXT` suitable for nvidia's gl library. For nvidia 470 and below, there isn't an official gbm backend. If the dumb backend is used, we can't initialze on the gbm platform. If the mesa backend is used, we can initialize on the gbm platform, but if we do, we risk EGL internally picking the wrong `EGLDeviceEXT` See: https://github.com/X11Libre/xserver/pull/2847 Signed-off-by: stefan11111 --- glamor/glamor_egl.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 234b368386..3f16087c56 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -1597,6 +1597,24 @@ glamor_egl_set_glvnd_vendor(ScreenPtr screen) return; } +/** + * If we're on nvidia and the user didn't request a particular gl vendor, set it to nvidia. + * See: https://github.com/X11Libre/xserver/pull/2847 + */ +#ifdef WITH_LIBDRM + if (glamor_egl->fd >= 0) { + drmVersionPtr version = drmGetVersion(glamor_egl->fd); + if (version) { + if (version->name && !strcmp(version->name, "nvidia-drm")) { + drmFreeVersion(version); + glamor_set_glvnd_vendor(screen, "nvidia"); + return; + } + drmFreeVersion(version); + } + } +#endif + #ifdef GLAMOR_HAS_GBM if (glamor_egl->gbm) { const char *gbm_backend_name; @@ -2218,6 +2236,22 @@ glamor_egl_init_display(glamor_egl_priv_t *glamor_egl, int *dri_fd, int *out_pla #define EGL_PLATFORM_GBM_KHR 0x31D7 #endif +/** + * If we're on nvidia and the user didn't request a particular gl vendor, set it to nvidia. + * See: https://github.com/X11Libre/xserver/pull/2847 + */ +#ifdef WITH_LIBDRM + if (!glamor_egl->glvnd_vendor && (glamor_egl->fd >= 0)) { + drmVersionPtr version = drmGetVersion(glamor_egl->fd); + if (version) { + if (version->name && !strcmp(version->name, "nvidia-drm")) { + glamor_egl->glvnd_vendor = strdup("nvidia"); + } + drmFreeVersion(version); + } + } +#endif + /** * If the user didn't give us a GL driver/library name, * we populate it with what we queried