Commit Graph

1541 Commits

Author SHA1 Message Date
Rose Hudson 9e8947e4d5 add render timer API
Based on five calls:
wlr_render_timer_create - creates a timer which can be reused across
  frames on the same renderer
wlr_renderer_begin_buffer_pass - now takes a timer so that backends can
  record when the rendering starts and finishes
wlr_render_timer_get_time - should be called as late as possible so that
  queries can make their way back from the GPU
wlr_render_timer_destroy - self-explanatory

The timer is exposed as an opaque `struct wlr_render_timer` so that
backends can store whatever they want in there.
2023-06-05 19:50:07 +00:00
Simon Ser 4e513c93bd backend/wayland: add support for cropping output layers 2023-06-05 18:29:55 +00:00
Simon Ser 4c5eadecce backend/wayland: add scaling support for output layers
Use the viewporter protocol to scale output layers.
2023-06-05 18:29:55 +00:00
Simon Ser 30aca4df0d backend/drm: introduce wlr_drm_mode_get_info()
This allows compositors to get back the raw drmModeModeInfo and
look at DRM-specific fields and flags.
2023-05-31 22:37:12 +00:00
Simon Ser 8fe29e6bd1 backend/drm: use new rendering API 2023-05-30 16:18:19 +00:00
Austin Shafer 0910fa9179 drm_plane_pick_render_format: return false if no format could be found
Commit 90d08f8f1c changed the way
wlr_drm_format_intersect worked, including passing in a destination
format list. This breaks scenarios where the intersection doesn't
find any matching formats, since we still have a valid destination
format set. This changes it to only return true if more than one
matching format is present in the intersection list.
2023-05-17 18:24:20 +00:00
Tobias Predel 3dc5c7e5e7 backend_destroy: Similiar logic like DRM backend
In the logic of the DRM backend in backend_destroy, wlr_backend_finish
is called first, then the outputs are destroyed and then the
display->destroy.link is removed from the list.

This commit applies the same order to the headless backend.
2023-05-15 20:21:23 +02:00
Alexander Orzechowski 300bd80772 wlr_drm_format_set: Store formats on array 2023-05-11 18:25:52 +02:00
Alexander Orzechowski 90d08f8f1c wlr_drm_format: Rework wlr_drm_format_intersect
Now it takes a reference to a destination format
2023-05-11 18:24:43 +02:00
Alexander Orzechowski b45396c790 wlr_drm_format: Introduce drm_format_finish 2023-05-11 03:51:01 -04:00
zhoulei 2c30500ce1 backend/drm: fix di_info memory leak 2023-05-08 10:16:25 +08:00
ptrcnull 56502be1d1 backend/x11: prevent segfault on empty DRI3 response 2022-05-01 06:13:58 +02:00
Simon Ser 44069dfd5e output-layer: add cropping support
Add a src_box state field. Use the SRC_* KMS props in the DRM
backend, reject the layers in the Wayland backend (for now, we can
support it later via viewporter).
2023-04-20 10:39:46 +02:00
Simon Ser 835208db98 output-layer: add support for scaling buffers
This allows callers to set a destination size different from the
buffer size to scale them.

The DRM backend supports this. The Wayland backend doesn't yet
(we'd need to wire up viewporter).
2023-04-04 19:39:38 +02:00
Simon Ser 89dcecba39 backend/wayland: only unmap layers when necessary 2023-03-28 22:58:29 +00:00
Simon Ser fcc092c2a6 backend/wayland: only update layer position when necessary 2023-03-28 22:58:29 +00:00
Simon Ser e8a2f76eb4 backend/wayland: only re-order sub-surfaces when necessary 2023-03-28 22:58:29 +00:00
Rose Hudson 37f42e2df2 backend/wayland: support touch cancel events
since wayland doesn't provide a touch id in cancel events, track what
points are active so we can cancel all of them

timestamp is also not provided - use 0 because no one's paying attention
to that anyway

Closes #3000
2023-03-24 11:47:08 +00:00
Simon Ser 1d64e12391 backend/drm: log drm_connector_alloc_crtc() failures
Helps figuring out why e.g. get_primary_formats fails.
2023-03-20 20:21:28 +01:00
Simon Ser 1b6fac4aa6 output-layer: require all layers in wlr_output_state.layers
- Simplifies the backends
- Avoids having two ways to do the same thing: previously one could
  disable a layer by either omitting it from wlr_output_state.layers,
  or by passing a NULL buffer
- We can change our mind in the future: we can allow users to omit
  some layers and define a meaning without breaking the API.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4017#note_1783997
2023-03-10 11:16:01 +00:00
Simon Ser 97c8ad7c65 backend/wayland: fix leak of some globals
Fix a few globals which weren't properly cleaned up. Discovered
in [1].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3604
2023-03-01 16:07:54 +01:00
Simon Ser af5cc860e1 backend/wayland: destroy zwp_linux_buffer_params_v1 objects
Don't leak these.
2023-02-28 20:05:46 +01:00
Simon Ser a160304289 backend/drm: use libdisplay-info for CVT mode generation 2023-02-28 14:44:02 +00:00
Simon Ser 35da997001 backend/drm: use libdisplay-info to parse EDID 2023-02-28 14:44:02 +00:00
Simon Ser bec94cc040 backend: move #ifdefs to nested functions
Instead of littering #ifdefs everywhere, move them to the dedicated
attempt_XXX_backend() functions. This makes the logic in
wlr_backend_autocreate() more readable, and provides better error
messages when the X11/Wayland backends are disabled at compile-time,
or when WLR_BACKENDS contains a backend disabled at compile-time.
2023-02-27 11:33:52 +01:00
Simon Ser 8acaabcbab backend: make wlr_backend_autocreate() fail when DRM is missing
When we change the required dependencies for the DRM backend,
Meson might auto-disable the backend for users missing the new
requirements. This results in confused users [1] because they don't
notice the "drm-backend: NO" line burried in the Meson logs, and
then get a black screen when starting the compositor.

Update wlr_backend_autocreate() to refuse to create a backend with
only libinput (without DRM).

Users really wanting to start their compositor with a libinput
backend and without a DRM backend can manually set WLR_BACKENDS.

[1]: https://github.com/swaywm/sway/issues/7457
2023-02-27 11:18:58 +01:00
Simon Ser b33ab26fe7 render/swapchain: make public
We've had this struct for a while. It'd be useful for compositors
if they want to manage the swap chains themselves instead of being
forced to use wlr_output's. Some compositors might also want to use
a swapchain without an output.
2023-02-21 17:14:31 +01:00
Simon Ser c667e64892 backend: disable DRM backend monitor when WLR_DRM_DEVICES is used
WLR_DRM_DEVICES specifies a static list of DRM devices to open
at startup.

Do not create DRM backends for hotplugged DRM devices when it's
set.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3595
2023-02-21 12:55:26 +01:00
Simon Ser 7303e13808 backend: avoid adding NULL backend in attempt_backend_by_name() 2023-02-21 12:52:20 +01:00
Simon Ser 2849712356 backend: create DRM backend monitor when WLR_BACKENDS is used 2023-02-21 12:51:46 +01:00
Simon Ser bea6bee55d backend/headless: unconditionally accept all output layers
We don't need to do anything special to handle these.
2023-02-21 10:12:35 +00:00
Simon Ser 8338d17d7e backend/drm: drop wlr_drm_layer.pending_{width,height}
No need to store this info in struct wlr_drm_layer. We can just
extract the size when we need it.
2023-02-21 09:45:47 +00:00
Simon Ser bbd5145d8a backend/drm: drop unnecessary pixman_region32_t casts
The Pixman API now accepts const parameters.
2023-02-21 09:37:59 +00:00
Simon Ser 22d9df2af4 backend/drm: send output layer feedback events 2023-02-20 18:38:57 +01:00
Simon Ser 4d6fbb2289 backend/drm: add support for output layers 2023-02-20 18:38:57 +01:00
Simon Ser 2398621b8b backend/drm: add libliftoff composition layer
This will be useful for implementing the output layers API.
2023-02-20 18:38:57 +01:00
Simon Ser 9d43e7e4d6 backend/drm: add libliftoff interface 2023-02-20 18:38:57 +01:00
Simon Ser b4e9487312 backend/drm: init wlr_drm_plane for all plane types 2023-02-20 18:38:57 +01:00
Simon Ser cd17b18495 backend/wayland: implement output layers 2023-02-20 18:38:57 +01:00
Simon Ser cfa7696d7b backend/wayland: handle wl_registry.global_remove for wl_seat
Destroy the struct wlr_wl_seat when the global is removed.
2023-02-02 18:24:38 +00:00
Simon Ser 2b5eb0733e backend/wayland: make destroy_wl_seats() handle a single seat
Instead of destroying all seats, destroy a single one. We only need
to destroy all seats at one call-site (backend_destroy), but we'll
need to destroy a single seat elsewhere in the next commit.
2023-02-02 18:24:38 +00:00
Simon Ser 8df62e4016 backend/drm: require hwdata pkg-config file
The hardcoded fallback "/usr/share/hwdata/pnp.ids" was only a
temporary solution to get things working while distributions were
still working on shipping it.
2023-02-02 18:15:29 +00:00
Simon Ser afa1a7f4ba backend/wayland: update output mode after commit is done
Do not update the output mode if the commit failed in one of the
error codepaths.
2023-02-02 17:24:37 +00:00
Simon Ser 2e49fa1a0a backend/wayland: allow superseding a previous commit
During a modeset, the core wlr_output logic will allocate a buffer
with a new size and commit it. However if we still have a frame
callback pending we'd refuse to perform the commit. This is
inconsistent with the DRM backend, which performs a blocking
modeset.

This is visible when resizing the Wayland toplevel. The logs are
filled with "Skipping buffer swap", and the wlr_damage_ring's
bounds are not properly updated.

Fix this by destroying the pending frame wl_callback.
2023-02-02 17:24:37 +00:00
Simon Ser c88ad532ad backend/wayland: don't cache next item when destroying buffers
Because wl_buffer.release is per-buffer and not per-commit, the
Wayland backend might create multiple struct wlr_wl_buffer per
struct wlr_buffer. As a result, the wlr_buffer_unlock() call inside
destroy_wl_buffer() can cause another struct wlr_wl_buffer to be
destroyed.

In backend_destroy() we were iterating the list of buffers with
wl_list_for_each_safe(), which is actually not safe in this case:
the next buffer is cached, but might be destroyed as a side-effect
of calling destroy_wl_buffer().

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3572
2023-02-02 16:45:09 +00:00
Simon Ser d36dd96e8d backend/drm: set "max bpc" property based on pixel format
Since 1d581656c7 ("backend/drm: set "max bpc" to the max") we
set the "max bpc" property to the maximum value. The kernel driver
is supposed to clamp this value depending on hardware capabilities.

All kernel drivers lower the value depending on the GPU capabilities.
However, none of the drivers lower the value depending on the DP-MST
link capabilities. Thus, enabling a 4k@60Hz mode can fail on some
DP-MST setups due to the "max bpc" property.

Additionally, it's not a good idea to unconditionally set "max bpc"
to the max. A high bpc consumes more lanes and more clock speed,
which means higher power consumption and the busy lanes cannot be
used for something else (e.g. other data transfers on a USB-C cable).

For now, let's tie the "max bpc" to the pixel format of the buffer.
Introduce a heuristic to make "high bit-depth buffer" a synonym of
"I want the best quality".

This is not perfect: a "max bpc" higher than 8 might be desirable
for pixel formats with a color depth of 8 bits, for instance when
the color management KMS properties are used. But we don't really
support that yet, so let's leave this for later.

Closes: https://github.com/swaywm/sway/issues/7367
2023-01-31 09:32:11 +00:00
Simon Ser 324eeaa0cd backend/drm: disable all CRTCs after VT switch
When the user switches away from the VT where wlroots is running,
the new DRM master may mutate the KMS state in an arbitrary manner.
For instance, let's say wlroots uses the following connector/CRTC
mapping:

- CRTC 42 drives connector DP-1
- CRTC 43 drives connector DP-2

Then the new DRM master may swap the mapping like so:

- CRTC 42 drives connector DP-2
- CRTC 43 drives connector DP-1

wlroots needs to restore its own state when the user switches back.
Some state is attached to wlr_drm_crtc (e.g. current FB), so reading
back and adopting the CRTC/connector mapping left by the previous DRM
master would be complicated (this was the source of other bugs in the
past, see [1]).

With the previous logic, wlroots merely tries to restore the state
of each connector one after the other. This fails in the scenario
described above: the kernel refuses to use CRTC 42 for DP-1, because
that CRTC is already in-use for DP-2.

Unfortunately with the legacy uAPI it's not possible to restore the
state in one go. We need to support both legacy and atomic uAPIs, so
let's fix the bug for the legacy uAPI first, and then improve the
situation for the atomic uAPI as a second step [2].

We need to disable the CRTCs we're going to switch the connectors for.
This sounds complicated, so let's just disable all CRTCs to simplify.
This causes a black screen because of the on/off modesets, but makes
VT switch much more reliable, so I'll take it.

[1]: c6d8a11d2c
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3794

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3342
2023-01-18 18:38:21 +00:00
Kirill Primak 9c7db7124e backend/x11: fix delta_discrete value
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3563
2023-01-16 14:19:44 +03:00
Simon Ser bc8260f377 backend/x11: fix initial value of wlr_x11_buffer.n_busy
We lock the buffer there, so we need to initialize the n_busy
count to 1 as well.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3556
2023-01-03 10:59:57 +01:00
Simon Ser dc7cc98cf2 backend/drm: check return value of get_drm_{connector,crtc}_props()
We already do it for get_drm_plane_props().
2022-12-16 10:30:14 +01:00