56 Commits
Author SHA1 Message Date
Lynne e4373dd092 vulkan: enable VK_KHR_maintenance11
Among other things, lifts the 4-byte alignment that transfer-only queue
families require of buffer offsets in buffer-image copies.
2026-09-24 11:05:27 +09:00
Philip Langdale 67d341f49e avfilter/fruc_vulkan: turn the filter into a Vulkan filter
This change introduces the basic Vulkan filter machinery, while preserving the
original vf_framerate timing logic. At this stage, the filter simply picks the
temporally closest input frame for the output.

Note that while input frames are not modified in anyway, they must be
deep-copied for output. This ensures that they match the output context, which
may differ from the input context in important way, and avoids extending the
lifetime of hardware decoded frames that are part of the decoder's DPB.

This requires exposing vkCmdCopyImage in the Vulkan function loader, and a
compute queue family and execution pool to record the copy on.

The filter depends on vulkan_1_4 for its Vulkan-Headers requirement; while this
is not required by any of the code in this commit, the final optical-flow
pipeline will need VK_KHR_maintenance9, which first appeared with Vulkan 1.4.
To avoid confusion, the requirement is asserted from the beginning.
2026-08-29 17:07:53 -07:00
Kacper Michajłowandllyyr cc50be6d0d avutil/hwcontext_vulkan: probe host image transfer support before enabling
Drivers may expose the host image transfer format feature, yet reject
the final image parameter combination, or provide no memory type from
which such an image can be allocated. Notably video decode/encode
images are often not possible to allocate from host visible memory
type. Validate the final image parameters, including DRM format
modifiers, and keep the usage flag only when it is actually usable.

Fixes: #21704
Co-authored-by: llyyr <llyyr.public@gmail.com>
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-08-17 17:23:43 +02:00
Lynne b7e8611b2a vulkan: enable unified image layouts when supported
Enables VK_KHR_unified_image_layouts when available, and queries its
feature bits into FFVulkanContext. The extension guarantees that using
the GENERAL image layout comes with no performance penalty, with the
unifiedImageLayoutsVideo feature extending this to video usage.
2026-08-17 14:57:07 +09:00
Lynne a1c83c513f vulkan: carry the execution context's busy state in a timeline semaphore
An execution abandoned on error between start and submission left the
ownership mutex locked forever, deadlocking the context's next reuse.

Replace the submission fence with a timeline semaphore:
ff_vk_exec_start() claims the context by incrementing the awaited
value, the submission signals it, and the mutex only briefly guards
the dependency lists. Abandonment becomes ff_vk_exec_discard(), called
exactly once on a started, unsubmitted context: it frees the
dependencies, drops the recording, and un-claims by signalling from
the host - which a fence cannot do. ff_vk_exec_submit() cleans up
after its own failures; error paths which leaked the claim now
discard, and ff_vk_exec_start() failures are checked everywhere.
2026-08-17 14:57:07 +09:00
Lynne 8884301271 vulkan: enable maintenance9 when supported
Enables VK_KHR_maintenance9 when available. The feature of interest
is that queue family ownership transfers become optional for resources
created with exclusive sharing mode, with their contents preserved
when accessed by another queue family.

For optimal-tiling images, this is only guaranteed between queue
families flagged in VkQueueFamilyOwnershipTransferPropertiesKHR, so
query it for each queue family alongside the other properties.
2026-08-17 14:57:01 +09:00
Lynne 64fe3bee7f vulkan: enable VK_KHR_shader_maximal_reconvergence when available 2026-08-03 10:57:45 +09:00
llyyr 51660ad523 libavutil/vulkan: replace GetDeviceQueue with GetDeviceQueue2
vkGetDeviceQueue2 with flags = 0 is equivalent to vkGetDeviceQueue and
is available since Vulkan 1.1. Needed to support queues created with
non-zero VkDeviceQueueCreateFlags.

Fixes VUID-vkGetDeviceQueue-flags-01841 VVL error.
2026-04-24 16:07:25 +05:30
Lynne 6f811ad751 hwcontext_vulkan: implement internal queue synchronization 2026-04-21 08:34:47 +02:00
Lynne 3ba81f2af4 vulkan: drop support for descriptor buffers
Descriptor buffers were a neat attempt at organizing descriptors.
Simple, robust, reliable.

Unfortunately, driver support never caught on, and neither did validation
layer support.

Now they're being replaced by descriptor heaps, which promises to be
the future. We'll see how it goes.
2026-02-19 19:42:31 +01:00
Lynne e32cb94258 hwcontext_vulkan: enable long vector extension
This enables us to do some neat tricks.
2026-01-12 17:28:41 +01:00
Lynne cf0ce1b7e4 hwcontext_vulkan: enable the VK_EXT_shader_replicated_composites extension
Its required to use certain features in SPIR-V that glslang uses.
2026-01-12 17:28:41 +01:00
Lynne b7d2469e4c vulkan_functions: add vkCmdDispatchBase
Its useful for multi-stage operations.
2025-12-31 15:00:46 +01:00
Lynne bb30126349 hwcontext_vulkan: enable the explicit shader workgroup extension
Its useful as it allows us to alias memory in shaders.
2025-12-31 15:00:45 +01:00
Lynne d33bf66519 vulkan_functions: add vkCmdUpdateBuffer
It embeds the data to be uploaded directly into the command buffer,
which makes it useful for uploading transient data.
2025-12-22 19:46:27 +01:00
Lynne 964e9cc63b hwcontext_vulkan: add support for VK_EXT_zero_initialize_device_memory 2025-10-28 07:11:21 +01:00
Lynne b2928971e8 lavc: add an av1_vulkan encoder
This commit adds a Vulkan AV1 encoder, using the native acceleration API.
2025-08-08 18:29:40 +09:00
Lynne 2caf23e7c4 vp9: add Vulkan VP9 hwaccel 2025-08-08 18:29:40 +09:00
Lynne a9b2c10eee hwcontext_vulkan: use host image copy 2025-06-11 01:20:18 +09:00
Lynne 435db9bb49 vulkan: enable VK_KHR_shader_subgroup_rotate
Yet another thing that should've been always present.
2025-05-20 19:53:02 +09:00
Lynne e040c087c7 vulkan: add support for expect/assume
This commit adds support for compiler hints.
While on AMD these are not used/needed, Nvidia benefits from them, and gives
a sizeable 10% speedup on 4k.
2025-04-14 06:10:43 +02:00
Lynne 66b8c92df2 vulkan_ffv1: cache only 2 lines when decoding RGB
This reduces the intermediate VRAM used for RGB decoding by a
factor of 100x for 6k video.
This also speeds the decoder up by 16% for 4k RGB24 and 31% for 6k video.

This is equivalent to what the software decoder does, but with less pointers.
2025-04-14 06:10:42 +02:00
Lynne 8804ae158b vulkan_functions: add note to update ff_vk_extensions_to_mask
Otherwise, the extension looks like its enabled, but isn't
actually used by anything.
2025-03-27 17:22:12 +01:00
Lynne 67eb01b458 hwcontext_vulkan: enable VK_KHR_video_maintenance2
Enables some fixes for the video specifications, and a new feature.
2025-03-17 08:49:12 +01:00
Lynne 851a84650e hwcontext_vulkan: check if semaphores are exportable before enabling exporting
lavapipe recently added support for external_semaphore_fd, but only for syncfiles,
not for opaque file descriptors.

The code is written to allow using syncfiles later on.

Ref: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12422
2025-01-13 10:44:30 +09:00
Lynne d8f301cdf2 ffv1enc_vulkan: switch to receive_packet
This allows the encoder to fully saturate all queues the GPU
has, giving a good 10% in certain cases and resolutions.

This also improves error resilience if an allocation fails,
and properly cleans up after itself if it does.
2024-11-26 14:14:15 +01:00
Lynne e3676d96cb hwcontext_vulkan: move device feature struct setup to a new function 2024-10-04 10:10:43 +02:00
Lynne 535e5eb7f3 hwcontext_vulkan: enable VK_KHR_shader_relaxed_extended_instruction 2024-10-04 10:10:43 +02:00
Lynne 0d5bfd0b21 vulkan_functions: change extension type to a typedef uint64_t
We were getting a bit too close for comfort to the 32-bit limit
on enums.
2024-10-04 10:10:42 +02:00
Lynne 37d5cb84e8 vulkan: check if current buffer has finished execution before picking another
This saves resources, as dependencies are freed/reclaimed with a lower latency,
and provies a speedup.
2024-10-04 10:10:42 +02:00
Lynne bc36fe6f1f vulkan: use push descriptors where possible
Push descriptors are in theory slightly faster, but come with
limitations for which we have to check.

Either way, they're not difficult to implement, so even though
no one should be using peasant-tier descriptors, do it anyway.
2024-09-23 13:41:07 +02:00
Lynne 8a7af4aa49 vulkan: add support for regular descriptor pools
This permits:
 - The use of Vulkan filtering on many more devices
 - Better debugging due to lack of descriptor buffer support in layers

Much of the changes here are due to a requirement that updates to
descriptors must happen between the command buffer being waited on,
and the pipeline not being bound.

We routinely did it the other way around, by updating only after
we bind the pipeline.
2024-09-23 13:40:38 +02:00
Lynne a577d313b2 hwcontext_vulkan: add support for implicit DRM synchronization
More recent kernel versions allow for users to extract a sync_file
handle from a DMA-BUF, which can then be imported into Vulkan as a
binary semaphore.

This finally allows for synchronization between Vulkan and DMA-BUF
images, such as those from screen capture software, or VAAPI,
avoiding any corruption artifacts.

This is done fully asynchronously, where we use the kernel's
given binary semaphores as a dependency to increment the image's
usual VkSemaphores we allocate. The old imported binary semaphores
are cleaned up after execution as usual.

In the future, hwcontext_drm should receive support for explicitly
synchronized images as well, which would make the synchronization
more robust and portable.
2024-09-22 02:11:08 +02:00
Lynne 46c13834b6 hwcontext_vulkan: enable VK_KHR_video_maintenance1
We require it for encoding.
2024-08-16 01:22:15 +02:00
Lynne 2ce0e51503 hwcontext_vulkan: add support for Vulkan encoding 2024-08-11 05:13:14 +02:00
Lynne 55adcb4fc5 hwcontext_vulkan: add support for VK_EXT_shader_object
We'd like to use it eventually, and its already covered by
the minimum version of the headers we require.
2024-08-11 05:13:13 +02:00
Lynne a30b7c0158 hwcontext_vulkan: initialize optical flow queues if available
Lets us implement FPS conversion.
2024-08-11 05:13:10 +02:00
LynneandDave Airlie ecdc94b97f vulkan_av1: port to the new stable API
Co-Authored-by: Dave Airlie <airlied@redhat.com>
2024-03-25 08:54:40 +01:00
Lynne 358919506d vulkan: enable VK_KHR_cooperative_matrix
It's of interest to API users, and of interest to us,
as a DCT/DST can be implemented via matrix multiplies.
2023-08-26 23:14:53 +02:00
Lynne 160a415e22 lavfi: add nlmeans_vulkan filter 2023-05-29 00:42:01 +02:00
Lynne dfff3877b7 vulkan: add support for the atomic float ops extension 2023-05-29 00:42:01 +02:00
Lynne 77478f6793 av1dec: add Vulkan hwaccel 2023-05-29 00:42:00 +02:00
Lynne b5eaeb1f13 vulkan: rewrite to support all necessary features
This commit rewrites the majority of vulkan.c to enable its use
as a general-purpose high-level utility code, usable for decoding,
encoding, and filtering of video frames.

The dependency system was rewritten to simplify management of
execution.

The image handling system was rewritten to accomodate multiplane
images.

Due to how related all the new features were, this is a single
commit.
2023-05-29 00:41:48 +02:00
Lynne b15104ed97 vulkan: add support for retrieving queue, query and video properties 2023-05-29 00:41:47 +02:00
Lynne e5e12c5078 hwcontext_vulkan: load query-related functions
Needed for both encoding and decoding.
2023-05-29 00:41:41 +02:00
Lynne 6dfa29a58d hwcontext_vulkan: add functions for video decoding 2023-05-29 00:41:40 +02:00
Lynne 571756bf2f hwcontext_vulkan: use VK_EXT_physical_device_drm to derive DRM to Vulkan
Finally, a way to directly identify a Vulkan device from a DRM device!
2023-05-29 00:41:40 +02:00
Lynne f50bc930a4 hwcontext_vulkan: add support for descriptor buffers 2023-05-29 00:41:39 +02:00
Lynne 74b202b839 hwcontext_vulkan: enable VK_KHR_synchronization2 if supported 2023-05-29 00:41:36 +02:00
Lynne fddfb0ebf8 hwcontext_vulkan: enable support for YCbCr samplers 2023-05-29 00:41:36 +02:00