1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00
Commit Graph

258 Commits

Author SHA1 Message Date
Timo Rothenpieler
262d41c804 all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
vytskalt
2e19e74a29 hwcontext_vulkan: transfer exclusive images to correct queue family in drm->vulkan mapping 2025-08-02 11:02:59 +03:00
Lynne
bd75fad85f hwcontext_vulkan: fix issues with importing a device
The previous fix just used a local variable for the memory properties,
which did not fix this issue.
2025-06-27 03:09:27 +09:00
Lynne
60fc0288ae hwcontext_vulkan: fix 85c0364b70
The issue is that by moving the mprops loading later, we inadvertently
broke some earlier dependencies.
2025-06-24 16:42:43 +09:00
Lynne
11428896db hwcontext_vulkan: add workaround for broken Nvidia drivers 2025-06-24 02:30:01 +09:00
Lynne
85c0364b70 hwcontext_vulkan: move ReBAR check into a new function and use it later
The issue is that vulkan_device_create_internal() is only called for
devices that lavu creates by itself.
For external devices, this was never done.

This also solves some mid-function declaration warnings.
2025-06-24 02:30:01 +09:00
Niklas Haas
27590d8653 avutil/hwcontext_vulkan: disable host transfers if ReBAR is disabled
This feature fundamentally relies on host-visible VRAM, which restricts the
set of available memory types to (typically) host-visible device-local ones.

When resizable BAR is disabled, this memory type is usually limited to
e.g. 256 MiB in size, which is just plain insufficient for allocation of
general purpose GPU images, causing OOM errors on even the simplest of
commands.

The easiest solution is to disable host transfers entirely on machines
without host-addressable VRAM. In theory, we could try and recover the use
of host transfers for images which are *not* restricted to device-local
memory types, but this is rarely the case in practice, and the effort
required would exceed the benefit, especially since ReBAR is a standard
feature on all platforms recent enough to have Vulkan drivers, and only
occasionally disabled in the UEFI for by default for some hare-brained
notion of "backwards compatibiility" with ancient software.
2025-06-22 12:13:09 +02:00
Lynne
e5bb448543 vulkan: maintain compatibility with old headers
Previous patch to fix these issues was incomplete.
2025-06-17 13:26:13 +09:00
Lynne
922a1ca989 vulkan: maintain compatibility with older headers 2025-06-12 00:17:29 +09:00
Lynne
3ac7d70291 hwcontext_vulkan: fix image copy
The patch was applied by mistake in an unfinished form.
This fixes the build and lets the code run.
2025-06-11 14:33:01 +09:00
Lynne
a9b2c10eee hwcontext_vulkan: use host image copy 2025-06-11 01:20:18 +09:00
Lynne
f531c91170 hwcontext_vulkan: add a setting to limit queues
If its a problem, you'll likely want to set it to 1 than more fine-grained
control, which you can already do via the API.
2025-06-10 22:26:14 +09:00
Lynne
26d17709e7 hwcontext_vulkan: minimize queue allocation on NVIDIA
On NVIDIA, there's a global maximum limit of approximately 112 queues,
which means it takes ONLY 7 total programs using the maximum amount of
queues to cause the driver to error out/*segfault* during initialization.

Also, each queue takes about 30ms to allocate, which quickly adds up.

This reduces the queues allocate to the minimum that we would be happy
with. Its not worth limiting decode/encode queues as they're generally
not a lot, and do help.
2025-06-10 22:26:14 +09:00
Lynne
b5262bccdb hwcontext_vulkan: do not use optical flow queueus by default
We don't use them, and on NVIDIA, each queue takes around 30ms
to allocate, and the driver has a global limit of ONLY 112 queues.
2025-06-10 22:26:09 +09:00
Niklas Haas
c2521c0cd2 avutil/vulkan: add YUVA pixel formats support
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition
2025-05-28 12:14:54 +02:00
Lynne
842fa198e9 hwcontext_vulkan: fix build with old Vulkan header versions 2025-05-21 03:11:07 +09:00
Lynne
eabb62813e hwcontext_vulkan: only try exporting DMABUF memory on !WIN32 and only for DMABUF tiling 2025-05-20 19:53:02 +09:00
Lynne
7c3c5c8052 hwcontext_vulkan: correct image transfer usage flags
By pure coincidence, BUFFER and IMAGE flags were equal for those
two usage types.
2025-05-20 19:53:02 +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
Link Mauve
d5f4a55123 avutil/hwcontext_vulkan: Query the correct format
In the call to vkGetPhysicalDeviceImageFormatProperties2(), we were
previously requesting the properties of the first fallback format (e.g.
VK_FORMAT_R8_UNORM for VK_FORMAT_G8_B8R8_2PLANE_420_UNORM) instead of
the actual format in use.

We don’t do anything with it afterwards, but there is no reason to keep
querying the wrong format.
2025-05-07 15:16:58 +02:00
Lynne
33a4d36101 hwcontext_vulkan: support AV_PIX_FMT_GBRP
Support was partially added previously in vulkan.c, but now it's fully
supported.
2025-05-01 09:34:44 +02:00
Lynne
3bb2b8aff4 hwcontext_vulkan: enable subgroupSizeControl
We already use this feature for setting the subgroup size,
but this feature was not enabled.

Fixes a validation warning.
2025-04-22 13:43:20 +02:00
Lynne
96ddce1b3c vulkan: move OPT_CHAIN out of hwcontext_vulkan
This allows for it to be shared.
Technically, implementations should not give drivers structs
that the drivers are not familiar with.
2025-04-22 13:43:19 +02:00
Lynne
5098b1a345 vulkan: move feature<->usage mapping code outside of hwcontext_vulkan.c
Allows for it to be reused. In particular, for a future patch to make
vulkan hwaccels output DMABUF-backed VkImages.
2025-04-22 13:43:17 +02:00
Lynne
bb3ce284d7 vulkan: use a single command buffer per command buffer pool
We violated the spec, which, despite the actual command buffer pool
*not* being involved in any functions which require external synchronization
of the pool, *require* external synchronization even if only the
command buffers are used.

This also has the effect of *significantly* speeding up execution
in case command buffers are contended.
2025-04-16 23:38:16 +02:00
James Almer
0e59675698 avutil/hwcontext_vulkan: use the typedef'd name for the expect_assume struct
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-15 16:52:51 -03:00
James Almer
f29475a89e avutil/hwcontext_vulkan: check if expect_assume is supported by the header
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-15 16:44:45 -03: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
a1137f9214 hwcontext_vulkan: disable descriptor buffer extension on Intel
Temporary workaround. Will be replaced with a version check once a fix is
in the works and a known next version for Mesa with a fix is known.
2025-04-14 06:10:41 +02:00
Andreas Rheinhardt
4d2e38b376 avutil/hwcontext_vulkan: Remove unused variable
Forgotten in 8c7b00ba3a.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
llyyr
8c7b00ba3a avutil/hwcontext_vulkan: stop checking for deprecated and removed flag
AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY was deprecated in e0f2d2e702
and removed in 09a5760299

Fixes: e0f2d2e702
Fixes: 09a5760299
2025-03-29 00:40:48 +01:00
Lynne
53ff9005b5 vulkan: add support for AV_PIX_FMT_GBRAP32 2025-03-17 08:49:15 +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
3c09aadcf4 hwcontext_vulkan: allow using concurrent access images with more than 5 queues
This limit was not bumped when the queue family rewrite happened.

Fixes validation issues on nvidia.
2025-03-17 08:49:10 +01:00
Lynne
6c9affb3e6 hwcontext_vulkan: fix downloads; use the common host map function to map frame data
This commit uses the recently exported code for host mapping images back
where it was exported from.

The function also had broken download code for image downloading since its
recent refactor.
2025-03-17 08:49:09 +01:00
Lynne
bdc07f372a hwcontext_vulkan: add support for mapping multiplane images into CUDA
This patch refactors the CUDA import code to allow for Vulkan images
with multiple planes to be mapped.

Currently, a driver bug exists which causes NV12 images to be mapped
incorrectly when the memory being mapped contains both planes, the
issue has been reported to NVIDIA.
yuv420p does work correctly, however.

This is still an improvement, as the code used to crash when trying to
map the memory, unless disable_multiplane=1 was given as an option.
2025-03-11 13:42:19 +01:00
Lynne
629e8a2425 vulkan: add support for AV_PIX_FMT_GRAY32 2025-03-01 13:11:13 +01:00
Lynne
85d81dcfd6 hwcontext_vulkan: enable read/write without storage
BGR formats in Vulkan cannot be used in storage images, as the
pixel labels on storage images are always ordered as RGB, and
swizzling is not an option due to old hardware limitations.
This means that you must always use an RGB format and manually
swizzle when reading or writing to BGR images, or simply not use
a format in the shader itself.
This adds support for the latter.
2025-02-27 19:06:41 +01:00
Lynne
b6bf568a44 vulkan: don't query video queue properties unless the extension is enabled
Fixes validation errors.
2025-02-21 03:19:19 +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
d9b773c22f hwcontext_vulkan: add VK_EXT_layer_settings to optional instance extensions
The issue is that some compilers complain if a struct or array
is empty.

This extension does nothing by default, and can be useful, so just add it
to keep the array non-empty.
2025-01-03 14:53:37 +09:00
Lynne
1b8cd00da6 configure: add option to statically link to libvulkan
This may be useful in weird setups and on platforms where
static linking to libvulkan is supported.

libplacebo also has this fallback.
2024-12-23 04:25:09 +09:00
Lynne
2e06b84e27 vulkan: do not reinvent a queue context struct
We recently introduced a public field which was a superset
of the queue context we used to have.

Switch to using it entirely.

This also allows us to get rid of the NIH function which was
valid only for video queues.
2024-12-23 04:25:09 +09:00
Lynne
4ca2b86ed5 hwcontext_vulkan: disable validation layer threading warnings
The layer is buggy currently:
https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/9045
2024-12-23 04:25:08 +09:00
Lynne
18af3a1db2 hwcontext_vulkan: do not enable portability subset by default
It doesn't make sense to, and could result in the implementation
picking emulation layers.
2024-12-23 04:25:01 +09:00
Lynne
d485420237 hwcontext_vulkan: take disable_multiplane into account when checking for formats 2024-11-26 14:14:13 +01:00
Lynne
cf0961a527 hwcontext_vulkan: require storage properties to claim formats as supported
This function dates back a long time ago, before vkfmt_from_pixfmt2.
When it was converted over, the thought was that this was far too
restrictive to demand storage images for each format.
With the new clever function, it makes sure to check that the compatible
subformats a format can be used as support storage capabilities.

This gets rid of fake support for RGB48/RGB96 which some implementations
offer but don't support using as storage images.
2024-11-26 14:14:13 +01:00
Lynne
f65e51293a hwcontext_vulkan: add support for AV_PIX_FMT_GBRAP10/12/14 2024-11-26 14:14:13 +01:00
Lynne
7c52dda55f hwcontext_vulkan: add support for AV_PIX_FMT_GBRP12/14/16 2024-11-26 14:14:12 +01:00
Lynne
08fb505a66 hwcontext_vulkan: add support for AV_PIX_FMT_GRAY10/12/14 2024-11-26 14:14:07 +01:00