hwdec_vulkan: add Vulkan HW Interop

Vulkan Video Decoding has finally become a reality, as it's now
showing up in shipping drivers, and the ffmpeg support has been
merged.

With that in mind, this change introduces HW interop support for
ffmpeg Vulkan frames. The implementation is functionally complete - it
can display frames produced by hardware decoding, and it can work with
ffmpeg vulkan filters. There are still various caveats due to gaps and
bugs in drivers, so YMMV, as always.

Primary testing has been done on Intel, AMD, and nvidia hardware on
Linux with basic Windows testing on nvidia.

Notable caveats:
* Due to driver bugs, video decoding on nvidia does not work right now,
  unless you use the Vulkan Beta driver. It can be worked around, but
  requires ffmpeg changes that are not considered acceptable to merge.
* Even if those work-arounds are applied, Vulkan filters will not work
  on video that was decoded by Vulkan, due to additional bugs in the
  nvidia drivers. The filters do work correctly on content decoded some
  other way, and then uploaded to Vulkan (eg: Decode with nvdec, upload
  with --vf=format=vulkan)
* Vulkan filters can only be used with drivers that support
  VK_EXT_descriptor_buffer which doesn't include Intel ANV as yet.
  There is an MR outstanding for this.
* When dealing with 1080p content, there may be some visual distortion
  in the bottom lines of frames due to chroma scaling incorporating the
  extra hidden lines at the bottom of the frame (1080p content is
  actually stored as 1088 lines), depending on the hardware/driver
  combination and the scaling algorithm. This cannot be easily
  addressed as the mechanical fix for it violates the Vulkan spec, and
  probably requires a spec change to resolve properly.

All of these caveats will be fixed in either drivers or ffmpeg, and so
will not require mpv changes (unless something unexpected happens)

If you want to run on nvidia with the non-beta drivers, you can this
ffmpeg tree with the work-around patches:

* https://github.com/philipl/FFmpeg/tree/vulkan-nvidia-workarounds
This commit is contained in:
Philip Langdale
2022-03-12 11:21:29 -08:00
committed by Philip Langdale
parent 085f3e31a0
commit 61e685594d
11 changed files with 387 additions and 2 deletions

View File

@@ -411,7 +411,7 @@ endif
if darwin
path_source = files('osdep/path-darwin.c')
sources += path_source + files('osdep/timer-darwin.c')
endif
if posix and not darwin
@@ -933,6 +933,8 @@ if features['libplacebo-next']
'video/out/gpu_next/context.c')
endif
features += {'libplacebo-decode': features['libplacebo'] and libplacebo.version().version_compare('>=5.275.0')}
sdl2_video = get_option('sdl2-video').require(
features['sdl2'],
error_message: 'sdl2 was not found!',
@@ -1309,6 +1311,16 @@ if features['cuda-interop'] and features['vulkan']
sources += files('video/out/hwdec/hwdec_cuda_vk.c')
endif
vulkan_interop = get_option('vulkan-interop').require(
vulkan.found() and features['libplacebo-decode'] and
libavutil.version().version_compare('>=58.11.100'),
error_message: 'Vulkan Interop requires vulkan, libplacebo >= 5.275.0, and libavutil >= 58.11.100',
)
features += {'vulkan-interop': vulkan_interop.allowed()}
if vulkan_interop.allowed()
sources += files('video/out/hwdec/hwdec_vulkan.c')
endif
d3d_hwaccel = get_option('d3d-hwaccel').require(
win32,
error_message: 'the os is not win32!',