[FFmpeg-devel] [PATCH v4 4/8] lavfi: add common Vulkan filtering code

James Almer jamrial at gmail.com
Wed May 23 07:44:29 EEST 2018


On 5/22/2018 1:28 AM, Rostislav Pehlivanov wrote:
> This commit adds a common code for use in Vulkan filters. It attempts
> to ease the burden of writing Vulkan image filtering to a minimum,
> which is pretty much a requirement considering how verbose the API is.
> 
> It supports both compute and graphic pipelines and manages to abstract
> the API to such a level there's no need to call any Vulkan functions
> inside the init path of the code. Handling shader descriptors is probably
> the bulk of the code, and despite the abstraction, it loses none of the
> features for describing shader IO.
> 
> In order to produce linkable shaders, it depends on the libshaderc
> library (and depends on the latest stable version of it). This allows
> for greater performance and flexibility than static built-in shaders
> and also eliminates the cumbersome process of interfacing with glslang
> to compile GLSL to SPIR-V.
> 
> It's based off of the common opencl and provides similar interfaces for
> filter pad init and config, with the addition that it also supports
> in-place filtering.
> 
> Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
> ---
>  configure            |   12 +-
>  libavfilter/vulkan.c | 1190 ++++++++++++++++++++++++++++++++++++++++++
>  libavfilter/vulkan.h |  223 ++++++++
>  3 files changed, 1423 insertions(+), 2 deletions(-)
>  create mode 100644 libavfilter/vulkan.c
>  create mode 100644 libavfilter/vulkan.h
> 
> diff --git a/configure b/configure
> index 5f4407b753..abcfe32625 100755
> --- a/configure
> +++ b/configure
> @@ -252,6 +252,7 @@ External library support:
>    --enable-librsvg         enable SVG rasterization via librsvg [no]
>    --enable-librubberband   enable rubberband needed for rubberband filter [no]
>    --enable-librtmp         enable RTMP[E] support via librtmp [no]
> +  --enable-libshaderc      enable GLSL->SPIRV compilation via libshaderc [no]
>    --enable-libshine        enable fixed-point MP3 encoding via libshine [no]
>    --enable-libsmbclient    enable Samba protocol via libsmbclient [no]
>    --enable-libsnappy       enable Snappy compression, needed for hap encoding [no]
> @@ -1707,6 +1708,7 @@ EXTERNAL_LIBRARY_LIST="
>      libpulse
>      librsvg
>      librtmp
> +    libshaderc
>      libshine
>      libsmbclient
>      libsnappy
> @@ -2225,6 +2227,7 @@ HAVE_LIST="
>      opencl_dxva2
>      opencl_vaapi_beignet
>      opencl_vaapi_intel_media
> +    shaderc_opt_perf
>      vulkan_drm_mod
>      perl
>      pod2man
> @@ -3456,12 +3459,12 @@ avcodec_select="null_bsf"
>  avdevice_deps="avformat avcodec avutil"
>  avdevice_suggest="libm"
>  avfilter_deps="avutil"
> -avfilter_suggest="libm"
> +avfilter_suggest="libm libshaderc"

If libavfiler/vulkan.c (which i assume uses libshaderc methods) is only
going to be built if one or more of the filters is also built, then this
is unnecessary. The libshaderc dep on each filter is enough.

>  avformat_deps="avcodec avutil"
>  avformat_suggest="libm network zlib"
>  avresample_deps="avutil"
>  avresample_suggest="libm"
> -avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi videotoolbox corefoundation corevideo coremedia bcrypt"
> +avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl vulkan user32 vaapi videotoolbox corefoundation corevideo coremedia bcrypt"

This one belongs in patch 3/8, otherwise hwcontext_vulkan will fail to link.

>  postproc_deps="avutil gpl"
>  postproc_suggest="libm"
>  swresample_deps="avutil"
> @@ -6050,6 +6053,7 @@ enabled libpulse          && require_pkg_config libpulse libpulse pulse/pulseaud
>  enabled librsvg           && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
>  enabled librtmp           && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket
>  enabled librubberband     && require_pkg_config librubberband "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append librubberband_extralibs "-lstdc++"
> +enabled libshaderc        && require libshaderc shaderc/shaderc.h shaderc_compiler_initialize -lshaderc_shared
>  enabled libshine          && require_pkg_config libshine shine shine/layer3.h shine_encode_buffer
>  enabled libsmbclient      && { check_pkg_config libsmbclient smbclient libsmbclient.h smbc_init ||
>                                 require libsmbclient libsmbclient.h smbc_init -lsmbclient; }
> @@ -6355,6 +6359,10 @@ enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.
>  enabled vulkan &&
>      require_pkg_config vulkan "vulkan >= 1.1.73" "vulkan/vulkan.h" vkCreateInstance
>  
> +if enabled_all vulkan libshaderc ; then
> +    check_cc shaderc_opt_perf shaderc/shaderc.h "int t = shaderc_optimization_level_performance"
> +fi
> +
>  if enabled_all vulkan libdrm ; then
>      check_cpp_condition vulkan_drm_mod vulkan/vulkan.h "defined VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME"
>  fi

Should be good otherwise.


More information about the ffmpeg-devel mailing list