Commit Graph

7300 Commits

Author SHA1 Message Date
Simon Ser
9e71c88467 scene: unwrap wlr_client_buffer for direct scan-out
Passing the wlr_client_buffer directly has a downsides because a
fresh wlr_buffer pointer is passed each output commit instead of
cycling through existing wlr_buffer objects:

- The FDs are re-imported each time in the backend.
- Any import failure is logged every output commit [1].
- The Wayland backend cannot handle import failures without
  roundtripping each output commit [2].

Instead, extract the source buffer from the wlr_client_buffer and
pass that to the backend.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4836
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4841
2024-11-07 14:17:35 +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
xurui
3f314bc183 output-power-management-v1: use enum_is_valid functions
Signed-off-by: xurui <xurui@kylinos.cn>
2024-11-07 10:20:03 +00:00
xurui
38fc4f2976 wlr_output_management_v1: use enum_is_valid functions
Signed-off-by: xurui <xurui@kylinos.cn>
2024-11-07 10:20:03 +00:00
xurui
81fa6c4b96 wlr_linux_dmabuf_v1: use enum_is_valid functions
Signed-off-by: xurui <xurui@kylinos.cn>
2024-11-07 10:20:03 +00:00
xurui
cda6fdffac layer-shell-v1: use enum_is_valid functions
Signed-off-by: xurui <xurui@kylinos.cn>
2024-11-07 10:20:03 +00:00
Simon Ser
2c098a3e45 build: rename meson_options.txt to meson.options
This is the preferred name since Meson 1.1.
2024-11-07 10:53:38 +01:00
Kenny Levinsen
1f13bc72fe render/vulkan: Garbage collect unused buffers
Perform a primitive garbage collection of buffers that have not been
used in the past 10 seconds, an arbitrarily selected number.

As garbage collection also makes span buffer allocation happen much more
often, logging on allocation activity leads to a lot of log noise so get
rid of that while at it.
2024-11-07 09:49:29 +00:00
Kenny Levinsen
0d728f96b7 util/time: Move NSEC_PER_SEC to header
This constant can be useful whenever one has to deal with timespecs, so
let's move it to the header.
2024-11-07 10:22:56 +01:00
Kenny Levinsen
d6b47c3ab0 wlr_keyboard_group: Use get_current_time_msec 2024-11-07 10:22:10 +01:00
Kenny Levinsen
8bb6935374 tablet-v2: Event time should be milliseconds
The event time used for zwp_tablet_pad_group_v2_send_mode_switch was
tv_nsec / 1000, which is microseconds resetting every whole second.

Use get_current_time_msec to get milliseconds including whole seconds.
2024-11-07 10:09:36 +01:00
mmcomando
c5d8f6d187 Consider using vulkan renderer in default configuration
With this change vulkan renderer can be automatically chosen in two more cases:

GLES2 renderer is disabled at compile time
GLES2 renderer failed to be created

Main purpose of this change is to automatically choose vulkan as renderer when GLES2 renderer is not enabled.
2024-11-06 08:52:58 +01:00
Simon Ser
3fdbfb0be8 buffer: add more docs 2024-11-04 19:05:38 +01:00
Kirill Primak
ea93dd5cc3 xdg-system-bell-v1: add implementation 2024-11-03 08:54:10 +03:00
Kirill Primak
3ca4bc8c09 meson: fix file order 2024-11-03 08:52:48 +03: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
Alexander Orzechowski
ebab992b44 wlr_scene: Add notes about wlr_scene_rect taking premultiplied colors 2024-10-29 15:15:41 -04: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
Kirill Primak
1520be3c5c Make all listeners private 2024-10-28 18:07:02 +00:00
Simon Ser
3bbfae73ae render/vulkan: add support for explicit sync 2024-10-28 17:51:21 +00:00
Simon Ser
9351c78d70 render/vulkan: add render_pass_destroy()
De-duplicate the cleanup logic.
2024-10-28 17:51:21 +00:00
David Turner
cf43a447cb scene: Transform coordinates for direct scanout
We support direct scanout when there is an output and buffer
transform so long as the transforms are the same (so cancel out for the
buffer contents).  But we still need to apply the output transform to
the destination box location and size.
2024-10-28 13:28:23 +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
llyyr
4c74a8843a presentation-time: bump protocol version to v2
We've actually been doing the wrong thing this whole time, for v1 of the
protocol, we should set the refresh_nsec field to 0 if the output does
not have a constant refresh rate. However we've been setting it to the
fastest rate instead since eac7c2ad2f
which is incidentally exactly what v2 of the protocol proposes.

So allow advertising v2, and fix v1 to set refresh_nsec to 0.
2024-10-28 02:58:48 +05:30
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
Kirill Primak
6006023a37 Use WLR_PRIVATE for private fields 2024-10-25 07:51:51 +03:00
David Turner
e51ce333bc scene: Apply output offset for direct scanout
When setting the primary buffer location for direct scanout, subtract
the offset of that output to put the buffer location in output-relative
coordinates.

Fixes #3910
2024-10-24 16:03:17 +01: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
xurui
0d467ef9aa xdg-positioner: use enum_is_valid functions
Signed-off-by: xurui <xurui@kylinos.cn>
2024-10-23 18:52:34 +08:00
xurui
527b77b445 xdg-toplevel: use enum_is_valid functions
Signed-off-by: xurui <xurui@kylinos.cn>
2024-10-23 18:52:26 +08: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
YaoBing Xiao
47fb00f66d wlr_linux_dmabuf_v1: log plane index in error messages for dma-buf
Signed-off-by: YaoBing Xiao <xiaoyaobing@uniontech.com>
2024-10-15 18:05:16 +00: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
Kirill Primak
7952658367 scene: crop output buffer damage before adding
This piece of logic was accidentally removed in
009515161b.
2024-10-15 12:59:40 +00: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
Alexander Orezechowski
402a862413 output: Change wlr_output_add_software_cursors_to_render_pass to take buffer coordinates
Since wlr_damage_ring now only works with buffer local coordinates, this
creates an inpedance mismatch for compositors that want to use this
function. Instead of compositors needing to the the conversion itself,
change thu function to take buffer local coordinates directly.
2024-10-12 07:30:11 +00: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
785e340f01 scene: use backend-wide timeline feature flag 2024-10-11 17:11:35 +00:00
Simon Ser
186bdc8da4 output: use backend-wide timeline 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
Alexander Orezechowski
8d8d5f5e94 scene: Rename some functions 2024-10-11 00:37:55 +03:00
Alexander Orezechowski
009515161b scene: Only accept buffer coordinates for damage 2024-10-11 00:37:55 +03:00
Alexander Orezechowski
f1b8937345 scene: Factor scaling into output transform function 2024-10-11 00:37:51 +03:00
Alexander Orezechowski
b9f0b9c766 scene: Apply damage ring as buffer local coordinates 2024-10-11 00:37:51 +03:00
Alexander Orezechowski
831e7fc7ee damage_ring: Add notes about damage being in buffer local coordinates 2024-10-11 00:37:48 +03:00
Alexander Orzechowski
79e063035c damage_ring: Remove wlr_damage_ring_set_bounds
This wasn't that great:
1. Now that damage ring tracks damage across actual wlr_buffer objects,
   it can use the buffer size to do any sort of cropping that needs to
   happen.
2. The damage ring size really should be the size of the transformed
   size of the output. Compositors currently have to call
   `wlr_damage_ring_set_bounds()` where it might not be clear when to
   call the function. Compositors can just check against the actual
   output bounds that they care about when processing the damage.

Fixes: #3891
2024-10-09 06:31:46 +00:00