1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2026-06-19 19:03:00 +02:00

58 Commits

Author SHA1 Message Date
Lynne 03be563053 hwcontext_vulkan: fix BGRA/BGR0 images
The fix was a lot simpler than I thought it was.
2026-06-12 10:14:33 +09:00
Niklas Haas b488ee5553 swscale/ops: generalize SwsReadWriteOp.packed to enum
I want to start adding more data layouts, like semiplanar formats (nv12), or
palette formats. I made an effort to distinguish existing checks for rw.packed
into "mode != PLANAR" and "mode == PACKED", based on the intent of the
surrounding code, in anticipation of these new layouts.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 5f43d0cd46 swscale/ops: add and use ff_sws_rw_op_planes()
This is rw_planes() from ops_dispatch.c, but exposed internally.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 091149b187 swscale/ops: group filtered rw metadata into struct
This is a minor cosmetic improvement that allows me to use more
convenient names for a filter-related metadata fields, without
confusion.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 228ef8d97b swscale/ops: make compile() take const SwsOpList *
The old x86 backend was the only backend that actually mutated the ops list.
With this gone, we can constify this parameter.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 972c0cf91f swscale: add new SwsContext.backends option
This allows constraining the set of available backends. This serves as a
better replacement for the "unstable" flag, which is a bit ambiguous. Allows
users to, for example, opt into the memcpy or x86 backend, while excluding
e.g. the upcoming JIT backends.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Lynne cd89df8f99 vulkan/swscale: don't hardcode source type as float when filtering
Sponsored-by: Sovereign Tech Fund
2026-05-31 01:14:04 +09:00
Lynne 80405d3ceb swscale/vulkan: support interlaced filtering
Sponsored-by: Sovereign Tech Fund
2026-05-30 12:10:06 +09:00
Lynne 6de9576fca swscale/vulkan: implement filtered reads for the SPIRV backend
Same as GLSL, but much more annoying due to descriptors.
2026-05-30 12:10:06 +09:00
Lynne f17c8db820 swscale/vulkan: add a non-bitexact version of OP_LINEAR
Uses matrix*vector + vector multiplication.

Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:08 +09:00
Lynne 6d57426b6a swscale/vulkan: create a constant matrix from linear op constants
Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:07 +09:00
Lynne 2423a719e0 swscale/vulkan: put entire linear matrix+vector as constant data
Rather than only using what we need.
The driver will remove any unused constants.

Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:07 +09:00
Lynne 198991372c swscale/vulkan: move linear op handling to a separate function
Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:03 +09:00
Lynne c40ac0f03a swscale/vulkan: add support for filtering on SWS_OP_READ
Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:27 +09:00
Lynne 448e08aa80 swscale/vulkan: allocate buffers for scaling filters
Simply allocates buffers to hold filter data.

Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne b7ccdaa018 swscale/vulkan: make buffer descriptor generation generic
Again, simple rename.

Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne d0af60afa8 swscale/vulkan: make dither buffer allocation path generic
Just a simple rename.

Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne c8ddaa97db swscale/vulkan: base dispatch size on output image size, rather than input
Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne 51d4406e07 swscale/graph: support allocating hardware intermediate frames
Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:21 +09:00
Lynne 489a3834d2 swscale/vulkan: implement SWS_OP_PACK/SWS_OP_UNPACK
The issue is that while Vulkan already does the decomposition for us,
swscale assumes that the pixels will be in bitstream order, rather than
in their decomposed form.
This is valid for all packed formats for which these instructions are
issued (XV30 and X2RGB10).
This allows us to support the formats in Vulkan.

Sponsored-by: Sovereign Tech Fund
2026-05-19 03:22:29 +09:00
Niklas Haas cf2d40f65d swscale/ops: add explicit clear mask to SwsClearOp
Instead of implicitly testing for NaN values. This is mostly a straightforward
translation, but we need some slight extra boilerplate to ensure the mask
is correctly updated when e.g. commuting past a swizzle.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:23:36 +02:00
Zhao Zhili 9917308cc2 swscale/vulkan: fix dither buffer leak on mapping failure
A failure while preparing a dither buffer leaves the newly allocated
buffer outside the cleanup range, leaking Vulkan resources. Make the
failure path cover the current buffer as well.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-07 17:53:14 +00:00
Lynne 2b6fbcad6d swscale/vulkan: compile SPIR-V backed only if SPIR-V headers are found
Instead of making Vulkan depend on the headers, make the compilation of
the SPIR-V backend depend on the headers.

Sponsored-by: Sovereign Tech Fund
2026-04-04 19:02:27 +00:00
Lynne 47e4e95173 swscale/vulkan: add a native SPIR-V assembler backend
swscale gets runtime-defined assembly once again!

This commit splits the Vulkan backend into two, SPIR-V and GLSL,
enabling falling back onto the GLSL implementation if an instruction
is unavailable, or simply for testing.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne 6a723420dc swscale/vulkan: add a SPIR-V assembler header file
This commit adds a SPIR-V assembler header file. It was partially generated
from the SPIR-V header file JSON definition, then edited by hand to template
and reduce its size as much as possible.
It only implements the essentials required for SPIR-V assembly that swscale
requires.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne 5fa4085774 swscale/vulkan: use uniform buffers for dither matrix
Uniform buffers are much simpler to index, and require no work from
the driver compiler to optimize.
In SPIR-V, large 2D shader constants can be spilled into scratch memory,
since you need to create a function variable to index them during runtime.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne d4bcd3340e swscale/vulkan: add a check for BGRA features
The issue is that very often, hardware has limited support for BGRA
formats.

As this is a limitation of Vulkan itself, we cannot work around this
in a compatible way.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne 0a543441be swscale/vulkan: always reserve 4 image descriptors
The issue is that with multiplane images, or packed images,
there may be some mismatching between what .elems has, and what
we need.
Descriptors are cheap, so just always reserve 4.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne eb71c6c9a4 swscale/vulkan: move execution context to be a part of a shader
The issue is that the main Vulkan context is shared between possibly
multiple shaders, and registering a new shader requires allocating
descriptors.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne 7c33948b29 swscale/vulkan: fix potential memory issues
The issue is that updating descriptors relies on the pointers of
the structures remaining the same since creation.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:01 +02:00
Niklas Haas 85bef2c2bc swscale/ops: split SwsConst up into op-specific structs
It was a bit clunky, lacked semantic contextual information, and made it
harder to reason about the effects of extending this struct. There should be
zero runtime overhead as a result of the fact that this is already a big
union.

I made the changes in this commit by hand, but due to the length and noise
level of the commit, I used Opus 4.6 to verify that I did not accidentally
introduce any bugs or typos.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas c24d67a0ff swscale/vulkan/ops: use QSTR/QTYPE to print all rationals
Now this helper is a bit more useful.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas 7a4cffa25d swscale/vulkan/ops: simplify QTYPE macro
There's no reason for this macro to hard-code op->c.q4[i].

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas c0cc7f341a swscale/ops: simplify SwsOpList.order_src/dst
Just define these directly as integer arrays; there's really no point in
having them re-use SwsSwizzleOp; the only place this was ever even remotely
relevant was in the no-op check, which any decent compiler should already
be capable of optimizing into a single 32-bit comparison.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Lynne 0e077f2dc1 swscale/vulkan: do not apply order_src/dst for packed r/w
> packed = load all components from a single plane (the index given by order_src[0])
> planar = load one component each from separate planes (the index given by order_src[i])

Sponsored-by: Sovereign Tech Fund
2026-03-28 19:36:04 +01:00
Lynne 69c9cfbddf swscale/vulkan: fix redundant check for packed data
This is always in the branch where packed == false.

Sponsored-by: Sovereign Tech Fund
2026-03-28 19:36:04 +01:00
Niklas Haas bf09910292 swscale/ops: add filter kernel to SwsReadWriteOp
This allows reads to directly embed filter kernels. This is because, in
practice, a filter needs to be combined with a read anyways. To accomplish
this, we define filter ops as their semantic high-level operation types, and
then have the optimizer fuse them with the corresponding read/write ops
(where possible).

Ultimately, something like this will be needed anyways for subsampled formats,
and doing it here is just incredibly clean and beneficial compared to each
of the several alternative designs I explored.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Lynne e88d4ef718 swscale/vulkan: take order_src/order_dst into account
This fixes rgba/gbrap/bgra conversions.

Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne e01d19aad6 swscale/vulkan: implement SWS_OP_LINEAR
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne 4805f317a6 swscale/vulkan: implement SWS_OP_DITHER
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne d212ff08e0 swscale/vulkan: implement SWS_OP_CONVERT
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne bea41f1f90 swscale/vulkan: implement SWS_OP_LSHIFT/SWS_OP_RSHIFT
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne d35a77879c swscale/vulkan: implement SWS_OP_MIN/SWS_OP_MAX
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:16 +01:00
Lynne bf93a67733 swscale/vulkan: implement SW_OP_SCALE
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:16 +01:00
Lynne 41f748d2ee swscale/vulkan: add precise qualifier to f32
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:09 +01:00
Niklas Haas 68046d0b33 Revert "swscale/vulkan/ops: move buffer desc setting to helper function"
This reverts commit 32554fc107.

Accidentally pushed this commit twice, with the wrong location.
Correct version is 97682155e6.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:16:42 +01:00
Niklas Haas 143cb56501 swscale/vulkan/ops: use opaque run function
Avoids some unnecessary round-trips through the execution harness, as well
as removing one unnecessary layer of abstraction (SwsOpExec).

It's a bit unfortunate that we have to cast away the const on the AVFrame,
since the Vulkan functions take non-const everywhere, even though all they're
doing is modifying frame internal metadata, but alas.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 97682155e6 swscale/vulkan/ops: move buffer desc setting to helper function
And call it on the read/write ops directly, rather than this awkward loop.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 32554fc107 swscale/vulkan/ops: move buffer desc setting to helper function
And call it on the read/write ops directly, rather than this awkward loop.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas b6ebee038f swscale/vulkan/ops: move fractional read/write rejection to implementation
Rather than testing for it separately for some reason.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:57 +01:00