Patches seem to be working for me. Performance on 4k compared to vaapi
is still rough. A few notes, I got the best performance when matching
the vulkan-queue-count and swapchain-depth to the queueCount value of the
compute queue in vulkaninfo. I also set gpu-context=x11vk in my
mpv.conf. I can't seem to get rid of the frequent or occassional:

[vo/gpu-next/libplacebo] Failed acquiring swapchain image: VK_TIMEOUT
depending on the values of swapchain-depth and vulkan-queue-count they
could be minimized (by setting to 1) but not eliminated in my testing. Setting
it to 1 also produced more dropped frames. Lastly we should note that
RADV_PERFTEST won't need to be set starting with Mesa 24.3.3. Thanks for
the update.


Using hardware decoding (vulkan).
AO: [sndio] 44100Hz stereo 2ch s16
VO: [gpu-next] 1920x1080 vulkan[nv12]


mpv --vulkan-device=help
Available vulkan devices:
  'AMD Radeon 780M (RADV GFX1103_R1)' (GPU 0, PCI ID 1002:15bf, UUID
00000000-c500-0000-0000-000000000000)


vulkaninfo | grep -A4 -i queueProperties
        queueProperties[0]:
        -------------------
                minImageTransferGranularity = (1,1,1)
                queueCount                  = 1
                queueFlags                  = QUEUE_GRAPHICS_BIT |
QUEUE_COMPUTE_BIT | QUEUE_TRANSFER_BIT | QUEUE_SPARSE_BINDING_BIT
--
        queueProperties[1]:
        -------------------
                minImageTransferGranularity = (1,1,1)
                queueCount                  = 4
                queueFlags                  = QUEUE_COMPUTE_BIT |
QUEUE_TRANSFER_BIT | QUEUE_SPARSE_BINDING_BIT
--
        queueProperties[2]:
        -------------------
                minImageTransferGranularity = (1,1,1)
                queueCount                  = 1
                queueFlags                  = QUEUE_VIDEO_DECODE_BIT_KHR



On Sat, May 24, 2025 at 04:10:22AM +0000, Lucas Gabriel Vuotto wrote:
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 <b...@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}"


--
All desire is the desire to be desired by the subject presumed to know.

Reply via email to