Commit Graph

1777 Commits

Author SHA1 Message Date
Simon Ser
e9a6b3b85d backend/wayland: add support for explicit sync
wl_buffer.release event delivery becomes undefined when using the
linux-drm-syncobj-v1 protocol, so we need to wait for buffer
release via a timeline point instead.

The protocol requires both wait and signal timelines to be set, so
we need to create one when the compositor only supplies a wait
timeline.
2024-11-11 15:22:22 +00:00
Kenny Levinsen
f440c60128 backend/drm: Remove redundant error logs
wlr_renderer and wlr_allocator will print out errors as they go, and end
with a final error if they fail to create anything. The caller of this
function will also log when it fails.

Skip the redundant errors emitted here.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
0108506c77 backend/drm: Allow proceeding with render-less mgpu
If an mgpu device does not have a renderer, continue without one rather
than ignoring it entirely. It is not guaranteed that we will be able to
scan out to it in any particular configuration, but that is true for any
output regardless, and having the output visible is not harmful even if
it cannot light up.

To proceed safely, we strip implicit modifier support from all planes,
while avoiding duplication of the same logic for mdgpu_formats.

This helps GUD and DisplayLink scenarios.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
66ddd62e42 backend/drm: Move mgpu renderer setup to function
This helps readability a bit and will make error handling in a coming
commit easier.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
b2bb111f03 backend/drm: Check for mgpu_renderer instead of parent
The presence of the renderer is what matters with respect to blitting.
Having a parent without the need to blit will be allowed later.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
1dd05437bf backend/drm: Bail if renderer cannot import DMA-BUFs
We create a renderer for the sole purpose of blitting buffers from a
primary renderer that we might not be able to scan-out from. If we end
up with the pixman renderer, it either won't work becuase it cannot
import dmabufs from the primary renderer, or won't have any effect
because the primary renderer already uses dumb buffers.

We test for DMA-BUF capabilities specifically to make it clear what our
interest is, rather than focusing too much on the pixman renderer.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
55f15d1abd backend/drm: Ensure renderer is set to NULL on error
If init_drm_renderer failed, it would destroy the renderer but would not
set it to NULL, leading to use-after-free.

NULL the renderer after destroying it.
2024-11-08 13:45:05 +01:00
Kenny Levinsen
014023c14f backend/drm: Set timeline support based on capability
We assumed that all atomic backends supported syncobj, but gud does not.
Instead, query DRM_CAP_SYNCOBJ_TIMELINE when using the atomic backend.
2024-11-08 13:45:05 +01:00
Simon Ser
4c4d74a564 backend/drm: use public wlr_allocator_autocreate()
We don't need any custom behavior since d8c0707e27 ("backend/drm: return
secondary backend DRM FD").
2024-11-07 18:50:25 +01:00
Simon Ser
4ec1defb3e all: use public <wlr/render/allocator.h>
We don't need to use the private header in these files.
2024-11-07 18:48:20 +01:00
Simon Ser
baeecc8dbd backend/wayland: handle DMA-BUF import failures
create_immed() is a bit dangerous because on failure, either the
connection is closed or the buffer is silently ignored.

Use create() with a roundtrip to figure out whether the import
succeeded.
2024-11-07 14:42:01 +00:00
Kenny Levinsen
63fabecee2 backend/wayland: Account for shm buffer offset
If we are trying directly scan-out a shm buffer, we create a temporary
buffer pool to instantiate a wl_buffer from, created in accordance to
our buffers size. If the buffer has an offset, it will end up out of
bounds of the created pool.

Extend the temporary pool by the buffer offset to compensate. Matching
the original pool size does matter unless we want to optimize away the
temporary pool to reduce mappings in the parent compositor.
2024-11-07 14:45:23 +01:00
llyyr
d835fa813f backend/multi: only consider backends with dmabuf cap for timeline
timeline feature will never be applicable to backends without it, so
don't check it. Before this commit, it would cause timeline to be set
to false if libinput ended up being the last item in the list (which is
the case currently).
2024-10-30 23:10:59 +00:00
Kenny Levinsen
c1ce983826 backend/drm: Store only a single plane viewport
We store both queued and current buffers to be able to retain both the
framebuffer currently on screen and the one queued to replace it. From a
re-use perspective, we only care about the last committed framebuffer.

The viewport is only stored in order to be re-used together with the
last committed framebuffer, so do away with the queued/current
distinction and store a single viewport updated every time a commit
completes.
2024-10-29 11:18:48 +01:00
Kenny Levinsen
1edd5e224f backend/drm: Remove reset from interface
The reset implementations are no longer used.
2024-10-29 11:13:13 +01:00
Kenny Levinsen
0f255b46fc backend/drm: Remove automatic reset on VT switch
Instead of trying to restore the drm state when the session is activated
again, just disconnect all outputs when the session is deactivated. The
scan that triggers on session activation will rediscover the connectors.
2024-10-28 21:20:30 +01:00
Kenny Levinsen
3df1528a8f backend/drm: Store viewport with framebuffer
Accessing the output state viewport require a buffer, and that might not
have a state with a buffer when preparing the plane properties for an
atomic commit.

Instead, store the properties at the same time as the fb, and use a
similar mechanism to carry the state around.
2024-10-28 19:22:27 +00:00
Kenny Levinsen
7717c92ed0 backend/drm: Skip plane props if buffer is not committed
If our session is re-activated during scanout, restore_drm_device will
reset planes and then attempt an enabling modeset commit without a
buffer. The new plane transform logic requires a committed buffer to be
present to calculate the boxes if they were not explicitly provided, and
at least amdgpu rejects commits that try to use 0 as default.

Skip updating plane props instead of segfaulting if no buffer is set.

A better fix would be to not rely on restore_drm_device at all and
instead require compositors to modeset in response to session
activation.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3912
2024-10-28 02:14:49 +01:00
Simon Ser
e8e76dc295 backend/drm: check whether clipped damage is empty
We were checking whether the damage region was empty before
clipping. However a non-empty damage region can become empty after
clipping. Instead, check whether the clipped region is empty.

Fixes: 4339c37f99 ("backend/drm: clip FB damage")
2024-10-26 13:07:10 +02:00
Peng Liu
0ba1982488 backend/x11: delete xcb conn check NULL
xcb_connect always returns a non-NULL pointer
to a xcb_connection_t, even on failure.

Signed-off-by: Peng Liu <liupeng01@kylinos.cn>
2024-10-24 09:02:41 +00:00
Isaac Freund
da8f7a07ba
backend/headless: actually perform output test
Currently the headless backend does not actually implement the
wlr_output_test function, causing tests containing output state
unsupported by the headless backend to succeed while committing the same
state will always fail.

This commit fixes that by actually hooking up the already exisiting test
function.

References: https://codeberg.org/river/river/issues/1154
2024-10-24 10:49:08 +02:00
David Turner
c87ab6465d Support direct scanout with src crop and dst boxes
Enable scene-tree direct scanout of a single buffer with various options
for scaling and source crop. This is intended to support direct scanout
for fullscreen video with/without scaling, letterboxing/pillarboxing
(e.g. 4:3 content on a 16:9 display), and source crop (e.g. when
1920x1088 planes are used for 1920x1080 video).

This works by explicitly specifying the source crop and destination box
for the primary buffer in the output state.  DRM atomic and libliftoff
backends will turn this into a crop and scale of the plane (assuming the
hardware supports that).  For the Wayland/X11/DRM-legacy backends I just
reject this so scanout will be disabled.

The previous behaviour is preserved if buffer_src_box and buffer_dst_box
are unset: the buffer is displayed at native size at the top-left of the
output with no crop.

The change to `struct wlr_output_state` makes this a binary breaking
change (but this works transparently for scene-tree compositors like
labwc after a recompile).
2024-10-22 18:28:09 +01:00
Kenny Levinsen
ba0cc8eb05 backend/multi: Advance index on backend_commit
wlr_multi_backend sorts the states it is given and tries to perform
sequential backend-wide commits for each sub-backend with the states
that belong to it.

It did not manage the index correctly for the next iteration, so given N
states for a backend it would perform N backend-wide commits.

Clarify the logic by calculating a length rather than an end pointer and
update the index after each iteration.
2024-10-15 17:32:54 +02:00
Simon Ser
3b3ed21e61 backend/drm: fix timeline feature flag on multi-GPU setups
This piece of code checks for multi-GPU renderer support, so it
needs to run after the renderer is initialized.

Fixes: 514c4b4cce ("backend: add timeline feature flag")
Closes: https://github.com/swaywm/sway/issues/8382
2024-10-12 17:12:29 +02:00
Simon Ser
1e949402b0 output: drop output timeline flag
This has been superseded by the backend-wide feature flag.
2024-10-11 17:11:35 +00:00
Simon Ser
514c4b4cce backend: add timeline feature flag
The output feature flag has a flaw: it's not possible to check
whether the backend supports timelines during compositor
initialization when we need to figure out whether we want to enable
the linux-drm-syncobj-v1 protocol.

Introduce a backend-wide feature flag to indicate support for
timelines to address this defect.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3904
2024-10-11 17:11:35 +00:00
Kirill Primak
56d69320c7 pointer: release pressed buttons on destroy 2024-09-24 19:53:54 +00:00
YaoBing Xiao
7debaced03 x11/backend: Optimize query_version error handling
Signed-off-by: YaoBing Xiao <xiaoyaobing@uniontech.com>
2024-09-12 17:52:26 +08:00
Kenny Levinsen
96ad414ec9 backend/drm: Remove call to CRTC realloc on scan
After a connector scan, new connectors might have appeared and old ones
gone away. At this point, old CRTC allocations are already gone, while
new allocations are not yet needed. Skip the call.
2024-09-09 13:22:56 +00:00
Simon Ser
234d31f138 backend/drm: improve doc comment for match_connectors_with_crtcs_()
- Add general description
- Mention the computer theory problem that this is solving
- More wording cleanup
2024-09-02 17:12:32 +00:00
Simon Ser
0d6284eb62 backend/drm: add explicit sync support to libliftoff interface 2024-08-26 18:21:50 +02:00
Simon Ser
d7223eae02 backend/drm: add explicit sync support to multi-GPU blits 2024-08-26 18:09:27 +02:00
YaoBing Xiao
a5aae69b2a backend/drm: remove unnecessary semicolons 2024-08-24 08:36:46 +00:00
Simon Ser
5432108846 backend/drm: drop SKIP in match_connectors_with_crtcs()
It's unused.
2024-08-21 22:25:19 +02:00
Simon Ser
5f3b99bbed backend/drm: rename i param in match_connectors_with_crtcs_()
Use a more descriptive name to make it clear what kind of index
this is.
2024-08-21 22:25:19 +02:00
Simon Ser
1e03719361 backend/drm: drop match_connectors_with_crtcs() return value
It's unused.
2024-08-21 22:25:19 +02:00
Simon Ser
0bf642d246 backend/drm: use more descriptive names for match_obj()
This function is only used for connectors and CRTCs, so instead of
the abstract "obj"/"resource" wording, just use the concrete names.
2024-08-21 22:25:19 +02:00
Simon Ser
d2a5dbe104 backend/drm: use CRTCs in-order
When lighting up a new connector, we'd use the last CRTC instead of the
first one. This causes issues because drivers have the expectation that
userspace will match CRTCs to connectors in-order [1].

The order has regressed a long time ago in 5b13b8a12c ("backend/drm:
consider continue not using resources"). That commit was a fix to
avoid moving a connector between CRTCs [2]. Revert that commit and
use a different approach: even if we've found a solution, always try
not using a CRTC in the hope that we'll find another solution with
less CRTC replacements.

[1]: https://lore.kernel.org/dri-devel/20240612141903.17219-2-ville.syrjala@linux.intel.com/
[2]: https://github.com/swaywm/wlroots/issues/1230

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3098
2024-08-21 15:17:04 +00:00
YaoBing Xiao
43554c1966 types/wlr_output: removing the useless pointer 2024-08-21 14:04:24 +00:00
Alexander Orzechowski
bfcaa4bc44 swapchain, damage_ring: Drop buffer age 2024-08-21 09:45:54 -04:00
Dudemanguy
3d2f09bace backend/drm: fix a use-after-free
The page_flip can be destroyed, but it is unconditionally accessed later
on when setting present_flags. Fix this by simply setting the
present_flags before the page_flip gets destroyed.
2024-08-19 13:46:41 -04:00
Kirill Primak
310a5eb61c backend/wayland: simplify wl_keyboard.{enter,leave} processing 2024-08-15 18:33:00 +00:00
Isaac Freund
08495d2596 backend/drm: don't set vsync present flag if page flip was async 2024-08-15 15:11:10 +00:00
Kirill Primak
3103ea3af9 backend/wayland: process initial events from globals correctly
Previous logic could lead wlr_wl_backend.drm_render_name being written
to twice, causing a memory leak. This commit fixes the race condition.
2024-08-15 12:52:05 +03:00
project-repo
3cae2a2c01 Fix memory leak in drm.c 2024-08-12 14:06:10 +00:00
Kirill Primak
8730ca9661 seat/pointer: handle duplicate presses/releases correctly 2024-08-06 22:53:08 +00:00
Simon Ser
3067e45c2e backend/drm: add support for explicit sync APIs 2024-08-06 17:37:06 +00:00
Simon Ser
a35b4f059d backend/drm: add support for SIZE_HINTS property
This property allows the driver to advertise support for multiple
cursor sizes. On Intel, using a smaller buffer size reduces power
consumption.

References: https://lore.kernel.org/dri-devel/20240227193523.5601-2-ville.syrjala@linux.intel.com/
2024-07-10 22:42:44 +00:00
Simon Ser
0028e0638f backend/wayland: use wl_shm.release if available 2024-07-07 18:16:48 +02:00
Simon Ser
0a79bc28c7 build: require libinput v1.19
This version has been published back in 2021.
2024-07-04 22:51:07 +02:00