1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-29 05:57:37 +02:00
Commit Graph

124 Commits

Author SHA1 Message Date
Lynne
7cd1edeaa4 vulkan: drop bgr_workaround
Vulkan's main issue around using BGR is simple.
The letters in the shader don't match up (rgba in shader, bgra in format).
So of course, rather than allowing "bgra" or other permutations of
formats in the shader, they went the nuclear option and spent months writing
an extension to get rid of the need to have a format in the shader to begin
with.

All this to solve a problem that should never have existed to begin with.
This fixes BGRA images since enabling WithoutFormat, as the GPU now remaps
without your involvement.
2025-04-19 18:45:13 +02:00
Lynne
ca6392e0a7 vulkan: always enable ReadWithoutFormat/WriteWithoutFormat
This implements support for reading and writing storage images with
no format.
The issue is that we define our images as arrays, and arrays can
only have a single type, which means that f.ex. NV12 needs two
different images, R8 and RG8.

The only driver known not to advertise support for the extension
as a whole is Intel, because they have parial support for odd formats
we never use. Therefore, just always enable it by default.
2025-04-19 10:59:11 +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
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
7b0156201b vulkan: fix logging level when erroring upon creating shader module 2025-04-14 06:10:34 +02:00
Lynne
4dadf71dce lavu/vulkan: skip adding NULL buffers as deps in ff_vk_exec_add_dep_buf
Allows for cleaner code.
2025-03-27 17:22:07 +01:00
Lynne
53ff9005b5 vulkan: add support for AV_PIX_FMT_GBRAP32 2025-03-17 08:49:15 +01:00
Lynne
4de023f953 vulkan: add ff_vk_exec_add_dep_wait_sem()
This adds a function which adds a regular timeline semaphore
as a wait-only dependency.
2025-03-17 08:49:15 +01:00
Lynne
f2a0bdd6b1 vulkan: unify handling of BGR and simplify ffv1_rct 2025-03-17 08:49:15 +01:00
Lynne
bbb06f1ffc vulkan: workaround BGR storage image undefined behaviour 2025-03-17 08:49:10 +01:00
Lynne
a5b90caacd vulkan: copy host-mapping buffer code from hwcontext
This is useful elsewhere.
2025-03-17 08:49:09 +01:00
Lynne
ed6ee32846 vulkan: add ff_vk_create_imageview 2025-03-17 08:49:09 +01:00
Lynne
7046e65e37 vulkan: rename ff_vk_set_descriptor_image to ff_vk_shader_update_img 2025-03-17 08:49:08 +01:00
Andreas Rheinhardt
27c82af2fe avutil/vulkan: Remove unused ff_vk_create_avbuf()
Unused since aea4d4b423.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:35:53 +01:00
Lynne
8631990f22 vulkan: take refs of frames using the regular buffer ref path
This simplifies the code, reduces allocations, and critically, does
not store references of frames, along with references to hw_frames_ctx.
The issue was that storing refs to frames while transferring stored
refs to hw_frames_ctx of frames, and so created a circular dependency,
which caused the Vulkan device to never be terminated.

This only stores what it strictly needs as a dependency, and enables
the frames context to be freed, even while doing asynchronous transfers.
2025-03-03 19:43:57 +01:00
Lynne
629e8a2425 vulkan: add support for AV_PIX_FMT_GRAY32 2025-03-01 13:11:13 +01:00
IndecisiveTurtle
b37ce9b016 libavutil/vulkan: Expose ff_vk_set_descriptor_image
Useful when creating a descriptor array of separate images
2025-02-28 13:44:49 +01:00
Lynne
f774a9376a vulkan: add .buf_elems to FFVulkanDescriptorSet
This enables users to specify a number that would be appended to
the buf_content string.
Saves users from needing to manually print to a string.

An earlier commit tried doing this via .elems, but it was
faulty, as this also incremented the total number of descriptors
in the descriptor set.
2025-02-21 03:19:20 +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
1029f51285 vulkan: fix crash in ff_vk_shader_free
The issue is if a shader fails to compile, shd->desc_layout would
not exist, but nb_descriptor_sets would.
2025-02-18 10:44:49 +01:00
Lynne
5c59e6ce19 vulkan: enable using .elems field for buffer content definitions
This avoids needing to snprintf when the buffer only contains an array of a struct,
while letting the validation layers detect errors more reliably.
2025-01-22 00:09:32 +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
157cd820ad vulkan: remove pointless mutex locks
This code was simply incorrect through and through. It did not
protect what actually has to be protected in a multi-threaded setup.
Perhaps it was used to silence threading errors?

Either way, remove it, and document the correct way to use execution
pools in a threaded environment.
2024-12-23 04:25:09 +09:00
Lynne
187fd52864 vulkan: fix use of atomics for the current context index
The code used to use atomic, but over time, this got broken.
This commit also remmoves the is-the-last-submission-ready
shortcut, which rarely did anything.
There's also value in relying on the fact that contexts
always carry their frames in a strictly incremental order
with no gaps.
2024-11-28 01:29:21 +09:00
Lynne
ce8a070cf3 vulkan: only wait for fences on uninit if the context had a submission
This fixes a potential deadlock on exit.
2024-11-26 14:14:14 +01:00
Lynne
86e552506d vulkan: zero out AVBufferRef in case of failure
This resulted in uninit errors and was never caught as
we generally did not use massive allocations before.
2024-11-26 14:14:14 +01:00
Lynne
f582de8f34 vulkan: only apply shortcut for next context selection if selection has a submission 2024-11-26 14:14:14 +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
Lynne
aad40fed33 vulkan: fix sw_frame_deps counter
The code used as a basis was the buffer dependency code, where the
counter was incremented after each buffer, but for the sw_frame dep
API, we only support adding individual frames at a time.
2024-11-20 05:47:41 +01:00
Lynne
1876026f83 vulkan: add ff_vk_exec_add_dep_sw_frame
Some software frames may be mapped, and we'd like to have
them as proper dependencies.
2024-11-18 07:54:20 +01:00
Lynne
c918b42dcd vulkan: retrieve Vulkan 1.1 properties
Required to know the subgroup size.
2024-11-18 07:45:46 +01:00
Lynne
16fa710340 vulkan: fix printing descriptors to shader for shaders with no descriptors 2024-11-18 07:45:46 +01:00
Lynne
a516b2da22 vulkan: add support for 10-bit planar RGB 2024-11-18 07:45:46 +01:00
Lynne
eb8f3b8460 hwcontext_vulkan: fix planar RGB images
They were non-working for quite a while.
2024-11-18 07:45:41 +01:00
James Almer
bb57b78013 avutil/hwcontext_vulkan: add missing packed YUV444 format mappings
Signed-off-by: James Almer <jamrial@gmail.com>
2024-10-27 14:50:57 -03:00
James Almer
5c622d4cc1 avutil/hwcontext_vulkan: add support for AV_PIX_FMT_Y216
Signed-off-by: James Almer <jamrial@gmail.com>
2024-10-23 20:06:03 -03:00
Lynne
9eb7e8d2a4 vulkan: move alignment of host-visible allocations outside of ff_vk_alloc_mem
The issue is that if dedicated allocation is used, VkBufferCreateInfo.size
and the actual allocated size mismatched, which is a validation error.
2024-10-23 08:14:10 +02:00
Lynne
dfaade76db vulkan: move buffer allocation av_log message
Its more useful when buffers are allocated, not in the
pool.
2024-10-18 11:18:35 +02:00
Lynne
931d45d4d6 vulkan: do not create imageviews with video encode/decode usage
This function is only used for filtering and generic compute.
The issue is that a view inherits the usage flags from the image
by default, and the spec says the view format must be compatible
with the usage. VkImageViewUsageCreateInfo allows us to filter out
the indeded uses of the imageview.

Pffff.
2024-10-16 12:48:16 +02:00
Lynne
4b128de44a vulkan: enable selecting a compatible representation of format
When using **integer** images inside shaders, it turns out
that conversion doesn't automatically happen, but we need to
explicitly use the imageviews to get the image exposed as
a suitable representation for the shader.

Finally enables bitexact image representations.
2024-10-16 12:48:15 +02:00
Lynne
98f6d43146 vulkan: keep track of mapped memory in the buffer structure
Can/could be useful to know which buffers are mapped.
2024-10-15 17:45:20 +02:00
Lynne
3afdfe830f vulkan: add support for AV_PIX_FMT_RGB96 2024-10-15 17:45:19 +02:00
Lynne
903f7f053a vulkan: add support for AV_PIX_FMT_RGBA128 2024-10-15 17:45:18 +02:00
James Almer
fd8b0dcfed avutil/hwcontext_vulkan: add proper maps for XV3{0,6}
Signed-off-by: James Almer <jamrial@gmail.com>
2024-10-14 15:12:49 -03:00
Lynne
0e19b05375 vulkan: fix layout qualifiers for 32-bit RGBA float storage reps
r8
r16/r16f
r32f

Sure, GLSL. Makes sense.
2024-10-12 00:38:49 +02:00
Lynne
168e8ae9bf hwcontext_vulkan: add support for AV_PIX_FMT_RGBF32 2024-10-11 23:54:23 +02:00
Lynne
d55a351741 hwcontext_vulkan: add support for AV_PIX_FMT_RGBAF32 2024-10-11 23:54:22 +02:00
Lynne
1addd0fdca vulkan: use correct signed image type for storage images
Using signed or unsigned integer formats/layouts requires that
"uimage" or "iimage" are used.
2024-10-11 23:54:22 +02:00