Commit graph

594 commits

Author SHA1 Message Date
Derek Foreman
978052f9ed drm: Use weston_log_scope_puts when we don't have a format string
We can use __VA_OPT__ to make a macro that automatically selects between
the puts and printf log scope variants.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-14 17:12:05 +03:00
Derek Foreman
77eb13f499 drm,renderers: Remove some unnecessary indirection
pnode->view->surface is the same as pnode->surface, always.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
f5fb552b57 drm: Fix stale comment that refers to weston_view
This is passed a weston_paint_node, not a weston_view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
6a06562b77 drm: Rename find_plane_for_view
We're passing a paint node already, so let's just change the name.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
1ec218026a compositor: Store view alpha in the paint node
This is one of the few things backends and renderers still need to grab
from the view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
d85618a029 drm: rename node to pnode in drm_output_find_plane_for_view
Cosmetic meddling.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
a0f860ad70 drm: Stop using weston_view in drm_assign_planes
We can get all these things from surface through paint node.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
501f6d31b1 drm: Stop using weston_view in try_paint_node_on_plane
We've removed all need for this now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
9042fd41d7 drm: Store paint node instead of view in plane state
The paint_node life cycle should match the output's, so we should be able
to store it in the state instead of a view.

This gets us closer to having the backends stop caring about views.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
6f09ba42bd compositor: Add cursor layer status to paint nodes
Store this in the paint node so we don't have to look it up in the view
in the backends.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
838d6d92be drm: Don't use weston_view in drm_output_find_plane_for_view
We can get what we need via the paint node.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
c1fcfd288d drm/state-propose: remove output asserts in z_order_list walks
We already validate the paint node list in weston_output_repaint,
immediately after we conditionally rebuild the z_order_list.

These asserts are thus completely redundant, as we've already
performed them in the front end.

My reason for removing this now is to drop weston_view usage
from the backend.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
96676d114c drm: Don't use weston_view in drm_fb_get_from_paint_node
We have no need for a weston_view here.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
3c53883d78 drm: Use is_fully_opaque from paint node in drm_fb_get_from_paint_node
The paint node early update has already checked this value for us, we
should use that instead of interacting with the view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
9022976412 drm: Log paint node internal names instead of view internal names
Backends work on paint nodes, not views - and the paint node internal
name is a superset of the view internal name anyway, so it's not hard to
figure out which view a paint node belongs to when reading debug text.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
ef5164aa06 drm: Pass a paint node to dmabuf_feedback_maybe_update
The failure reason is already part of the paint node, so passing the view
here just makes things a little bit more complicated.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:40:04 -05:00
Derek Foreman
300c41858c drm: Use surface from paint node in drm_fb_get_from_paint_node
One fewer reasons to keep use the weston_view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:40:04 -05:00
Derek Foreman
b3d18455dd drm: Change node to pnode in drm_output_prepare_cursor_paint_node
Cosmetic meddling.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:40:03 -05:00
Derek Foreman
dd88c1fddd drm: rename node to pnode in drm_output_try_paint_node_on_plane
Cosmetic meddling.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:40:02 -05:00
Derek Foreman
febd93e4da compositor: Replace view_has_valid_buffer with paint_node_had_valid_buffer
Backends should be relying on paint nodes for their information, not
views.

Since we always have a paint node when we want to pass a buffer, we can
pass that instead of a view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:39:58 -05:00
Derek Foreman
f4a56f057f drm: Pass paint node to drm_fb_compatible_with_plane
The backends shouldn't care about views as much as they do,
so pass the paint node.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:38:03 -05:00
Derek Foreman
69efa21e08 drm: Pass paint node to cursor_bo_update
This doesn't need anything view related, and we already have the node.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:38:03 -05:00
Derek Foreman
4b7586ea15 drm: Don't test reused states
We shouldn't need to test state, because the state that worked previously
should work again. However, to be completely safe against unpredictable
edge cases, we've kept a state check.

Remove that check and instead force a state rebuild in the case of an
application failure.

Keep track of how often this happens so we can fall back to checking
instead of consistently failing state application.

fixes #1081

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-08 08:27:02 -05:00
Daniel Stone
fcb195cbd0 drm-backend: Reuse prior state where possible
If we're in a steady state, doing nothing but flipping buffers, we can
try to avoid going through our full routine of brute-forcing an
acceptable plane state, by instead just reusing the old state and
changing only the FB it refers to.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-08 08:27:02 -05:00
Derek Foreman
96e9f4e4ba drm: Remove switch in state-propose
Now that only overlay planes are on the handle list, we can simplify this
code a little bit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 13:59:54 -05:00
Derek Foreman
bf16894809 drm: Remove cursor and scanout handles from the plane handle list
Just put the "normal" planes on that list. This will allow for
some simplification later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 13:59:54 -05:00
Derek Foreman
8b7e72d8fa drm: Allow building a planes-only state with no primary
Some drivers allow a planes-only state as long as something covers
the entire CRTC, and some allow planes-only state even with only
partial coverage.

If we have an fb that we'd like to put on the primary plane, but can't,
we might as well try it on an overlay anyway and see if we can build a
planes-only state without a primary.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 13:59:52 -05:00
Derek Foreman
d665061f4d drm: special case the primary plane
While not as weird as the cursor plane, the primary plane's case is
pretty weird. Pull it out of the loop and handle it early.

This is really intended to be a step torwards building a planes-only
output state without a primary plane in it at all.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 13:58:51 -05:00
Derek Foreman
fe686c9646 drm: Check the cursor plane outside of the plane loop
The cursor code is weird, so let it be weird before the loop
that tests normal planes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 13:13:51 -05:00
Derek Foreman
a7e35ddac1 drm: refactor plane tests
Pull out a bunch of the plane check code into a function so we can use it
later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 12:32:40 -05:00
Derek Foreman
b7844bc8dd drm: Move fence check before underlay check
There's no need to evaluate these in any particular order, but I'm
going to refactor all the check unrelated to underlays into a single
place shortly.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 12:32:40 -05:00
Derek Foreman
1f900aa553 drm: Check if underlays are present before trying to use them
Trying to use an underlay will always fail if the output doesn't support
them, so add a quick check here.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 12:32:40 -05:00
Derek Foreman
7833a01b4d drm: Reword comment in find_plane_for_view
The text can be a bit confusing, so try to clarify it a little bit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 12:32:40 -05:00
Derek Foreman
2f460b513f drm: Change the renderer skip logic
There's only one mode where we can skip the renderer, let's base the check
on that instead of checking for an existing scanout fb.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 12:32:37 -05:00
Derek Foreman
0dd1d390be state-helpers: use shared xmalloc
Just use the shared xmalloc() instead of malloc+assert

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 12:30:47 -05:00
Leandro Ribeiro
04a85ab71c drm: use output capture task destroy listener for writeback
No behavior changes; this is a follow-up of "drm: handle client buffer
destroyed while writeback scheduled".

That commit protects against clients disconnecting while a writeback job
is scheduled, which could otherwise lead to crashes if the buffer is
destroyed before the wb job completes. However, output capture provides
the same functionality: it listens to the client buffer destroy event to
retire the capture task.

Instead of listening to the wl_buffer destroy event, simply listen to
the capture task destroy event. GL renderer already follows this
pattern, and now DRM aligns with it.

See also:
weston_capture_task_buffer_destroy_handler()
weston_capture_task_add_destroy_listener()

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-31 15:48:51 -03:00
Leandro Ribeiro
7444c29fd2 drm: assert writeback state is freed after capture task retirement
No behavior change, just a refactor to make it more clear that the state
is freed after the capture task is retired.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-31 15:47:13 -03:00
Leandro Ribeiro
a222e4c44b drm: retire writeback capture task if another is in progress
Before "drm: make writeback format negotiation more robust", pulling a
writeback capture task while another writeback was in progress could
lead to a crash.

That commit avoids the crash, but it relies on
drm_output_find_compatible_writeback() to fail if a writeback task is
already in progress, as the majority of hardware probably support a
single writeback connector compatible with the CRTC.

Although unlikely, hardware may support more than one writeback
compatible with the CRTC. That would break our code, as our writeback
implementation does not support simultaneous writeback tasks per output.

This adds an explicit check and retires the writeback task if there's
already another writeback in progress.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-26 14:17:14 -03:00
Leandro Ribeiro
35d35f31ff drm: make writeback format negotiation more robust
Currently drm_output_get_writeback_formats() returns the formats
supported by a single writeback connector compatible with output->crtc.
This list is used to populate struct weston_output_capture_source_info
through weston_output_update_capture_info().

Later, when pulling writeback capture tasks, we call
drm_output_get_writeback_formats() again. However, as
drm_output_find_compatible_writeback() skips writeback connectors in
use, the returned format list may now differ.

Also, when selecting a writeback connector we implicitly rely on
drm_output_find_compatible_writeback() returning the same connector as
before, without verifying that the chosen connector supports the format
of the buffer provided by the client.

Make drm_output_get_writeback_formats() return the union of formats
supported by all writeback connectors compatible with output->crtc. This
makes the returned format list deterministic, regardless of whether a
writeback connector is currently in use. Although most hardware probably
supports a single writeback compatible with the CRTC, this is a good
change as it makes the code more generic and robust.

Also, add a new format param to drm_output_find_compatible_writeback(),
so now the the selected writeback can be validated against the requested
format.

The main benefit of this patch (and the reason why I wrote) is enabling
us to fix an issue when a writeback task is already in progress and
additional ones are requested:

1. weston_output_pull_capture_task() depends on the writeback format
   list

2. if a writeback is already in progress,
   drm_output_get_writeback_formats() returns NULL (assuming there's a
   single writeback connector).

3. weston_output_pull_capture_task() crashes Weston, as the list of
   writeback formats we pass does not match the one stored in struct
   weston_output_capture_source_info.

With the format list now deterministic, we'll be able to safely pull the
capture task and retire it. The next commit implements this behavior.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-26 14:17:10 -03:00
Leandro Ribeiro
b71b347ac6 drm: rename drm_writeback_should_wait_completion() to try_complete()
This function does more than just checking if it should wait for
completion: it completes the screenshot if possible. So rename to avoid
confusion.

This also adds documentation to the function.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-26 14:16:22 -03:00
Leandro Ribeiro
1152c53e58 drm: handle client buffer destroyed while writeback scheduled
Currently when a client buffer gets destroyed, the output capture task
gets destroyed with weston_capture_task_buffer_destroy_handler().

The problem is that we may have a writeback task scheduled, so
wb_state->ct would be pointing to a ct that has already been retired
and destroyed.

In this commit we start handling this case.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-26 14:16:22 -03:00
Robert Mader
944ae353dd drm-backend: Implement offloading of solid-color backgrounds
Using the new BACKGROUND_COLOR CRTC property.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2026-03-26 17:20:11 +01:00
Robert Mader
77b1d4af96 backend-drm: Add support for the BACKGROUND_COLOR CRTC property
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2026-03-26 13:22:33 +01:00
Marius Vlad
c66d0ea09a backend-drm: Rename sprites with hardware planes
Perhaps this would make things a bit more obvious to newcomers not
being familiar with historical 2D bitmap hardware sprite.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-03-17 16:39:34 +02:00
Marius Vlad
dde648a25f man/weston-keybindings: Use generic hardware planes
This disables all of the hardware planes not just overlay (primary and
underlays as well). Change also the debug message.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-03-17 16:39:34 +02:00
Pekka Paalanen
ec74bd0403 Deprecate remoting and pipewire plugins
The intention is that you should be able to replace these with the
pipewire-backend that you can load together with the DRM-backend. The
functionality should be equivalent, but the libweston software
architecture becomes more maintainable for upstream. Also the
pipewire-backend is not tied to the DRM-backend, and can work with any
other backend and even alone.

Once the remoting and pipewire plugins are gone, we can remove the
virtual output API from DRM-backend.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-17 16:10:38 +02:00
Derek Foreman
7c3e3d7544 drm: Remove VAAPI recorder
This was deprecated, and now it is gone.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-03-16 16:00:20 +02:00
Marius Vlad
f454723d4f backend-drm: Move out comments in else branch
No functional change, just move the comments in the else branch.

Added with 5429302e, ("backend-drm: add KMS plane's formats to
per-surface dma-buf feedback").

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-03-16 13:06:24 +02:00
Pekka Paalanen
6077ba5fec backend-drm: use bits_to_str_stream() in state-propose
Before, these pieces of code were allocating, formatting and freeing the
bit flags string regardless of whether debug logging was used or not.

Now, the bit flags string is formatted only when debug logging is
active, and it does not involve malloc+free.

This should improve performance a bit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00
Pekka Paalanen
c5dcdacdc0 backend-drm: refactor open-coded connector_add_prop()
The only difference is a small one in the debug print, otherwise this is
completely identical.

Makes drm_pending_state_apply_atomic() slightly more maintainable.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00