From a5b9d529eec8d4bb6fc858143337c3573ec8afd0 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Wed, 11 Jan 2023 16:39:59 -0600 Subject: [PATCH] vo_dmabuf_wayland: drop support for linux-dmabuf-v2 The only real reason this was ever supported is because it was dramatically simpler than v4, so it was put in as an initial implementation. Later, v4 support was added and we left v2 for compatibility, but let's just drop it. Compositors all use v4 nowadays, and v2 is significantly limited (no modifier support for example). It's better to just remove this dead code for simplicity. --- video/out/vo_dmabuf_wayland.c | 4 ++-- video/out/wayland_common.c | 29 ----------------------------- video/out/wayland_common.h | 4 ---- 3 files changed, 2 insertions(+), 35 deletions(-) diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index 6c0a00c088..4c0594911a 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -354,8 +354,8 @@ static int preinit(struct vo *vo) goto err; assert(p->ctx->ra); - if (!vo->wl->dmabuf) { - MP_FATAL(vo->wl, "Compositor doesn't support the %s protocol!\n", + if (!vo->wl->dmabuf || !vo->wl->dmabuf_feedback) { + MP_FATAL(vo->wl, "Compositor doesn't support the %s (ver. 4) protocol!\n", zwp_linux_dmabuf_v1_interface.name); goto err; } diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index dd233119a1..41f6ade83a 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1082,24 +1082,6 @@ static const struct wl_callback_listener frame_listener = { frame_callback, }; -static void dmabuf_format(void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf, - uint32_t format) -{ - struct vo_wayland_state *wl = data; - - if (wl->drm_format_ct == wl->drm_format_ct_max) { - wl->drm_format_ct_max *= 2; - wl->drm_formats = talloc_realloc(wl, wl->drm_formats, int, wl->drm_format_ct_max); - } - - wl->drm_formats[wl->drm_format_ct++] = format; - MP_VERBOSE(wl, "%s is supported by the compositor.\n", mp_tag_str(format)); -} - -static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = { - dmabuf_format -}; - #if HAVE_WAYLAND_PROTOCOLS_1_24 static void done(void *data, struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1) @@ -1190,11 +1172,6 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id wl->dmabuf_feedback = zwp_linux_dmabuf_v1_get_default_feedback(wl->dmabuf); zwp_linux_dmabuf_feedback_v1_add_listener(wl->dmabuf_feedback, &dmabuf_feedback_listener, wl); #endif - } else if (!strcmp (interface, zwp_linux_dmabuf_v1_interface.name) && (ver >= 2) && found++) { - wl->dmabuf = wl_registry_bind(reg, id, &zwp_linux_dmabuf_v1_interface, 2); - zwp_linux_dmabuf_v1_add_listener(wl->dmabuf, &dmabuf_listener, wl); - wl->drm_format_ct_max = 64; - wl->drm_formats = talloc_array(wl, int, wl->drm_format_ct_max); } if (!strcmp (interface, wp_viewporter_interface.name) && (ver >= 1) && found++) { @@ -2138,12 +2115,6 @@ bool vo_wayland_supported_format(struct vo *vo, uint32_t drm_format, uint64_t mo return true; } - /* TODO: remove these once zwp_linux_dmabuf_v1 version 2 support is removed. */ - for (int i = 0; i < wl->drm_format_ct; ++i) { - if (drm_format == wl->drm_formats[i]) - return true; - } - return false; } diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h index 4390b7927d..94a8f2c96a 100644 --- a/video/out/wayland_common.h +++ b/video/out/wayland_common.h @@ -94,10 +94,6 @@ struct vo_wayland_state { void *dmabuf_feedback; void *format_map; uint32_t format_size; - /* TODO: remove these once zwp_linux_dmabuf_v1 version 2 support is removed. */ - int *drm_formats; - int drm_format_ct; - int drm_format_ct_max; /* presentation-time */ struct wp_presentation *presentation;