Commit graph

2685 commits

Author SHA1 Message Date
Derek Foreman
a84db969f4 compositor: Rename weston_surface_commit_state
We'll eventually have a hard split between the commit and the application
of state, so rename this function to better indicate what it does.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
ee90650c8c compositor: Make subsurface->synchronized a bool
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Jonas Ådahl
ed6beb1dbf compositor: Make surface state caching reusable
Intended to be used by other inter surface synchronization mechanisms
than subsurfaces.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
724d3707ec pipewire: Shoot down unsatisfiable capture tasks
If there's no running connection, we can't capture, so just burn down any
waiting tasks so we don't assert later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Derek Foreman
c54c421d21 gl-renderer: Listen to capture destroy signals
Listen to the capture destroy signal so we can prevent the async fd
source from causing a UAF.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Derek Foreman
263290c677 gl-renderer: Move destroy_capture_task
Simple code motion to help with a later commit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Derek Foreman
d2bab8a5ee libweston: Add an output capture task destroy listener
An output task may be destroyed by a client disconnect. This causes
problems for our drm backend's asynchronous capture task handler, which
currently has no way to notice this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Pekka Paalanen
48cc12cfc5 color-lcms: return cmsHTRANSFORM from xform_realize_chain()
No functional change.

This will help to keep the code more straightforward when
parametric<->ICC color transformations are added, and they need more
operations than just the cmap_3dlut for the 3D LUT.

Particularly, there will be a new flag telling if cmap_3dlut is
populated, and the flag is best set in init_icc_to_icc_chain() instead
of xform_realize_chain().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
13e7a3addb color-lcms: renames in_prof/out_prof
Shorter shorthands are nicer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
4e286bd297 color-lcms: add mask for allowed steps
When crafting an ICC to ICC color transformation, all the steps in
weston_color_transformation are at disposal. In the future also
parametric<->ICC color transformations will be crafted using the same
ICC chain machinery. However, there some steps must be reserved for
additional operations.

Add a bit mask that tells which color steps can be used by
xform_realize_icc_chain().

Unfortunately the mask is most conveniently stored in struct
cmlcms_color_transform. The LittleCMS context user data is the only good
way of passing our own bits into the factory code, but the user data
cannot be reset without destroying the context. It is probably not safe
to destroy the context as long as we have any LittleCMS objects alive
and created in that context. Hence, the user data must out-live the
LittleCMS context.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
dfea094772 color-lcms: prefix color_transform_step values
I will be adding a MAPPING value, and it would look odd without any
prefix. This adds a bit of namespacing.

The definition is moved to the header, because I will be needing it in
struct cmlcms_color_transform.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
0974359b8f color-lcms: split into xform_realize_icc_chain()
Split init_icc_to_icc_chain() into two parts:
- init_icc_to_icc_chain() is specific for ICC to ICC transformation
- xform_realize_icc_chain() can process any chain of cmsHPROFILEs

xform_realize_icc_chain() will be used by ICC-to-parametric and
parametric-to-ICC transformations in following commits.

No changes to functionality. 'extra' local variable is lost as unused.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
9500bbe844 color-lcms: rename xform_realize_chain to init_icc_to_icc_chain
I will be splitting this function, and xform_realize_chain() matches the
parts I'm going to split out of it, while the remainder will be specific
to icc-to-icc transformations.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Leandro Ribeiro
c594aa22cb backend-drm: offload post-blend color transformation to KMS
In this patch we allow offloading the post-blend color transformation
to KMS.

As KMS currently only supports to offload the transformation in a LUT,
this may result in precision issues. So this introduces the config
option "offload-blend-to-output", which is disabled by default.

This option requires "color-management" to be enabled, otherwise it is
ignored.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
e77ca25a80 color: fail weston_color_curve_to_3x1D_LUT() when !xform->steps_valid
This is a leftover from "color: do not use color steps for non-optimized
pipelines". If a xform don't have valid steps, it shouldn't have curves.
So this function should fail.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
fceb4151a3 color: allow creating LUT from curve even when bad precision may occur
At this point, the DRM/KMS API supports offloading post-blend color
xform only through LUT's. This is not ideal, and an API to improve that
should be proposed in the future.

But we still want to experiment with offloading pre-blend (not post)
color transformation through the colorop API, which is close to being
accepted upstream. But this requires us to offload post-blend as well.

weston_color_curve_to_3x1D_LUT() currently fails if we detect that
crafting a LUT from the color curve may result in bad precision.
Instead, let's add a boolean param to control if we forbid or not bad
precision. This should allow us to offload post-blend xform through
LUT's.

This also improves the error messages in this function.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
6f969623eb backend-drm: do not disable underlay planes based on b->format
Since commit "backend-drm: improve code that chooses output->format", we
changed how b->format (the GBM format from the config file) is used.

There are config options in weston.ini that allow us to ignore the GBM
format set. So what matters to us is which output->format is being used,
and we compute that in drm_output_pick_format_egl() and
drm_output_pick_format_pixman().

So remove these checks that disable underlay planes based on b->format,
keeping only the ones that depend on the output->format selection.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
56c27ea248 backend-drm: improve code that chooses output->format
Instead of picking an arbitrary format, let's first ensure that the
format is supported by the renderer.

Also, start choosing formats with alpha channel if we have b->underlay.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
ed7ceef37e gl-renderer: do not set compositor capabilities on failure
When gl_renderer_display_create() fails, do not change the compositor
capabilities.

The compositor may not abort when that happens, it may simply decide to
fallback to another renderer. So setting anything on failure is wrong.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
c10857df5d gl-renderer: add function to query supported rendering formats
This goes through all formats available in the EGLConfig's that we
get from EGLDisplay and expose them in a struct weston_drm_format.

Currently backends choose a format for their outputs and hope that
GL-renderer is able to find a compatible EGLConfig. This should help
backends to avoid guessing.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
dd5e1f5047 libweston: rename get_supported_formats to get_supported_dmabuf_formats
Let's be more more specific and rename the renderer interface function
that returns the supported dma-buf formats. I.e. if we pass a dma-buf
with one of these formats for the renderer, it should be able to import
it.

Next we'll introduce a function to query the rendering formats from
the renderer, so this distinction is important.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
fba356e44d gl-renderer: log EGLConfig component type
Now that we also support EGLConfig with floating-point, let's log this
information.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
b5ed927960 gl-renderer: properly log EGLConfig vis id
To log vis id, we call:

eglGetConfigAttrib(egldpy, eglconfig, EGL_NATIVE_VISUAL_ID, &value)
p = pixel_format_get_info(value)

The problem is, EGL_NATIVE_VISUAL_ID represents a DRM format only on
GBM platform. So for other platforms we are calling
pixel_format_get_info() with values that are not DRM formats.

Avoid calling pixel_format_get_info() when the platform is different
from GBM, and log only the hex value in such case.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
0c986257f9 gl-renderer: change params of a few functions
No behavior change, just to make things easier for next commits. They
will need struct gl_renderer *gr in print_egl_config_info().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
ec646f34d6 gl-renderer: add support to query EGL configs with float-point formats
Currently when we have a blend-to-output color transformation, we have a
16FP shadow buffer representing the blending space. Then we blit from
that to the primary plane fb, which is a regular buffer (fixed-point,
not 16bpc).

The shadow buffer needs to be 16FP because the blending space is linear
with relation to light. So it needs more bits for encoding.

In the next patches we enable the option to offload the blend-to-output
color transformation to KMS, so we'll need the primary plane fb to be
of a 16FP format. In order to do that, we need to be able to find EGL
configs with float-point formats. In this patch we enable that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
3cad1c7716 libweston: remove set_gamma()
The plugins cms-static and cms-colord have been deprecated and removed
from our code. They were the only thing holding set_gamma() from being
removed. So remove set_gamma() from the code.

Users can have the same results tweaking the output color profile that
they use.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Michael Olbrich
66cdb7d9bc backend-rdp: implement set_dpms
set_dpms() is used for sleep/wakeup. output_repaint_timer_handler() resets the
repaint_status if called while Weston is sleeping. If the timer is still active,
it will trigger a call to weston_output_finish_frame() which then triggers an
assertion, because the repaint_status is not REPAINT_AWAITING_COMPLETION.
Stop the timer and reset the repaint_status in this case to avoid this.

Schedule a repaint for WESTON_DPMS_ON to ensure that the current state is
rendered.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2025-08-04 14:56:26 +00:00
Michael Olbrich
2a7b4f52e7 backend-x11: implement set_dpms
set_dpms() is used for sleep/wakeup. output_repaint_timer_handler() resets the
repaint_status if called while Weston is sleeping. If the timer is still active,
it will trigger a call to weston_output_finish_frame() which then triggers an
assertion, because the repaint_status is not REPAINT_AWAITING_COMPLETION.
Stop the timer and reset the repaint_status in this case to avoid this.

Schedule a repaint for WESTON_DPMS_ON to ensure that the current state is
rendered.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2025-08-04 14:56:26 +00:00
Michael Olbrich
afc19c2e94 backend-vnc: implement set_dpms
set_dpms() is used for sleep/wakeup. output_repaint_timer_handler() resets the
repaint_status if called while Weston is sleeping. If the timer is still active,
it will trigger a call to weston_output_finish_frame() which then triggers an
assertion, because the repaint_status is not REPAINT_AWAITING_COMPLETION.
Stop the timer and reset the repaint_status in this case to avoid this.

Schedule a repaint for WESTON_DPMS_ON to ensure that the current state is
rendered.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2025-08-04 14:56:26 +00:00
Michael Olbrich
d076f2c519 backend-pipewire: implement set_dpms
set_dpms() is used for sleep/wakeup. output_repaint_timer_handler() resets the
repaint_status if called while Weston is sleeping. If the timer is still active,
it will trigger a call to weston_output_finish_frame() which then triggers an
assertion, because the repaint_status is not REPAINT_AWAITING_COMPLETION.
Stop the timer and reset the repaint_status in this case to avoid this.

Schedule a repaint for WESTON_DPMS_ON to ensure that the current state is
rendered.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2025-08-04 14:56:26 +00:00
Michael Olbrich
b5843ed366 backend-headless: implement set_dpms
set_dpms() is used for sleep/wakeup. output_repaint_timer_handler() resets the
repaint_status if called while Weston is sleeping. If the timer is still active,
it will trigger a call to weston_output_finish_frame() which then triggers an
assertion, because the repaint_status is not REPAINT_AWAITING_COMPLETION.
Stop the timer and reset the repaint_status in this case to avoid this.

Schedule a repaint for WESTON_DPMS_ON to ensure that the current state is
rendered.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2025-08-04 14:56:26 +00:00
Derek Foreman
f132462df7 compositor: Don't pass a time to weston_output_repaint()
Nothing does anything with this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-08-01 15:08:00 +00:00
Pekka Paalanen
72ed2c12d8 color-lcms: parametric to parametric transformations
This implements the basic color transformation from parametric to
parametric image description. The colorimetric rendering intents are
implemented. The perceptual and saturation rendering intents are
equivalent to media-relative + BPC rendering intent, subject to be
implemented better later.

Things missing:
- handling target color volumes
- perceptual dynamic range mapping

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 17:32:11 +03:00
Pekka Paalanen
8c2c429fd5 color-lcms: parametric blend-to-output
Implement blend-to-output transformation for parameteric output image
descriptions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 13:14:34 +03:00
Pekka Paalanen
3737c9adb6 color-lcms: re-structure transformation creation
We will eventually have 6 different paths for creating color
transformations:
- input to blend, input to output
  - ICC to ICC
  - parametric to parametric
  - ICC to parametric
  - parametric to ICC
- blend to output
  - ICC
  - parametric

Set up their dispatching.

No changes to existing functionality.

xform_realize_chain() is now guaranteed to be called only with ICC
profiles.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 13:14:22 +03:00
Pekka Paalanen
3b3fa61c31 color: add Bradford matrix computation
This function is required for media-relative rendering intents.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 13:14:01 +03:00
Pekka Paalanen
b32f353003 color: add NPM computation
This function is required for producing color transformations from
parametric image descriptions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 13:13:38 +03:00
Pekka Paalanen
37bee3050e color-lcms: override sRGB two-piece TF on input profile
https://gitlab.freedesktop.org/pq/color-and-hdr/-/blob/main/doc/wayland_qa.md#q-should-srgb-content-be-decoded-with-the-piecewise-srgb-transfer-function

When anything claims to target a display with the sRGB two-piece
transfer function, override it with the power-2.2. That is how sRGB
displays actually work.

This patch includes a small refactoring in
cmlcms_color_transform_create().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 13:13:26 +03:00
Pekka Paalanen
3999d685bc color-lcms: call it a color transform recipe
I've been wanting a better name than search_param. In the future they
are not always search parameters when we have to replace the input
profile with another one for sRGB power-2.2 decoding purposes.

I think "recipe" describes this struct well: it's the list of
ingredients to cook a color transformation from.

This patch is purely renaming things.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 13:13:14 +03:00
Pekka Paalanen
67cfcaa0ac color-lcms: remove cmlcms_color_transform.status
This field is redundant, and therefore only confusing.

The success or not is returned from xform_realize_chain() directly. The
color processing steps vs. 3D LUT is recorded in
weston_color_transform.steps_valid.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-07-28 13:12:47 +03:00
Derek Foreman
5a1e925759 wayland-backend: Remove unused cairo_device_t
The frame_device variable wasn't used in the commit that added it, and
later another commit that performed a bunch of clean-up bookkeeping added
cairo_device_destroy() for it. This was non-destructive because
cairo_device_destroy() handles NULL gracefully, but still Very Weird.

Remove it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-07-23 08:02:43 -05:00
Leandro Ribeiro
3f81d2fd38 compositor: let backends handle output->disable_planes
On weston_output_repaint(), we have:

output_assign_planes(output);
...
output->repaint(output);

output_assign_planes() avoids calling output->assign_planes() when
output->disable_planes > 0. This brings a few complications to backends,
because they can't rely on the repaint loop starting from a certain
function: sometimes it starts from assign_planes(), others from
repaint().

Let's be more consistent: always call assign_planes() and let backends
handle output->disable_planes.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-07-18 17:58:45 +02:00
Leandro Ribeiro
3eed20254c backend-drm: add missing FAILURE_REASONS_FORCE_RENDERER
If we call drm_output_find_plane_for_view() with
DRM_OUTPUT_PROPOSE_STATE_RENDERER_AND_CURSOR for a view that is not a
cursor view, it should fail to get a plane.

In such case, set the failure reason to FAILURE_REASONS_FORCE_RENDERER.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-07-18 17:58:45 +02:00
Leandro Ribeiro
2efc1838cb backend-drm: rename renderer-only to renderer-and-cursor mode
In the next commit we introduce a real "renderer-only" mode. So let's
rename DRM_OUTPUT_PROPOSE_STATE_RENDERER_ONLY to
DRM_OUTPUT_PROPOSE_STATE_RENDERER_AND_CURSOR, as it also assign views
to cursor planes.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-07-18 17:58:45 +02:00
Derek Foreman
5a48cedc7b drm: Improve VRR timing at start of repaint loop
There was an old kernel bug where the drm driver could give us a stale
timestamp. We worked around this by performing a page flip at the
start of the repaint loop.

Now that we support VRR, when we don't render our refresh rate drops to the
display's lowest possible refresh rate. This leaves us with a race where
the repaint loop could be started between the mode's refresh rate and the
lowest possible VRR rate - which is indistinguishable from a stale
timestamp. In this case we'd perform a needless page flip and potentially
miss an opportunity to render.

The kernel bug was introduced in v3.16 in commit 844b03f27739135 and later
fixed in v4.1 in commit fdb68e09bbb1c98

Since the vrr_capable property was introduced in v4.20 in commit
ba1b0f6c73d4ea1, any kernel that supports VRR is new enough not to give us
stale timestamps, so we don't have to miss these opportunities.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-06-27 14:51:49 +01:00
Erico Nunes
2d34d32893 vulkan-renderer: support dmabuf renderbuffers
Initial support for dmabuf renderbuffers, based on the GL renderer
implementation.
This enables Vulkan renderer to use the pipewire backend with dmabuf.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-06-25 14:12:22 +00:00
Erico Nunes
33c418a85b vulkan-renderer: rework Vulkan dmabuf import
Rework the dmabuf import Vulkan code so that it is possible to reuse
a single routine across the DRM backend gbm import and dmabuf client
import.
This is will also make it possible to reuse it for dmabuf renderbuffers
as a follow-up.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-06-25 14:12:22 +00:00
Erico Nunes
4685cb1d1c vulkan-renderer: rework render_fence_fd
Decouple render_fence_fd from the DRM output, in particular so that
it is allowed in headless outputs (for upcoming dmabuf renderbuffers).
Also simplify the code to make it clear that it is handled per-output.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-06-25 14:12:22 +00:00
Erico Nunes
1a9d46e3bc vulkan-renderer: move render_done semaphore to image
For swapchain outputs, in some cases it is possible that a frame becomes
available by its fence but the last used swapchain image has still not
been returned to the swapchain. If the render_done semaphore is part of
the frame struct it will be reused and cause a validation error.
To prevent this from happening, move the render_done semaphore to the
image struct so that each of those semaphores is only used when the
associated image is safely acquired from the swapchain.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-06-25 14:12:22 +00:00
Marius Vlad
feb4fd1386 compositor, frontend: Allow to configure placeholder-color
This is a trivial change to allow passing a user-defined color to
specify the color for the placeholder.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-06-24 16:00:05 +03:00