Commit Graph

194 Commits

Author SHA1 Message Date
chenyongxing
015bb8512e render/vulkan: Fix draw rect clip region invalid in blend none mod 2024-07-16 14:24:46 +08:00
Kenny Levinsen
bf67eb342b render/vulkan: vkMapMemory stage spans up front
We always need these mapped for CPU access, so map it up front instead
of duplicating lazy mapping at each site of use.
2024-06-26 21:10:46 +00:00
Kenny Levinsen
bf0246e50c render/vulkan: Fix 3dlut stage span map offset
The mapping is shared between all users of the stage span, so it should
always map the whole thing and apply the allocation offset to the mapped
pointer.
2024-06-26 21:10:46 +00:00
Kenny Levinsen
6da71b6a89 render/vulkan: Unref color transform on pass submit
We increment the ref counter of the color transform at the start of the
render pass. Decrement it at the end to not leak the color transform.
2024-06-26 22:43:15 +02:00
Kenny Levinsen
bc82835756 render/vulkan: Use new span map handling for 3dlut
The use of stage spans for 3dluts was missed when the new cached
mappings were introduced, meaning that it would try to map and unmap
memory that might already have a cached mapping.

Vulkan does not support mapping memory multiple times, so make sure the
3dlut code also uses the cached mapping to avoid segfaults after unmap.
2024-06-26 13:14:07 +02:00
Kenny Levinsen
53464074e9 render/vulkan: Unmap span before freeing memory 2024-06-26 13:13:40 +02:00
Kenny Levinsen
47c578945c render/vulkan: Recycle memory maps for stage spans
Remapping buffers on every use causes a lot of unwanted pagefaults.
Reuse the mapping to significantly speed up the memcpy.
2024-06-24 15:55:10 +00:00
Simon Ser
2c4d3ad12d render/vulkan: don't use UNDEFINED layout for imported DMA-BUFs
UNDEFINED when used as source layout means that the contents of
the underlying memory becomes undefined. This isn't what we want
here: we don't want to mutate the imported pixel data.

The Vulkan spec isn't really clear what the proper value should be
here, but after discussing with driver developers [1] it seems like
UNDEFINED isn't the right one. The recommendation is to use GENERAL
instead.

[1]: https://github.com/ValveSoftware/gamescope/issues/356
2024-05-14 13:14:28 +02:00
Kirill Primak
f0b7fb72a8 render/vulkan: don't free a descriptor set from an already destroyed lut3d dummy pool 2024-05-09 19:07:54 +03:00
Kirill Primak
073c3e8837 render/vulkan: free render format setups on destroy 2024-05-09 18:47:02 +03:00
Kirill Primak
e20ae113f8 render/vulkan: free pipeline layouts on destroy 2024-05-09 18:46:55 +03:00
Kirill Primak
00bc75439f render/vulkan: fix texture clip region leak 2024-05-09 18:40:31 +03:00
Manuel Stoeckl
82b4bc3f5f renderer: add field to indicate color transform support 2024-04-26 17:17:36 +00:00
Manuel Stoeckl
ffdbfdbbbd render/vulkan: add support for output color transforms 2024-04-26 17:17:36 +00:00
Manuel Stoeckl
e443434876 render/vulkan: create plain framebuffers on demand
This change makes it possible to support both the direct srgb-format
pipeline and indirect (color-managed, or non-srgb-format) pipeline
for the same render buffer.
2024-04-26 17:17:36 +00:00
Manuel Stoeckl
adbfd3c321 render/vulkan: add lut3d output shader option
While a corresponding pipeline is created, it is not yet used.
2024-04-26 17:17:36 +00:00
Manuel Stoeckl
c64144a39b render/vulkan: add dummy 3d lookup table to output shader
Later commits will add shader options that use a real 3d
lookup table.
2024-04-26 17:17:36 +00:00
Simon Ser
ebef710746 renderer: replace get_render_buffer_caps() with struct field 2024-04-22 11:38:30 +02:00
Simon Ser
85c1eda721 render: unify getter for texture formats
Instead of having separate getters for shm formats and DMA-BUF
formats, use the same pattern as wlr_output_impl.get_primary_formats
with a single function which takes buffer caps as input.
2024-04-21 11:27:29 +00:00
John Lindgren
b1b34cd665 vulkan: perform sRGB-to-linear conversion correctly for premultiplied values
Pre-multipled sRGB values need to be un-multiplied before conversion
to linear and then re-multiplied after. Compare shaders/texture.frag.

This fixes an issue in labwc where titlebar corners (rendered as
ARGB textures) did not match the rest of the titlebar (rendered as
a solid wlr_scene_rect).

Note: 0.17 has other instances in render/vulkan/renderer.c that need
the same fix.
2024-04-11 09:24:03 +00:00
Biswapriyo Nath
dd2061b073 render/vulkan: Fix clang compiler error in 32 bit ARM Android
This adds proper calling convention attribute for callbacks used in vulkan
and fixes the following compiler error.

../src/render/vulkan/vulkan.c:175:22: error: incompatible function pointer types
initializing 'PFN_vkDebugUtilsMessengerCallbackEXT' (aka 'unsigned int (*)
(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct
VkDebugUtilsMessengerCallbackDataEXT *, void *) __attribute__((pcs("aapcs-vfp")))')
with an expression of type 'VkBool32 (*)(VkDebugUtilsMessageSeverityFlagBitsEXT,
VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *, void *)'
(aka 'unsigned int (*)(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int,
const struct VkDebugUtilsMessengerCallbackDataEXT *, void *)')
[-Wincompatible-function-pointer-types]
    .pfnUserCallback = &debug_callback,
                       ^~~~~~~~~~~~~~~
2024-04-10 14:03:38 +00:00
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
Simon Ser
842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Leo Li
71fb55f3bf render/pixel-format: Move has_alpha into it's own array
Some opaque pixel formats (nv12, p010) require per-plane bytes_per_block
info. However, it doesn't make sense to store them in
wlr_pixel_format_info, as they will never be useful (currently, this
info is used for shm, which doesn't have a concept of multi-planar
buffers.)

Let's define a separate array and function for determining whether a
pixel format has alpha.
2024-01-31 13:47:17 -05:00
Félix Poisot
5ae8ce807a render/vulkan: correct sRBG gamma expansion in shader 2024-01-26 13:50:55 +00:00
Kirill Primak
3eb89e5325 render/vulkan: fix possible double free 2024-01-17 15:44:37 +00:00
Simon Ser
a0b1329ee6 Fix bool return types
This makes wlroots build in C23 mode.

C23 is more strict and rejects implicit conversions from bool to a
pointer.
2024-01-04 22:24:06 +01:00
Manuel Stoeckl
d6859da3b4 render/vulkan: use _SRGB image view when possible
This is the last of a set of commits which ensures that both textures
and render buffers can be accessed through _UNORM and _SRGB image
views. While _UNORM image views are not yet used for 8-bpc image
formats, they will be needed in the future to support color transforms
for both textures and render buffers.
2023-12-04 15:13:31 +00:00
Manuel Stoeckl
566c413d8f render/vulkan: constify vulkan_format_props_find_modifier 2023-12-04 15:13:31 +00:00
Manuel Stoeckl
88a4b9eefd render/vulkan: create VkImage with option for _SRGB view, if possible 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
d3a339a03e renderer: Drop buffer binding 2023-11-30 20:11:50 -05:00
Alexander Orzechowski
3ed1268f64 render: Nuke old read pixels API
Sadly, the new API is not backwards compatible with the old API. Since
we have already switched all users in wlroots to the new API compositors
are already practically mandated to implement the new API. Let's get rid
of the old one since there is no point.
2023-11-30 20:01:12 -05:00
Alexander Orzechowski
c5a3c5ca4c render: Implement texture_preferred_read_format 2023-11-30 20:01:12 -05:00
Alexander Orzechowski
09f16b2a9c render/vulkan: Implement texture_read_pixels 2023-11-30 19:56:54 -05:00
Simon Ser
9a0a4ce221 render/vulkan: drop current_command_buffer
This was used by the legacy rendering API. Since begin()/end()
only need to set current_render_buffer and nothing else, we can
drop all of these bits.
2023-11-28 12:56:30 +00:00
Simon Ser
b2aac3390d render/vulkan: drop legacy rendering API 2023-11-22 11:36:17 +01: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
eri
3232697252 render/vulkan: use VK_KHR_global_priority
References: #3386
2023-10-26 16:17:57 +00:00
Simon Zeni
1c2f608331 render/vulkan: remove unused queue_props in renderer 2023-10-26 15:12:58 +00:00
Brett Ernst
47bf87ade2 renderer/vulkan: don't add two alphas together in blend func 2023-10-21 17:25:46 +00:00
Simon Ser
5adf325333 render/vulkan: undo alpha premult before sRGB encoding/decoding
sRGB encoding/decoding needs to happen with straight alpha, not
pre-multiplied alpha.
2023-10-17 17:28:56 +02:00
Manuel Stoeckl
e0adaaffb6 render/vulkan: constrain blend to output subpass to redrawn region
This commit only applies to the render pass API.
2023-10-05 11:45:32 +00:00
Alexander Orzechowski
1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Alexander Orzechowski
e9706e62f5 renderer: Use wlr_render_rect_options_get_box
Fixes: #3697
2023-09-21 02:25:34 -04:00
Manuel Stoeckl
5aea90264f render/vulkan: fix validation error with vkCmdBlitImage
Specfically, VUID-vkCmdBlitImage-srcImage-00247.
2023-09-10 15:28:57 -04: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
Alexander Orzechowski
5f6912595e renderer/vulkan: Defer device lost signal until end of pass
If the compositor were to try to handle a GPU reset within the lost
signal (by recreating the renderer) we should avoid referencing renderer
resources after the lost signal. This prevents use after free for such
compositors.
2023-08-20 21:12:06 -04:00