From 1b4e877def1a93b7b6b2a2e22def2be5e140f5fe Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 13 Sep 2023 12:38:50 -0400 Subject: [PATCH] egl/wayland: use more registry listeners to better handle device init this handles globals like dmabuf and wl_drm and also enables creating egl devices with valid fds Acked-by: Daniel Stone Part-of: --- src/egl/drivers/dri2/platform_wayland.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 567b0ed..01a1ded 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -2657,6 +2657,16 @@ registry_handle_global_swrast(void *data, struct wl_registry *registry, if (strcmp(interface, wl_shm_interface.name) == 0) { dri2_dpy->wl_shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); wl_shm_add_listener(dri2_dpy->wl_shm, &shm_listener, dri2_dpy); + } else if (strcmp(interface, wl_drm_interface.name) == 0) { + dri2_dpy->wl_drm_version = MIN2(version, 2); + dri2_dpy->wl_drm_name = name; + } else if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0 && + version >= 3) { + dri2_dpy->wl_dmabuf = wl_registry_bind( + registry, name, &zwp_linux_dmabuf_v1_interface, + MIN2(version, ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK_SINCE_VERSION)); + zwp_linux_dmabuf_v1_add_listener(dri2_dpy->wl_dmabuf, &dmabuf_listener, + dri2_dpy); } } @@ -2743,14 +2753,6 @@ dri2_initialize_wayland_swrast(_EGLDisplay *disp) dri2_dpy->wl_dpy = disp->PlatformDisplay; } - dev = _eglFindDevice(dri2_dpy->fd_render_gpu, true); - if (!dev) { - _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice"); - goto cleanup; - } - - disp->Device = dev; - dri2_dpy->wl_queue = wl_display_create_queue(dri2_dpy->wl_dpy); dri2_dpy->wl_dpy_wrapper = wl_proxy_create_wrapper(dri2_dpy->wl_dpy); @@ -2775,6 +2777,17 @@ dri2_initialize_wayland_swrast(_EGLDisplay *disp) dri2_dpy->formats.num_formats)) goto cleanup; + if (disp->Options.Zink) + dri2_initialize_wayland_drm_extensions(dri2_dpy); + + dev = _eglFindDevice(dri2_dpy->fd_render_gpu, true); + if (!dev) { + _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice"); + goto cleanup; + } + + disp->Device = dev; + dri2_dpy->driver_name = strdup(disp->Options.Zink ? "zink" : "swrast"); if (!dri2_load_driver_swrast(disp)) goto cleanup; -- 2.7.4