mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 17:58:26 +02:00
egl/gbm: Walk device list to initialize DRM platform
We cannot always use /dev/dri/card0. As a matter of fact, on systems with SimpleDRM enabled /dev/dri/card0 will be created by it and removed once a GPU driver has loaded. In any case we shouldn't hard-code the device number and instead walk the device list to find the first suitable device. This issue is trivially reproducible with `eglinfo -B -p gbm` on Ubuntu 24.04 or Fedora 40 Fixes:32f4cf3808("egl/gbm: Fix EGL_DEFAULT_DISPLAY") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30325> (cherry picked from commit7949471716)
This commit is contained in:
parent
d54be8ef21
commit
ec61b755a4
2 changed files with 22 additions and 5 deletions
|
|
@ -1844,7 +1844,7 @@
|
|||
"description": "egl/gbm: Walk device list to initialize DRM platform",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "32f4cf38085e4056b8e4a9fc78fea28897a1d05f",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "egl_dri2.h"
|
||||
#include "egldevice.h"
|
||||
#include "eglglobals.h"
|
||||
#include "loader.h"
|
||||
|
||||
static struct gbm_bo *
|
||||
|
|
@ -581,10 +582,26 @@ dri2_initialize_drm(_EGLDisplay *disp)
|
|||
dri2_dpy->fd_display_gpu =
|
||||
loader_open_device(drm->nodes[DRM_NODE_PRIMARY]);
|
||||
} else {
|
||||
char buf[64];
|
||||
int n = snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, 0);
|
||||
if (n != -1 && n < sizeof(buf))
|
||||
dri2_dpy->fd_display_gpu = loader_open_device(buf);
|
||||
_EGLDevice *dev_list = _eglGlobal.DeviceList;
|
||||
drmDevicePtr drm;
|
||||
while (dev_list) {
|
||||
if (!_eglDeviceSupports(dev_list, _EGL_DEVICE_DRM))
|
||||
goto next;
|
||||
|
||||
drm = _eglDeviceDrm(dev_list);
|
||||
|
||||
if (!(drm->available_nodes & (1 << DRM_NODE_PRIMARY)))
|
||||
goto next;
|
||||
|
||||
dri2_dpy->fd_display_gpu =
|
||||
loader_open_device(drm->nodes[DRM_NODE_PRIMARY]);
|
||||
if (dri2_dpy->fd_display_gpu < 0)
|
||||
goto next;
|
||||
|
||||
break;
|
||||
next:
|
||||
dev_list = _eglDeviceNext(dev_list);
|
||||
}
|
||||
}
|
||||
|
||||
gbm = gbm_create_device(dri2_dpy->fd_display_gpu);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue