From 2616b2b11eac26dfbb85926477a652d2a0540ef6 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Wed, 12 Jul 2023 20:11:32 -0500 Subject: [PATCH] build: make dmabuf-wayland a build option and require drm It makes more sense as an option at this point. Also libdrm is not optional at all. You have to get a drm format and modifier for this to even work (the VO will just fail without DRM). Just hard require it and remove the guards. vaapi can remain optional. --- meson.build | 20 ++++++++++++-------- meson_options.txt | 1 + video/out/vo_dmabuf_wayland.c | 8 +------- wscript | 10 +++++----- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/meson.build b/meson.build index 19448f44f6..8754a1b5e3 100644 --- a/meson.build +++ b/meson.build @@ -1013,6 +1013,18 @@ if features['wayland'] and features['memfd_create'] sources += files('video/out/vo_wlshm.c') endif +dmabuf_wayland = get_option('dmabuf-wayland').require( + features['drm'] and features['memfd_create'] and features['wayland'], + error_message: 'drm, memfd_create, or wayland was not found!', +) +features += {'dmabuf-wayland': dmabuf_wayland.allowed()} +if features['dmabuf-wayland'] + sources += files('video/out/vo_dmabuf_wayland.c') + sources += files('video/out/hwdec/dmabuf_interop_wl.c') + sources += files('video/out/wldmabuf/context_wldmabuf.c') + sources += files('video/out/wldmabuf/ra_wldmabuf.c') +endif + x11_opt = get_option('x11').require( get_option('gpl'), error_message: 'the build is not GPL!', @@ -1431,14 +1443,6 @@ if features['dmabuf-interop-pl'] sources += files('video/out/hwdec/dmabuf_interop_pl.c') endif -features += {'dmabuf-wayland' : features['wayland'] and features['memfd_create'] and (features['vaapi-wayland'] or features['drm'])} -if features['dmabuf-wayland'] - sources += files('video/out/vo_dmabuf_wayland.c') - sources += files('video/out/hwdec/dmabuf_interop_wl.c') - sources += files('video/out/wldmabuf/context_wldmabuf.c') - sources += files('video/out/wldmabuf/ra_wldmabuf.c') -endif - vdpau_opt = get_option('vdpau').require( features['x11'], error_message: 'x11 was not found!', diff --git a/meson_options.txt b/meson_options.txt index 65047b110f..5f2d31df3d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -58,6 +58,7 @@ option('caca', type: 'feature', value: 'auto', description: 'CACA') option('cocoa', type: 'feature', value: 'auto', description: 'Cocoa') option('d3d11', type: 'feature', value: 'auto', description: 'Direct3D 11 video output') option('direct3d', type: 'feature', value: 'auto', description: 'Direct3D support') +option('dmabuf-wayland', type: 'feature', value: 'auto', description: 'dmabuf-wayland video output') option('drm', type: 'feature', value: 'auto', description: 'DRM') option('egl', type: 'feature', value: 'auto', description: 'EGL 1.4') option('egl-android', type: 'feature', value: 'auto', description: 'Android EGL support') diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index e46dcadb47..269ddc2a3d 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -15,6 +15,7 @@ * License along with mpv. If not, see . */ +#include #include #include #include "config.h" @@ -22,9 +23,6 @@ #if HAVE_VAAPI #include #endif -#if HAVE_DRM -#include -#endif #include "common/global.h" #include "gpu/hwdec.h" @@ -192,19 +190,16 @@ done: static uintptr_t drmprime_surface_id(struct mp_image *src) { uintptr_t id = 0; -#if HAVE_DRM struct AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)src->planes[0]; AVDRMObjectDescriptor object = desc->objects[0]; id = (uintptr_t)object.fd; -#endif return id; } static void drmprime_dmabuf_importer(struct buffer *buf, struct mp_image *src, struct zwp_linux_buffer_params_v1 *params) { -#if HAVE_DRM int layer_no, plane_no; int max_planes = 0; const AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)src->planes[0]; @@ -227,7 +222,6 @@ static void drmprime_dmabuf_importer(struct buffer *buf, struct mp_image *src, plane.pitch, modifier >> 32, modifier & 0xffffffff); } } -#endif } static intptr_t surface_id(struct vo *vo, struct mp_image *src) diff --git a/wscript b/wscript index 758a9469ff..82f65b4afa 100644 --- a/wscript +++ b/wscript @@ -569,6 +569,11 @@ video_output_features = [ 'deps': 'wayland', 'func': check_statement('sys/mman.h', 'memfd_create("mpv", MFD_CLOEXEC | MFD_ALLOW_SEALING)') + }, { + 'name': '--dmabuf-wayland', + 'desc': 'dmabuf-wayland video output', + 'deps': 'wayland && memfd_create && drm', + 'func': check_true, } , { 'name': '--x11', 'desc': 'X11', @@ -696,11 +701,6 @@ video_output_features = [ 'desc': 'VAAPI (Wayland support)', 'deps': 'vaapi && gl-wayland', 'func': check_pkg_config('libva-wayland', '>= 1.1.0'), - }, { - 'name': 'dmabuf-wayland', - 'desc': 'Wayland dmabuf support', - 'deps': 'wayland && memfd_create && (vaapi-wayland || drm)', - 'func': check_true, }, { 'name': '--vaapi-drm', 'desc': 'VAAPI (DRM/EGL support)',