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 <stefan11111github@gmail.com>
This commit is contained in:
stefan11111 2026-06-09 14:44:46 +03:00 • committed by Enrico Weigelt
commit d482f4482b

View file

@ -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