Index | Thread | Search

From:
Lucas Gabriel Vuotto <lucas@sexy.is>
Subject:
Re: graphics/ffmpeg: enable Vulkan support
To:
ports@openbsd.org
Date:
Sat, 24 May 2025 04:10:22 +0000

Download raw body.

Thread
On Mon, May 19, 2025 at 08:46:53AM +0000, Lucas Gabriel Vuotto wrote:
> Hi Brad, ports,
> 
> The following enables Vulkan support in FFmpeg. With this, and some
> special environment variables, I'm able to use mpv with Vulkan-backed
> accelerated decoding, which in particular means that there is support
> for AMD-based accelerated video decoding.
> 
> There isn't anything out of the ordinary in the patch, with the
> exception of some reordering of lines to keep things sorted, and I
> also took the chance to add a missing LDEP on devel/fribidi.
> 
> To test this with mpv, please follow the instructions at [0]. In
> particular, the environment variables listed (ANV_VIDEO_DECODE,
> RADV_PERFTEST) are required for our Mesa to enable access to the
> decoding APIs. In order to detect support for accelerated decoding
> capabilities, set the corresponding environment variable and run
> `vulkaninfo | grep -i video`. `vulkaninfo` is part of vulkan-tools pkg.
> 
> [0]: https://github.com/mpv-player/mpv/discussions/13909#discussion-6516065
> 
> OK?

Rebased patch below.


diff refs/heads/master bf9462a6f5a958cb527b7e2a85a768063e155104
commit - e9e3d90e362acd0eeabc82a6c838916cf6616221
commit + bf9462a6f5a958cb527b7e2a85a768063e155104
blob - 571aeabff4dd3fa4cce0e41a46043d3fa396a66b
blob + c35023b55c6116f8b1234ee587bc398e374209a8
--- graphics/ffmpeg/Makefile
+++ graphics/ffmpeg/Makefile
@@ -2,7 +2,7 @@ COMMENT=	audio/video converter and streamer
 
 V=		6.1.2
 DISTNAME=	ffmpeg-${V}
-REVISION=	3
+REVISION=	4
 EPOCH=		1
 CATEGORIES=	graphics multimedia
 SITES=		https://ffmpeg.org/releases/
@@ -27,20 +27,24 @@ MAINTAINER=	Brad Smith <brad@comstyle.com>
 PERMIT_PACKAGE=	Yes
 
 WANTLIB += SDL2 X11 Xext Xv aom ass bz2 c crypto dav1d fontconfig
-WANTLIB += freetype fribidi gsm harfbuzz iconv lzma m mp3lame opus
+WANTLIB += freetype fribidi glslang gsm harfbuzz iconv lzma m mp3lame opus
 WANTLIB += pthread sndio speex ssl theoradec theoraenc v4l2 va
 WANTLIB += va-drm va-x11 vidstab vorbis vorbisenc vpx webp webpmux
 WANTLIB += x264 x265 xcb xcb-shape xcb-shm xcb-xfixes xml2 xvidcore
 WANTLIB += z zimg
 
+# dlopen
+WANTLIB += vulkan
+
 COMPILER=	base-clang ports-gcc
 COMPILER_LANGS=	c
 
 DEBUG_PACKAGES=	${BUILD_PACKAGES}
 
 BUILD_DEPENDS=	audio/ladspa \
-		textproc/texi2html \
-		multimedia/frei0r-plugins
+		graphics/vulkan-headers \
+		multimedia/frei0r-plugins \
+		textproc/texi2html
 .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
 BUILD_DEPENDS+=	devel/nasm
 .endif
@@ -55,7 +59,9 @@ LIB_DEPENDS=	archivers/bzip2 \
 		devel/fribidi \
 		devel/harfbuzz \
 		devel/sdl2 \
+		graphics/glslang \
 		graphics/libwebp \
+		graphics/vulkan-loader \
 		graphics/zimg \
 		multimedia/aom \
 		multimedia/dav1d \
@@ -79,7 +85,7 @@ LIBavdevice_EXTRALIBS=-L${LOCALBASE}/lib -L${X11BASE}/
 LIBavdevice_EXTRALIBS+=-lxcb-shape -lxcb-shm -lxcb-xfixes -lxcb -lsndio -lv4l2 -lm
 
 LIBavfilter_EXTRALIBS=-L${LOCALBASE}/lib -L${X11BASE}/lib -lass -lfontconfig
-LIBavfilter_EXTRALIBS+=-lfreetype -lfribidi -lharfbuzz -lvidstab
+LIBavfilter_EXTRALIBS+=-lfreetype -lfribidi -lglslang -lharfbuzz -lvidstab
 LIBavfilter_EXTRALIBS+=-lm -lz -lzimg -lva -pthread
 
 LIBavformat_EXTRALIBS=-L${LOCALBASE}/lib -lbz2 -lxml2 -lssl -lcrypto -lm -lz
@@ -111,7 +117,6 @@ CONFIGURE_ARGS+=--enable-shared \
 		--disable-stripping \
 		--disable-indev=jack \
 		--disable-outdev=sdl2 \
-		--disable-vulkan \
 		--enable-fontconfig \
 		--enable-frei0r \
 		--enable-gpl \
@@ -122,6 +127,7 @@ CONFIGURE_ARGS+=--enable-shared \
 		--enable-libfontconfig \
 		--enable-libfreetype \
 		--enable-libfribidi \
+		--enable-libglslang \
 		--enable-libgsm \
 		--enable-libharfbuzz \
 		--enable-libmp3lame \
@@ -129,6 +135,7 @@ CONFIGURE_ARGS+=--enable-shared \
 		--enable-libspeex \
 		--enable-libtheora \
 		--enable-libv4l2 \
+		--enable-libvidstab \
 		--enable-libvorbis \
 		--enable-libvpx \
 		--enable-libwebp \
@@ -139,7 +146,7 @@ CONFIGURE_ARGS+=--enable-shared \
 		--enable-libzimg \
 		--enable-nonfree \
 		--enable-openssl \
-		--enable-libvidstab \
+		--enable-vulkan \
 		--extra-cflags="-I${LOCALBASE}/include -I${X11BASE}/include" \
 		--extra-libs="-L${LOCALBASE}/lib -L${X11BASE}/lib" \
 		--extra-ldsoflags="${LDLIBFLAGS}" \
blob - fa16df99b92aa9200c8b4a978cbaff238bcb8723
blob + e79718b368b29605f2383da5c3cdf2051d35f7fe
--- graphics/ffmpeg/patches/patch-configure
+++ graphics/ffmpeg/patches/patch-configure
@@ -6,6 +6,10 @@
 
 - Fix broken libatomic test
 
+- Fix libglslang support detection, as our libglslang doesn't provide
+  some deprecated .so stubs (HSLS, OGLCompiler, MachineIndependent,
+  OSDependent, SPIRV, GenericCodeGen), and remove unneeded libs
+
 Index: configure
 --- configure.orig
 +++ configure
@@ -91,7 +95,21 @@ Index: configure
      check_builtin stdatomic stdatomic.h                                                 \
          "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar"  \
          $LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
-@@ -7748,6 +7759,7 @@ if enabled ppc; then
+@@ -6715,11 +6726,9 @@ enabled libfreetype       && require_pkg_config libfre
+ enabled libfribidi        && require_pkg_config libfribidi fribidi fribidi.h fribidi_version_info
+ enabled libharfbuzz       && require_pkg_config libharfbuzz harfbuzz hb.h hb_buffer_create
+ enabled libglslang && { check_lib spirv_compiler glslang/Include/glslang_c_interface.h glslang_initialize_process \
+-                            -lglslang -lMachineIndependent -lOSDependent -lHLSL -lOGLCompiler -lGenericCodeGen \
+-                            -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV-Tools -lpthread -lstdc++ -lm ||
++                            -lglslang -lpthread -lstdc++ -lm ||
+                         require spirv_compiler glslang/Include/glslang_c_interface.h glslang_initialize_process \
+-                            -lglslang -lOSDependent -lHLSL -lOGLCompiler \
+-                            -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV-Tools -lpthread -lstdc++ -lm; }
++                            -lglslang -lpthread -lstdc++ -lm; }
+ enabled libgme            && { check_pkg_config libgme libgme gme/gme.h gme_new_emu ||
+                                require libgme gme/gme.h gme_new_emu -lgme -lstdc++; }
+ enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
+@@ -7748,6 +7757,7 @@ if enabled ppc; then
      echo "POWER8 enabled            ${power8-no}"
      echo "PPC 4xx optimizations     ${ppc4xx-no}"
      echo "dcbzl available           ${dcbzl-no}"