Commit graph

934 commits

Author SHA1 Message Date
Simon Ser
0b58bddf13 render/color: add wlr_color_transform_pipeline
Useful to apply multiple transforms in sequence, e.g. sRGB inverse
EOTF followed by gamma LUTs.
2025-10-18 20:36:01 +02:00
Simon Ser
3d36ab9211 render/color: add wlr_color_transform_eval()
Makes it so the Vulkan renderer can handle arbitrary color
transforms, and doesn't need to be updated each time a new one is
added.
2025-10-18 20:35:02 +02:00
llyyr
6e1c8748ff render: introduce bt.1886 transfer function 2025-10-04 18:13:37 +05:30
Félix Poisot
d8fb7adcf0 scene, render: use Gamma 2.2 TF as default 2025-10-03 19:48:12 +00:00
Félix Poisot
c2d9ae2142 render: introduce Gamma 2.2 color transform 2025-10-03 19:39:17 +00:00
Simon Ser
60d72724cd render/color: fix bounds check in lut_1d_get()
i == len is out-of-bounds.

Fixes: 74217a4d93 ("render/color: introduce COLOR_TRANSFORM_LUT_3X1D")
2025-09-30 09:34:40 +02:00
Simon Ser
d1c88e9497 render/vulkan: add linear single-subpass
When the TF is set to EXT_LINEAR, we can write out color values
straight up to a non-SRGB image view.
2025-09-20 10:50:22 +00:00
Simon Ser
3e88a79e6f render/vulkan: replace wlr_vk_render_pass.srgb_pathway with two_pass
The important bit here is whether this is using a single or two
sub-passes. The flag isn't used for anything else.

Preparation for an upcoming one-subpass codepath.
2025-09-20 10:50:22 +00:00
Simon Ser
b2d09cdee9 render/vulkan: add wlr_vk_render_pass.render_buffer_out
Simplifies the logic and prepares for a new render setup.
2025-09-20 10:50:22 +00:00
Simon Ser
35eba5f2fe render/vulkan: add wlr_vk_render_pass.render_setup
Simplifies the logic and prepares for a new render setup.
2025-09-20 10:50:22 +00:00
Simon Ser
a91f96b391 render/vulkan: introduce wlr_vk_render_buffer_out
Holds common state for final output buffer targets.
2025-09-20 10:50:22 +00:00
Simon Ser
6fee3623e4 render/vulkan: rename vulkan_setup_srgb_framebuffer() for linear
Rename to "one-pass" (to indicate no blending buffer is involved),
because this will get re-used when introducing a linear
single-subpass codepath.
2025-09-20 10:50:22 +00:00
Simon Ser
7f6d66ea62 render/vulkan: use sRGB image view when color transform is set
If the color transform is set to sRGB inverse EOTF, we can use the
sRGB image view just like when no color transform is passed in.
2025-09-20 10:50:22 +00:00
Simon Ser
54374b6fe6 render/vulkan: rename plain to two_pass
We will introduce a new subpass without any post-processing step.
Rename "plain" so that there's no confusion.
2025-09-20 10:50:22 +00:00
Kenny Levinsen
dd7f543189 render/vulkan: Handle multi-descriptor sets
A combined image sampler may need several descriptors in a descriptor
set. We are not currently checking how many descriptors are required,
nor is it presumably guaranteed that such multi-descriptor allocation
will not fail due to fragmentation.

If the pool free counter is not zero, try to allocate but continue with
the next pool and fall back to creating a new pool if the allocation
failed.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/4010
2025-09-20 07:59:02 +00:00
Simon Ser
e95117b700 render/vulkan: remove hardcoded counts
Use the array size instead.
2025-08-27 14:26:21 -04:00
Simon Ser
1a18e47efa render/vulkan: fix VkPushConstantRange for wlr_vk_frag_texture_pcr_data
We pass an alpha multiplier plus a luminance multiplier now.

Fixes the following validation layer error:

    vkCmdPushConstants(): is called with
    stageFlags (VK_SHADER_STAGE_FRAGMENT_BIT), offset (80), size (72)
    but the VkPipelineLayout 0x510000000051 doesn't have a VkPushConstantRange with VK_SHADER_STAGE_FRAGMENT_BIT.
    The Vulkan spec states: For each byte in the range specified by offset and size and for each shader stage in stageFlags, there must be a push constant range in layout that includes that byte and that stage (https://docs.vulkan.org/spec/latest/chapters/descriptorsets.html#VUID-vkCmdPushConstants-offset-01795) (VUID-vkCmdPushConstants-offset-01795)

Fixes: 56d95c2ecb ("render/vulkan: introduce wlr_vk_frag_texture_pcr_data")
2025-08-27 14:26:21 -04:00
xurui
b0c886ec77 render/allocator/gbm: insert buffer after export gbm bo
Signed-off-by: xurui <xurui@kylinos.cn>
2025-08-25 14:05:13 +08:00
YaoBing Xiao
c14aa1d0b8 render/vulkan: destroy vulkan instance when drm phdev mismatch 2025-07-15 08:59:37 +08:00
Simon Ser
48bd1831fe render/egl: fix software rendering check
Commit b4ce0d8b39 ("render/egl: accept negative DRM FD to select
software rendering") added an EXT_device_drm check to figure out
whether the user selected a device with a DRM FD or without one.
However, for KMS-only devices, Mesa will never advertise the
selected KMS node:
3f1d40d230/src/egl/main/egldevice.c (L109)

Instead, pass down a parameter to indicate whether a DRM FD was
passed in.

Fixes: b4ce0d8b39 ("render/egl: accept negative DRM FD to select software rendering")
2025-06-29 10:57:56 +02:00
Simon Ser
ae85c31176 render/vulkan: add luminance multiplier for texture shader 2025-06-18 19:37:55 +00:00
Simon Ser
fa1feb447f render, render/vulkan: add primaries to wlr_render_texture_options 2025-06-18 19:37:55 +00:00
Simon Ser
a8144088df render/vulkan: add support for PQ for textures 2025-06-18 19:37:55 +00:00
Simon Ser
3a51a5c623 render/vulkan: add texture color transformation matrix 2025-06-18 19:37:55 +00:00
Simon Ser
56d95c2ecb render/vulkan: introduce wlr_vk_frag_texture_pcr_data
Contains UBOs for texture.frag.
2025-06-18 19:37:55 +00:00
Simon Ser
ec422ac389 render/vulkan: prepare texture shader for new transforms 2025-06-18 19:37:55 +00:00
Simon Ser
8d1c6e42ac render/vulkan: add support for texture transfer functions 2025-06-18 19:37:55 +00:00
Simon Ser
0ee0452af0 render/color, render/vulkan: add EXT_LINEAR to enum wlr_color_transfer_function 2025-06-18 19:37:55 +00:00
Simon Ser
f5a0992686 render/vulkan: fix multiplication order for output color matrix
This had the same bug as the texture side, but I forgot to fix it.

See:
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4988#note_2867416

Fixes: f3524de980 ("render, render/vulkan: add primaries to wlr_buffer_pass_options")
2025-06-18 21:25:37 +02:00
Simon Ser
7b6eec530c render/vulkan: add luminance multipler for output shader 2025-06-18 00:11:33 +02:00
Simon Ser
4470683591 render/color, render/vulkan: add support for PQ transfer function 2025-06-18 00:11:31 +02:00
Simon Ser
8430a1922d render/vulkan: add PQ inverse EOTF to output shader 2025-06-18 00:09:25 +02:00
Simon Ser
f3524de980 render, render/vulkan: add primaries to wlr_buffer_pass_options 2025-06-18 00:07:35 +02:00
Simon Ser
a5706e2fb9 render/vulkan: use array declaration in encode_proj_matrix()
This makes it more obvious what the final layout of the matrix will
be.
2025-06-17 19:41:29 +02:00
Simon Ser
1df2274f6c render/vulkan: rename mat3_to_mat4() to encode_proj_matrix()
This function is specific to projection matrices.
2025-06-17 19:35:16 +02:00
Simon Ser
30c6efedf1 render/vulkan: use output_pipe_srgb for non-NULL sRGB color transform 2025-06-17 18:50:25 +02:00
Simon Ser
2ea0e386c4 render/vulkan: add color transformation matrix 2025-06-17 18:47:50 +02:00
Simon Ser
74217a4d93 render/color: introduce COLOR_TRANSFORM_LUT_3X1D
This will be useful to apply LUTs applied via wlr_gamma_control_v1,
and to add wlr_color_transform support to wlr_output.
2025-06-16 09:06:10 +00:00
Simon Ser
3665b53e29 render/color: replace COLOR_TRANSFORM_LUT_3D with COLOR_TRANSFORM_LCMS2
Converting the LCMS2 transform to a 3D LUT early causes issues:

- It's a lossy process, the consumer will not be able to pick a
  3D LUT size on their own.
- It requires unnecessary conversions and allocations: an intermediate
  3D LUT is allocated, but the renderer already allocates one.
- It makes it harder to support arbitrary color transforms in the
  renderer, because each type needs to be handled differently.

Instead, expose a function to evaluate a color transform, and use
that to build the 3D LUT in the renderer.
2025-06-16 09:06:10 +00:00
Simon Ser
9b97e2607d render/color: use variable instead of type in sizeof()
Conforms to the wlroots code style.
2025-06-16 09:06:10 +00:00
Simon Ser
d421538b4a render/color: add wlr_color_transform_init() 2025-06-16 09:06:10 +00:00
Simon Ser
8fb4e4dabb swapchain: assert that size is not empty at creation time
Failing later (at buffer allocation time) makes it more difficult
to track down where the issue comes from.
2025-06-16 07:54:00 +00:00
Simon Ser
bb50c7a5a4 render/allocator/gbm: require GBM 21.1
Mesa 21.1 was released back in 2021. Let's require it so that we
can simplify our build and remove the workaround.
2025-06-16 07:43:01 +00:00
DreamMaoMao
a08acfcee0 render/pass: Ensure the precision is consistent during comparison 2025-05-29 21:50:21 +08:00
YaoBing Xiao
70add22e74 render/pixman: null check on newly created image 2025-05-07 21:33:22 +08:00
YaoBing Xiao
f36f856cdb render/drm_syncobj: fix return type mismatch 2025-05-06 17:48:54 +08:00
Simon Ser
e57dd9c5ef render/vulkan: check binary semaphore in vulkan_sync_render_buffer()
Ensure the binary semaphore is available when we need it.
2025-05-05 22:17:11 +02:00
Simon Ser
d4e4c9f64b render/vulkan: create binary semaphore when signal timeline is supplied
We were only creating the binary semaphore when implicit sync
interop was available. We also use the binary semaphore when
explicit sync is enabled.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3973
2025-05-05 22:17:04 +02:00
Kirill Primak
5fd43add1c Fix/cleanup includes a bit 2025-04-15 20:13:29 +03:00
Simon Ser
10b8880fc7 render/color: add wlr_color_transfer_function_get_default_luminance() 2025-03-30 16:21:26 +02:00