Skip to content

Commit 6af46c0

Browse files
committed
kdrive/fbdev: Set glvnd vendor even if not explicitly given by the user
This makes it so that glamor glx can properly initialize even if no glvnd vendor was given explicitly. This commit and 6b4f7ba fix the issue described in #1832 (comment) Now, `FBConfig`s corresponding to the choosen accelerated `EGLDevice` are choosen by `glXChooseFBConfig`. Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
1 parent 6b4f7ba commit 6af46c0

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

hw/kdrive/fbdev/fb_glamor.c

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,26 @@ fbdev_glamor_query_devices_ext(EGLDeviceEXT **devices, EGLint *num_devices)
168168
return TRUE;
169169
}
170170

171+
/**
172+
* Find the desired EGLDevice for our config.
173+
*
174+
* If strict == 2, we are looking for EGLDevices with names and,
175+
* if a glvnd vendor was passed, an exact match between the
176+
* device's name, and the desired vendor.
177+
*
178+
* If strict == 1, we are looking for EGLDevices with names and,
179+
* if a glvnd vendor was passed, a match between the gl vendor library
180+
* provider and the desired vendor's library.
181+
*
182+
* If strict == 0, we accept all devices, even those with no names.
183+
*
184+
* Regardless of success/failure, and regardless of strictness level,
185+
* we save the statically allocated string with the EGLDevice's name
186+
* in *out_driver_name, even if that name is NULL.
187+
*/
171188
static inline Bool
172-
fbdev_glamor_egl_device_matches_config(EGLDeviceEXT device, int strict)
189+
fbdev_glamor_egl_device_matches_config(EGLDeviceEXT device, int strict, const char** out_driver_name)
173190
{
174-
if (strict <= 0 || !fbdev_glvnd_provider) {
175-
return TRUE;
176-
}
177191
/**
178192
* For some reason, this isn't part of the epoxy headers.
179193
* It is part of EGL/eglext.h, but we can't include that
@@ -187,10 +201,20 @@ fbdev_glamor_egl_device_matches_config(EGLDeviceEXT device, int strict)
187201
#endif
188202

189203
const char *driver_name = eglQueryDeviceStringEXT(device, EGL_DRIVER_NAME_EXT);
204+
*out_driver_name = driver_name;
205+
206+
if (strict <= 0) {
207+
return TRUE;
208+
}
209+
190210
if (!driver_name) {
191211
return FALSE;
192212
}
193213

214+
if (!fbdev_glvnd_provider) {
215+
return TRUE;
216+
}
217+
194218
if (!strcmp(driver_name, fbdev_glvnd_provider)) {
195219
return TRUE;
196220
}
@@ -216,10 +240,16 @@ fbdev_glamor_egl_init_display(FbdevScrPriv *scrpriv)
216240
EGLDeviceEXT *devices = NULL;
217241
EGLint num_devices = 0;
218242

243+
/* Statically allocated according to EGL_EXT_device_persistent_id */
244+
const char *driver_name = NULL;
245+
219246
#define GLAMOR_EGL_TRY_PLATFORM(platform, native, platform_fallback) \
220247
scrpriv->display = glamor_egl_get_display2(platform, native, platform_fallback); \
221248
if (scrpriv->display != EGL_NO_DISPLAY) { \
222249
if (eglInitialize(scrpriv->display, NULL, NULL)) { \
250+
if (driver_name) { \
251+
fbdev_glvnd_provider = driver_name; \
252+
} \
223253
free(devices); \
224254
return TRUE; \
225255
} \
@@ -230,7 +260,7 @@ fbdev_glamor_egl_init_display(FbdevScrPriv *scrpriv)
230260
if (fbdev_glamor_query_devices_ext(&devices, &num_devices)) {
231261
#define GLAMOR_EGL_TRY_PLATFORM_DEVICE(strict) \
232262
for (uint32_t i = 0; i < num_devices; i++) { \
233-
if (fbdev_glamor_egl_device_matches_config(devices[i], strict)) { \
263+
if (fbdev_glamor_egl_device_matches_config(devices[i], strict, &driver_name)) { \
234264
GLAMOR_EGL_TRY_PLATFORM(EGL_PLATFORM_DEVICE_EXT, devices[i], TRUE); \
235265
} \
236266
}

0 commit comments

Comments
 (0)