wsi/wayland: Use wl_fixes to destroy wl_registry

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29140>
This commit is contained in:
Ian Douglas Scott 2024-05-10 11:57:22 -07:00 committed by Marge Bot
parent 3d4792d577
commit 6641c891fd
4 changed files with 53 additions and 4 deletions

View file

@ -55,6 +55,7 @@ struct wl_drm;
struct wl_registry;
struct wl_shm;
struct wl_surface;
struct wl_fixes;
struct zwp_linux_dmabuf_v1;
struct zwp_linux_dmabuf_feedback_v1;
#endif
@ -279,6 +280,7 @@ struct dri2_egl_display {
#endif
struct wl_shm *wl_shm;
struct wl_event_queue *wl_queue;
struct wl_fixes *wl_fixes;
struct zwp_linux_dmabuf_v1 *wl_dmabuf;
struct wp_presentation *wp_presentation;
struct dri2_wl_formats formats;

View file

@ -2312,6 +2312,10 @@ registry_handle_global_drm(void *data, struct wl_registry *registry,
wl_registry_bind(registry, name, &wp_presentation_interface, 1);
wp_presentation_add_listener(dri2_dpy->wp_presentation,
&presentation_listener, dri2_dpy);
#ifdef WL_FIXES_INTERFACE
} else if (strcmp(interface, wl_fixes_interface.name) == 0) {
dri2_dpy->wl_fixes = wl_registry_bind(registry, name, &wl_fixes_interface, 1);
#endif
}
}
@ -3150,6 +3154,10 @@ registry_handle_global_swrast(void *data, struct wl_registry *registry,
wl_registry_bind(registry, name, &wp_presentation_interface, 1);
wp_presentation_add_listener(dri2_dpy->wp_presentation,
&presentation_listener, dri2_dpy);
#ifdef WL_FIXES_INTERFACE
} else if (strcmp(interface, wl_fixes_interface.name) == 0) {
dri2_dpy->wl_fixes = wl_registry_bind(registry, name, &wl_fixes_interface, 1);
#endif
}
}
@ -3294,8 +3302,17 @@ dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy)
zwp_linux_dmabuf_v1_destroy(dri2_dpy->wl_dmabuf);
if (dri2_dpy->wl_shm)
wl_shm_destroy(dri2_dpy->wl_shm);
if (dri2_dpy->wl_registry)
if (dri2_dpy->wl_registry) {
#ifdef WL_FIXES_INTERFACE
if (dri2_dpy->wl_fixes)
wl_fixes_destroy_registry(dri2_dpy->wl_fixes, dri2_dpy->wl_registry);
#endif
wl_registry_destroy(dri2_dpy->wl_registry);
}
#ifdef WL_FIXES_INTERFACE
if (dri2_dpy->wl_fixes)
wl_fixes_destroy(dri2_dpy->wl_fixes);
#endif
if (dri2_dpy->wl_dpy_wrapper)
wl_proxy_wrapper_destroy(dri2_dpy->wl_dpy_wrapper);
if (dri2_dpy->wl_queue)

View file

@ -41,6 +41,7 @@ struct device_select_wayland_info {
struct zwp_linux_dmabuf_v1 *wl_dmabuf;
struct zwp_linux_dmabuf_feedback_v1 *wl_dmabuf_feedback;
struct wl_fixes *wl_fixes;
drmDevicePtr dmabuf_dev_info;
};
@ -168,13 +169,17 @@ device_select_registry_global(void *data, struct wl_registry *registry, uint32_t
wl_drm_add_listener(info->wl_drm, &ds_drm_listener, data);
} else
#endif
if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0 &&
version >= ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK_SINCE_VERSION) {
if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0 &&
version >= ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK_SINCE_VERSION) {
info->wl_dmabuf = wl_registry_bind(registry, name, &zwp_linux_dmabuf_v1_interface,
ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK_SINCE_VERSION);
info->wl_dmabuf_feedback = zwp_linux_dmabuf_v1_get_default_feedback(info->wl_dmabuf);
zwp_linux_dmabuf_feedback_v1_add_listener(info->wl_dmabuf_feedback, &dmabuf_feedback_listener,
data);
#ifdef WL_FIXES_INTERFACE
} else if (strcmp(interface, wl_fixes_interface.name) == 0) {
info->wl_fixes = wl_registry_bind(registry, name, &wl_fixes_interface, 1);
#endif
}
}
@ -255,6 +260,12 @@ done:
if (info.wl_drm)
wl_drm_destroy(info.wl_drm);
#endif
#ifdef WL_FIXES_INTERFACE
if (info.wl_fixes) {
wl_fixes_destroy_registry(info.wl_fixes, registry);
wl_fixes_destroy(info.wl_fixes);
}
#endif
wl_registry_destroy(registry);
wl_display_disconnect(display);

View file

@ -104,6 +104,7 @@ struct wsi_wl_display {
/* Actually a proxy wrapper around the event queue */
struct wl_display *wl_display_wrapper;
struct wl_event_queue *queue;
struct wl_fixes *wl_fixes;
struct wl_shm *wl_shm;
struct zwp_linux_dmabuf_v1 *wl_dmabuf;
@ -1458,6 +1459,11 @@ registry_handle_global(void *data, struct wl_registry *registry,
} else if (strcmp(interface, wp_linux_drm_syncobj_manager_v1_interface.name) == 0) {
display->wl_syncobj =
wl_registry_bind(registry, name, &wp_linux_drm_syncobj_manager_v1_interface, 1);
#ifdef WL_FIXES_INTERFACE
} else if (strcmp(interface, wl_fixes_interface.name) == 0) {
display->wl_fixes =
wl_registry_bind(registry, name, &wl_fixes_interface, 1);
#endif
}
}
@ -1516,6 +1522,10 @@ wsi_wl_display_finish(struct wsi_wl_display *display)
u_vector_finish(&display->color_primaries);
u_vector_finish(&display->color_transfer_funcs);
#ifdef WL_FIXES_INTERFACE
if (display->wl_fixes)
wl_fixes_destroy(display->wl_fixes);
#endif
if (display->wl_shm)
wl_shm_destroy(display->wl_shm);
if (display->wl_syncobj)
@ -1647,6 +1657,10 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl,
out:
/* We don't need this anymore */
#ifdef WL_FIXES_INTERFACE
if (display->wl_fixes)
wl_fixes_destroy_registry(display->wl_fixes, registry);
#endif
wl_registry_destroy(registry);
/* Destroy default dma-buf feedback object and format table */
@ -1659,8 +1673,13 @@ out:
return VK_SUCCESS;
fail_registry:
if (registry)
if (registry) {
#ifdef WL_FIXES_INTERFACE
if (display->wl_fixes)
wl_fixes_destroy_registry(display->wl_fixes, registry);
#endif
wl_registry_destroy(registry);
}
fail:
wsi_wl_display_finish(display);