Commit graph

939 commits

Author SHA1 Message Date
llyyr
6e1c8748ff render: introduce bt.1886 transfer function 2025-10-04 18:13:37 +05:30
Félix Poisot
c2d9ae2142 render: introduce Gamma 2.2 color transform 2025-10-03 19:39:17 +00:00
Simon Ser
2ec4012559 backend/drm: avoid error message when EDID is missing
We'd attempt to parse an EDID even when the connector has no EDID,
printing "Failed to parse EDID" in logs. Instead, don't attempt to
parse the EDID and print a more appropriate log message.
2025-10-01 15:14:46 +02:00
Simon Ser
8c7041c4e8 backend/drm: relay full HDR metadata 2025-06-26 11:02:26 +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
b482e9089b backend/drm: add support for image description transfer function 2025-06-18 00:11:33 +02:00
Simon Ser
f024d1b8c8 backend/drm: add support for color primaries 2025-06-18 00:07:58 +02:00
Simon Ser
f10dd1da1c backend/drm: add support for color transforms 2025-06-16 09:06:10 +00:00
David Turner
2420bfef0b backend/drm: Fix segfault in libliftoff startup
With labwc and WLR_DRM_FORCE_LIBLIFTOFF=1, a segfault is seen on startup
because we call output_state_get_buffer_src_box() when there is no
buffer set in the output state.  Fix this by getting the src/dst box
from state->primary_viewport instead.
2025-05-08 10:13:57 +00:00
YaoBing Xiao
22db307e4c backend/drm: assign plane_id from function parameter instead of drm_plane 2025-04-30 17:10:45 +08:00
YaoBing Xiao
648aee65ad backend/drm: rename conn_name to conn_type_name for clarity 2025-04-27 15:33:36 +00:00
YaoBing Xiao
3ad4374a54 backend/drm: add DRM object and property IDs to error 2025-04-18 17:36:05 +08:00
Kirill Primak
5fd43add1c Fix/cleanup includes a bit 2025-04-15 20:13:29 +03:00
Simon Ser
99da6ccc87 backend/drm: pass DRM_MODE_ATOMIC_NONBLOCK for test commits
The kernel performs some additional checks when
DRM_MODE_ATOMIC_NONBLOCK is supplied: it requires that none of the
planes are still busy with a previous page-flip.

Pass the flag during test-only commits so that we don't end up
performing a commit which will fail.
2025-03-24 12:45:47 +00:00
Simon Ser
94cb8e2bc7 backend/drm: fix enabling an output with a custom mode set
Since 5567aefb1c ("backend/drm: Don't add pollute fixed modes
list with custom modes"), when a custom mode is set on an output,
current_mode will be NULL.

Instead of checking current_mode, check width/height.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3946
2025-03-07 13:00:06 +00:00
Simon Ser
ca1f9f86e6 backend/drm: handle custom modes in connect_drm_connector()
On startup, some connectors might be already lit up with a custom
mode. We weren't correctly populating the current output state in
this case.
2025-03-07 13:00:06 +00:00
Simon Ser
a64e1a58b1 backend/drm: log when creating multi-GPU renderer
Creating a renderer results in lots of logs. Make it clear that
the logs belong to a multi-GPU renderer (as opposed to a primary
renderer created by the compositor).
2025-01-30 02:10:58 +00:00
llyyr
9ab87167b5 backend/drm: don't leak mgpu_formats 2025-01-16 14:58:59 +00:00
Kirill Primak
8f56f7ca43 Assert (almost all) signals have no attached listeners on destroy 2025-01-15 19:53:11 +03:00
Simon Ser
c0881bdc01 output: require commit after hardware cursor update
Up until now only the DRM backend required an output commit after
updating the cursor. Unify this for all backends, because:

- Screen capture can now catch cursor updates listening for output
  commits
- In the future we want to make the cursor a regular wlr_output_layer,
  which would need an output commit to be updated anyways
2025-01-14 16:42:12 +01:00
Kirill Primak
d5d650f9f6 output: introduce wlr_output_finish() 2025-01-08 16:06:12 +00:00
Simon Ser
b908d865b1 backend: replace get_buffer_caps hook with a struct field
Do the same as wlr_renderer: the supported buffer capabilities are
static for the lifetime of the backend.
2024-12-25 18:40:05 +00:00
Consolatis
be555a9a99 backend/drm: make drm_lease implementation follow docs
This ensures compositors get a output_destroy signal when the
lease is granted and a new_output signal when the lease is revoked.
2024-12-21 01:00:12 +01:00
Simon Ser
c6dd5e3c2e backend/drm: check buffer format for multi-GPU
Fixes on-screen corruption when displaying a fullscreen client
with an implicit modifier on the secondary GPU.

What happens here:

- Client allocates a buffer with an INVALID modifier on primary GPU.
- Compositor attempts to scan-out this buffer on an output connected
  to secondary GPU.
- Buffer is imported to secondary GPU, and is interpreted as if it had
  the secondary GPU's implicit tiling, even though it has the primary
  GPU's implicit tiling.

We need to forbid cross-device imports with implicit modifiers.
The mgpu_formats list is stripped from any INVALID modifier so
checking that fixes the bug.

Using the mgpu_formats list has an additional benefit: the buffer
is rejected in the test commit if it doesn't have a format supported
by the multi-GPU renderer.

Requires this Mesa bugfix:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31725
2024-11-28 20:27:48 +01:00
Simon Ser
3e651b4642 backend/drm: fix drmModePageFlip() when disabling CRTC on legacy uAPI
drmModePageFlip() will fail with EBUSY on a disabled CRTC.

We can't fix this by clearing the DRM_MODE_PAGE_FLIP_EVENT when
performing a commit which disables CRTCs, because some device-wide
commits might also page-flip other enabled CRTCs (and skipping the
page-flip event would mess up our buffer tracking).

Fix this by immediately completing page-flips which disable a CRTC
on the legacy uAPI.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3918
2024-11-23 15:29:44 +01: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
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
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
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
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