Commit Graph

37 Commits

Author SHA1 Message Date
Kenny Levinsen 4d68d3759b render/vulkan: Avoid double-free on calloc error
In query_modifier_support, the calloc for either or both of render_mods
and texture_mods may fail, in which case both are freed for convenience.
However, if one is non-NULL, vulkan_format_props_finish will try to free
it again.

NULL them to avoid double-free.
2024-02-22 23:07:58 +01:00
Manuel Stoeckl 566c413d8f render/vulkan: constify vulkan_format_props_find_modifier 2023-12-04 15:13:31 +00:00
Manuel Stoeckl fd4548bb93 render/vulkan: detect which _UNORM formats support _SRGB views 2023-12-04 15:13:31 +00:00
Manuel Stoeckl acc70ee3a5 render/vulkan: extract shm texture format query into function 2023-12-04 15:13:31 +00:00
Manuel Stoeckl eab89d6c76 render/vulkan: track and use _UNORM variants of _SRGB formats
Later commits will start using _SRGB image views again,
where appropriate.
2023-12-04 15:13:31 +00:00
Alexander Orzechowski 09f16b2a9c render/vulkan: Implement texture_read_pixels 2023-11-30 19:56:54 -05:00
Manuel Stoeckl dbe7fb7027 render/vulkan: undo alpha premult for 8-bpc ARGB/ABGR
When a texel from the Vulkan format VK_FORMAT_B8G8R8A8_SRGB is read,
the sRGB to linear conversion is applied independently to the R, G,
and B channels; the A channel has no influence on this. However,
DRM_FORMAT_ARGB8888 buffers are, per Wayland protocol, not encoded
in this fashion; one must first unpremultiply the color channels
before doing sRGB to linear conversion. This commit switches to
handling ARGB8888 and ABGR8888 formats using the general fragment
shader conversion from electrical to optical values.
2023-11-21 11:08:55 +00:00
Simon Ser 65bbbbbf0c render/vulkan: de-duplicate VkImageUsageFlags
The flags passed to vkCreateImage() must match the flags used when
querying formats. Make this clearer by using the same variable.
2023-09-09 23:32:28 +00:00
Simon Ser 709c9dd287 render/vulkan: rename tex_usage to shm_tex_usage
Same motivation as fdb199a43c ("render/vulkan: rename
tex_features to shm_tex_features").
2023-06-12 12:02:22 +00:00
Simon Ser 1b947c08c6 render/vulkan: require format info for shm
We use the format info to check the stride and need it to perform
the texture upload.
2023-06-07 10:06:27 +00:00
Simon Ser cebe991e95 render/vulkan: split off YCbCr texture features
Avoids repeating the common bits between dma_tex_features and
dma_tex_ycbcr_features, and we will need just the YCbCr-related
flags for shm YCbCr support soon.
2023-06-07 10:06:27 +00:00
Simon Ser fdb199a43c render/vulkan: rename tex_features to shm_tex_features
These features are required for shm only: the TRANSFER stuff is
for texture upload. We don't need these for DMA-BUFs. Make this
clearer by changing the name.

Also re-order the definitions to group all texture-related features
together.
2023-06-07 10:06:27 +00:00
Simon Ser 3de330ec85 render/vulkan: add 10, 12, and 16-bit YCbCr formats 2023-05-28 14:51:19 +00:00
Simon Ser 16dea12dae render/vulkan: add more YCbCr formats
The Vulkan spec states:

> For the purposes of range expansion and Y′CBCR model conversion,
> the R and B components contain color difference (chroma) values
> and the G component contains luma.

The equations below that sentence also help understand the mapping.
2023-05-24 08:58:59 +00:00
Simon Ser a682fa6c21 render/vulkan: require support for linear filter for YCbCr
YCBCR_CONVERSION_LINEAR_FILTER is not enough: this one only covers
chromaFilter. For magFilter/minFilter we need FILTER_LINEAR as well.
2023-05-24 08:58:59 +00:00
Simon Ser d7bebb0a4c render/vulkan: drop unnecessary comments
Some comments in here are noise.
2023-05-22 18:53:15 +02:00
Manuel Stoeckl 10dd416694 render/vulkan: allow rendering to non-8-bit buffers
This is implemented by a two-subpass rendering scheme; the first
subpass draws (and blends) onto a linear R16G16B16A16_SFLOAT buffer,
while the second subpass performs linear->srgb conversion, writing
onto the actual output buffer.
2023-05-12 15:09:02 +00:00
Simon Ser e353c5c631 render/vulkan: enable NV12 on big-endian
This format doesn't change its layout on big endian because it's
not packed and has 8-bit channels.
2023-05-11 07:25:32 +00:00
Simon Ser b03f71fe5f render/vulkan: add support for NV12 2023-05-04 20:07:20 +00:00
Simon Ser 337ef33edc render/vulkan: make shm/dmabuf split clearer in wlr_vk_format_props
struct wlr_vk_format_props contains a mix of properties for shm
and dmabuf, and it's not immediately clear which fields are for
which kind of buffer. Use a nested struct to group the fields.
2022-12-02 15:18:59 +00:00
Simon Ser db9d277614 render/vulkan: make vulkan_format_props_find_modifier() return value const 2022-12-02 15:18:59 +00:00
Simon Ser bc7f8de842 render/vulkan: improve message on format prop error
Use a more appropriate message on
vkGetPhysicalDeviceImageFormatProperties2() error.
2022-12-02 16:10:42 +01:00
Simon Ser 338a9616bd render/vulkan: simplify vulkan_format_props_query() 2022-12-02 16:10:41 +01:00
Simon Ser a3874cac6c render/vulkan: extract DMA-BUF format query to separate function 2022-12-02 16:09:58 +01:00
Simon Ser 21c4516838 render/vulkan: add 64-bit UNORM and SFLOAT formats 2022-12-02 10:36:36 +01:00
Simon Ser 9f938f7f2a render/vulkan: add more packed formats 2022-12-02 10:35:45 +01:00
Simon Ser 171c9081d1 render/vulkan: add more 8 bits per channel formats 2022-12-02 10:28:52 +01:00
Simon Ser ad165f7daf render/vulkan: explain format mapping with DRM 2022-12-02 10:24:00 +01:00
Simon Ser 8b9a48c984 render/vulkan: drop "_format" in wlr_vk_format fields
"format" is already in the name, no need to repeat ourselves.
`format->vk_format` sounds a bit redundant.
2022-12-02 10:24:00 +01:00
Simon Ser 0730552e85 render/vulkan: drop unused fields from wlr_vk_format_modifier_props
export_imported is never used, and dmabuf_flags is already checked
in query_modifier_support().
2022-11-28 10:22:56 +01:00
Manuel Stoeckl 3ed69b4946 render/vulkan: add support for RGB565 texture format
Since this does not have a matching _SRGB-type vulkan format, add a
new shader variant/pipeline to perform the sRGB->linear texture
conversion.
2022-11-25 14:19:27 +00:00
David96 dce1372e35 render/vulkan: Implement vulkan_read_pixels 2022-10-07 15:59:39 +00:00
Simon Ser bca60c4eec render/vulkan: improve format logging 2022-09-14 12:13:48 +02:00
Simon Ser 30769723c1 render/vulkan: fix format features check for shm textures
We were checking whether any of the features was supported. We need
to check if all of them are.

This makes the check consistent with query_modifier_support() above.
2022-09-07 15:46:38 +02:00
bi4k8 f295aff762 Add missing & 2022-06-11 20:41:16 +00:00
bi4k8 35d1bcff6f render/vulkan/pixel_format: do not leak props->...
`vulkan_format_props_query` calls `query_modifier_support` which
initializes fields of `props` with allocated memory. this memory is
leaked if `query_modifier_support` does not find a supported format
and shmtex is not supported, as in this case `add_fmt_props` ends
up being false and the allocated fields of `props` are never freed.
2022-06-11 20:25:35 +00:00
nyorain 8e34692250 render/vulkan: add Vulkan renderer
This new renderer is implemented with the existing wlr_renderer API
(which is known to be sub-optimal for some operations). It's not
used by default, but users can opt-in by setting WLR_RENDERER=vulkan.

The renderer depends on VK_EXT_image_drm_format_modifier and
VK_EXT_physical_device_drm.

Co-authored-by: Simon Ser <contact@emersion.fr>
Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
2021-10-18 11:51:13 +02:00