[FFmpeg-devel] [PATCH 3/8] lavu: add a Vulkan hwcontext

Rostislav Pehlivanov atomnuker at gmail.com
Sat Apr 21 06:46:13 EEST 2018


On 20 April 2018 at 05:30, Rostislav Pehlivanov <atomnuker at gmail.com> wrote:

> This commit adds a Vulkan hwcontext, currently capable of mapping DRM and
> VAAPI frames but additional functionality can be added later to support
> importing of D3D11 surfaces as well as exporting to various other APIs.
>
> This context requires the newest stable version of the Vulkan API,
> and once the new extension for DRM surfaces makes it in will also require
> it (in order to properly and fully import them).
>
> It makes use of every part of the Vulkan spec in order to ensure fastest
> possible uploading, downloading and mapping of frames. On AMD, it will
> also make use of mapping host memory frames in order to upload
> very efficiently and with minimal CPU to hardware.
>
> To be useful for non-RGB images an implementation with the YUV images
> extension is needed. All current implementations support that with the
> exception of AMD, though support is coming soon for Mesa.
>
> Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
> ---
>  configure                      |   12 +
>  doc/APIchanges                 |    3 +
>  libavutil/Makefile             |    3 +
>  libavutil/hwcontext.c          |    4 +
>  libavutil/hwcontext.h          |    1 +
>  libavutil/hwcontext_internal.h |    1 +
>  libavutil/hwcontext_vulkan.c   | 2125 ++++++++++++++++++++++++++++++++
>  libavutil/hwcontext_vulkan.h   |  133 ++
>  libavutil/pixdesc.c            |    4 +
>  libavutil/pixfmt.h             |    4 +
>  libavutil/version.h            |    2 +-
>  11 files changed, 2291 insertions(+), 1 deletion(-)
>  create mode 100644 libavutil/hwcontext_vulkan.c
>  create mode 100644 libavutil/hwcontext_vulkan.h
>
> diff --git a/configure b/configure
> index dee507cb6a..cd88f7eae1 100755
> --- a/configure
> +++ b/configure
> @@ -297,6 +297,7 @@ External library support:
>    --enable-opengl          enable OpenGL rendering [no]
>    --enable-openssl         enable openssl, needed for https support
>                             if gnutls or libtls is not used [no]
> +  --enable-vulkan          enable Vulkan code [no]
>    --disable-sndio          disable sndio support [autodetect]
>    --disable-schannel       disable SChannel SSP, needed for TLS support on
>                             Windows if openssl and gnutls are not used
> [autodetect]
> @@ -1761,6 +1762,7 @@ HWACCEL_LIBRARY_LIST="
>      mmal
>      omx
>      opencl
> +    vulkan
>  "
>
>  DOCUMENT_LIST="
> @@ -2217,6 +2219,7 @@ HAVE_LIST="
>      opencl_dxva2
>      opencl_vaapi_beignet
>      opencl_vaapi_intel_media
> +    vulkan_drm_mod
>      perl
>      pod2man
>      texi2html
> @@ -6322,6 +6325,15 @@ enabled vdpau &&
>
>  enabled crystalhd && check_lib crystalhd "stdint.h
> libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
>
> +enabled vulkan &&
> +    check_lib vulkan "vulkan/vulkan.h" vkCreateInstance -lvulkan &&
> +    check_cpp_condition vulkan vulkan/vulkan.h "defined
> VK_API_VERSION_1_1"
> +
> +if enabled_all vulkan libdrm ; then
> +    check_cpp_condition vulkan vulkan/vulkan.h "defined
> VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME"
> +        enable vulkan_drm_mod
> +fi


If anyone's wanting to test this keep in mind there's a mistake here, it
should be VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME and not
VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME. I have it on good authority
the spec will get changed soon so this check will be gone.
Also a change from the WIP patch is this supports forward mapping to DRM.


More information about the ffmpeg-devel mailing list