Commit Graph

58 Commits

Author SHA1 Message Date
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
3d75ba7495
vulkan: separate out descriptor layouts from sets
Just avoids a single temporary allocation.
2024-09-23 13:40:38 +02:00
Lynne
2395444c80
vulkan: add ff_vk_exec_add_dep_bool_sem
This function simply takes in a binary semaphore as a dependency
to an execution.
2024-09-22 02:11:08 +02:00
Lynne
c4048013e5
vulkan: flexibly allocate temporary imageviews
No reason to allocate 16 when 3 will do.
2024-09-22 02:11:07 +02:00
Lynne
0fa6f33875
hwcontext_vulkan: add support for x2bgr10 and proper DRM mappings for 10-bit images
This allows mapping of 10-bit DRM images.
2024-09-16 14:03:56 +02:00
Lynne
5e9845f11e
vulkan(_decode): fix, simplify and improve queries
The old query code never worked properly, and did some hideous
heuristics to read the status bit, and work that into a return
code.
This is all best left to callers to do, which simplifies
our code a lot.

This also fixes minor validation errors regarding calling queries
which are not in their active state.
2024-09-09 07:05:46 +02:00
Lynne
620822c0c5
vulkan: add a ff_vk_init function
This function sets the class correctly, and calls functions
that all users have to call anyway.
2024-09-09 07:05:45 +02:00
Lynne
06483d039a
vulkan: error out if query is called without being initialized 2024-09-09 07:05:43 +02:00
Lynne
fd86c373c2
vulkan: use correct return codes for query errors 2024-09-09 07:05:43 +02:00
Lynne
d138d7a595
vulkan: make sure descriptor buffers are always DEVICE_LOCAL
Implementations are required to list memory heaps in the most optimal
order. But its better to be explicit for this particular allocation.
2024-08-13 19:05:20 +02:00
Lynne
d6c08a41cb
vulkan: load queue families upon loading properties
Avoids the need to call ff_vk_qf_init if manually filling in
a queue family structure.
2024-08-11 05:13:16 +02:00
Lynne
83cd77563f
vulkan: add support for encode feedback queries 2024-08-11 05:13:15 +02:00
Lynne
8eac11105b
vulkan: use allocator callback for buffer creation
This would've let to a segfault if custom allocators were used.
2024-08-11 05:13:13 +02:00
Lynne
aea4d4b423
hwcontext_vulkan: rewrite upload/download
This commit was long overdue. The old transfer dubiously tried to
merge as much code as possible, and had very little in the way
of optimizations, apart from basic host-mapping.

The new code uses buffer pools for any temporary bufflers, and
handles falling back to buffer-based uploads if host-mapping fails.

Roundtrip performance difference:
ffmpeg -init_hw_device "vulkan=vk:0,debug=0,disable_multiplane=1" -f lavfi \
-i color=red:s=3840x2160 -vf hwupload,hwdownload,format=yuv420p -f null -

7900XTX:
Before: 224fps
After: 502fps

Ada, with proprietary drivers:
Before: 29fps
After: 54fps

Alder Lake:
Before: 85fps
After: 108fps

With the host-mapping codepath disabled:
Before: 32fps
After: 51fps
2024-08-11 05:13:11 +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
Lynne
bedfabc437
vulkan: use the new queue family mechanism 2024-08-11 05:13:09 +02:00
Lynne
80ddc72717
vulkan: rename read_only to singular
There's nothing stopping users from writing to such buffers.
Its more accurate to say they are singular, i.e. not duplicated
between multiple submissions.

This can be helpful for global statistics, or error propagation
purposes.
2024-07-14 18:33:56 +02:00
Lynne
e11087b162
vulkan: set VkDescriptorAddressInfoEXT.sType
This was not done, resulting in validation issues, and potential
driver issues.
2024-07-14 18:31:44 +02:00
Andreas Rheinhardt
790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt
1b7308b61d avutil/vulkan: Remove unused ff_vk_set_descriptor_sampler()
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:56:25 +01:00
Andreas Rheinhardt
c346c097af avutil/vulkan: Make ff_vk_set_descriptor_image() static
Only used in vulkan.c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:56:21 +01:00
Andreas Rheinhardt
c0d31cec7f avutil/vulkan: Avoid shadowing
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:56:17 +01:00
Andreas Rheinhardt
e429b0fdb7 avutil/vulkan: Don't autoinclude vulkan_loader.h
Only include it where necessary.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:55:26 +01:00
Lynne
1a8e766984
vulkan: return VK_NOT_READY when no queries are available
Fixes a validation issue.
The issue is that the function gets called before we've sumitted a frame
for decoding to that context. However, we cannot run queries before
they've been reset, which happens at submission time.
As we'd need to otherwise run a command queue at init-time, just check
if submissions have happened.
2023-10-28 21:16:15 +02:00
Lynne
d0a64f9a81
vulkan: do not leak bound_buffer_indices 2023-08-28 22:29:36 +02:00
Lynne
f6cf3a40e4
vulkan: check for extension rather than function pointer
The loader ensures only that functions with tagged supported extensions
exist, rather than ensuring only those with supported extensions are
loaded.
As the init function uses Vulkan functions, whose loading requires them
to have the extension flags set, the extension flags are guaranteed
to also exist at this point.
2023-08-28 22:29:33 +02:00
Lynne
747871a42c
vulkan: do not leak cooperative matrix properties 2023-08-28 22:29:29 +02: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
97890c2b55
lavu/vulkan: remove threadsafe buffer index load and fix a signed overflow
It's not needed anymore.
2023-07-21 20:04:20 +02:00
Lynne
5f1be341c2
vulkan: discard dependencies when explicitly waiting for execution
This reduces memory needed dramatically, as unneeded resources
can be immediately returned to the pool.
Although waitforfences is threadsafe, we add a mutex wait around
it, as the mutex fence in combination with waitforfences assures
us that no other thread will reset the fence in the meanwhile
whilst the mutex is locked. This allows is to call
ff_vk_exec_discard_deps.
2023-06-07 23:59:16 +02:00
Lynne
975cd48bb3
vulkan: synchronize access to execution pool fences
vkResetFences is specified as being user-synchronized
(yet vkWaitFences, is not).
2023-06-07 23:59:16 +02:00
Lynne
58f82fc26a
vulkan: replace usage of %lu with %"SIZE_SPECIFIER" 2023-05-29 03:22:58 +02:00
Lynne
dfff3877b7
vulkan: add support for the atomic float ops extension 2023-05-29 00:42:01 +02:00
Lynne
83024beec2
vulkan: enable forcing of full subgroups 2023-05-29 00:41:49 +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
721b71da4a
vulkan: return current queue index from ff_vk_qf_rotate() 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
6eaf3fe69c
vulkan: add support for queries 2023-05-29 00:41:47 +02:00
Lynne
f3fb1b50bb
vulkan: minor indent fix, add support for synchronous submission/waiting 2023-05-29 00:41:46 +02:00
Lynne
d386988c39
vulkan: use device properties 2 and add a convenience loader function 2023-05-29 00:41:46 +02:00
Lynne
bf69a64135
vulkan: add size tracking to buffer structs 2023-05-29 00:41:46 +02:00
Lynne
b18e20a4ee
vulkan: do not wait for device idle when destroying buffers
This should be done explicitly.
2023-05-29 00:41:45 +02:00
Lynne
15de0af8f0
vulkan: allow alloc pNext in ff_vk_create_buf 2023-05-29 00:41:45 +02:00
Lynne
af48790465
vulkan: support ignoring memory properties when allocating 2023-05-29 00:41:45 +02:00
Lynne
3c2f43d8ee
vulkan: expose ff_vk_alloc_mem() 2023-05-29 00:41:44 +02:00
Lynne
fa67ccee37
vulkan: add ff_vk_image_create() 2023-05-29 00:41:44 +02:00
Lynne
e8fce74abf
vulkan: add ff_vk_qf_fill() 2023-05-29 00:41:43 +02:00
Lynne
b5e333bba7
vulkan: add pNext argument to ff_vk_create_buf() 2023-05-29 00:41:43 +02:00
Lynne
619b1265a2
vulkan: add additional error codes 2023-05-29 00:41:42 +02:00