kdrive/fbdev: Prefer exact GL vendor match when choosing EGLDevices

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
stefan11111
2026-01-27 05:44:38 +02:00
committed by Enrico Weigelt
parent 125b7c5bef
commit 1f89bcfbdc

View File

@@ -178,9 +178,9 @@ fbdev_glamor_query_devices_ext(EGLDeviceEXT **devices, EGLint *num_devices)
}
static inline Bool
fbdev_glamor_egl_device_matches_config(EGLDeviceEXT device, Bool strict)
fbdev_glamor_egl_device_matches_config(EGLDeviceEXT device, int strict)
{
if (!strict) {
if (strict <= 0) {
return TRUE;
}
/**
@@ -204,6 +204,10 @@ fbdev_glamor_egl_device_matches_config(EGLDeviceEXT device, Bool strict)
return TRUE;
}
if (strict >= 2) {
return FALSE;
}
/**
* This is not specific to nvidia,
* but I don't know of any gl library vendors
@@ -233,19 +237,18 @@ fbdev_glamor_egl_init_display(FbdevScrPriv *scrpriv)
}
if (fbdev_glamor_query_devices_ext(&devices, &num_devices)) {
/* Try a strict match first */
for (uint32_t i = 0; i < num_devices; i++) {
if (fbdev_glamor_egl_device_matches_config(devices[i], TRUE)) {
GLAMOR_EGL_TRY_PLATFORM(EGL_PLATFORM_DEVICE_EXT, devices[i], TRUE);
}
#define GLAMOR_EGL_TRY_PLATFORM_DEVICE(strict) \
for (uint32_t i = 0; i < num_devices; i++) { \
if (fbdev_glamor_egl_device_matches_config(devices[i], strict)) { \
GLAMOR_EGL_TRY_PLATFORM(EGL_PLATFORM_DEVICE_EXT, devices[i], TRUE); \
} \
}
/* Try a try a less strict match now */
for (uint32_t i = 0; i < num_devices; i++) {
if (fbdev_glamor_egl_device_matches_config(devices[i], FALSE)) {
GLAMOR_EGL_TRY_PLATFORM(EGL_PLATFORM_DEVICE_EXT, devices[i], TRUE);
}
}
GLAMOR_EGL_TRY_PLATFORM_DEVICE(2);
GLAMOR_EGL_TRY_PLATFORM_DEVICE(1);
GLAMOR_EGL_TRY_PLATFORM_DEVICE(0);
#undef GLAMOR_EGL_TRY_PLATFORM_DEVICE
}
GLAMOR_EGL_TRY_PLATFORM(EGL_PLATFORM_SURFACELESS_MESA, EGL_DEFAULT_DISPLAY, FALSE);
@@ -266,6 +269,7 @@ fbdev_glamor_egl_init_display(FbdevScrPriv *scrpriv)
#undef GLAMOR_EGL_TRY_PLATFORM
free(devices);
return FALSE;
}