Commit graph

288 commits

Author SHA1 Message Date
Simon Ser
07fbf14332 build: bump version to 0.6.0-dev 2024-05-28 00:28:40 +02:00
Simon Ser
8b08dc1c14 build: bump version to 0.5.0 2024-05-28 00:22:40 +02:00
Simon Ser
b5b921ea85 Introduce core properties
This is a set of well-known KMS standard properties, either used
by libliftoff itself or commonly used by compositors. Adding
special cases for these allows us to access them without having
to iterate over a list.

This roughly improves performance by ~50% when leaving out the
atomic test-only commits.

Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/1
2024-05-27 23:46:20 +02:00
Leo Li
17a558d3e0 test: Add intersection tests 2024-05-27 13:27:57 -04:00
Leo Li
ef868e4abe Consider intersections when deciding reallocation
Previously, we would reallocate when any CRTC_* property changes. This
leads to unnecessary reallocations when a plane moves or resizes. Cursor
movements would reallocate on every update, for example.

What we really care about is if a layer's intersection status with
another plane changes, so do that.
2024-05-27 13:27:57 -04:00
Simon Ser
8d45eeae7f Bail out based on remaining compatible planes
If we've found a good previous allocation, it's possible that there
is no point trying to continue exploring the graph. In particular,
if we won't get a higher score even if we manage to make use of all
available planes, we can stop right away.

For instance, let's say that we've previously found a way to make use
of 3 out of 5 planes. We're exploring a different path where we've
populated 1 plane, we've skipped 1 plane because we couldn't find a
suitable layer for it, and out of the 3 remaining planes only 2 are
compatible with the CRTC we're interested in. Even if we manage to
make use of these 2 extra planes we would end up with 3 effectively
used planes thus no benefit over the previous solution.
2024-05-21 18:24:01 +02:00
Simon Ser
ec86735763 test/bench: disable timeout 2024-05-21 10:52:15 +02:00
Simon Ser
c857632cfd Fix integer overflow when setting timeout_ns to INT64_MAX 2024-05-21 10:50:31 +02:00
Simon Ser
35c06e8995 Add option to set timeout for liftoff_output_apply()
The default limit of 1ms might be too short if the compositor
calls liftoff_output_apply() early in the vblank cycle, or too
long if the refresh rate is high. The compositor is in a better
spot to decide how much time should be spent on atomic tests, so
add an option for that.

Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/78
2024-05-21 08:45:56 +00:00
Simon Ser
c63676eda7 test: add silent mode to libdrm_mock
Useful for benchmarks.
2024-05-21 10:25:35 +02:00
Simon Ser
c5f0ff73e4 Fix debug message visibility 2024-05-16 16:44:18 +02:00
Simon Ser
1452dd7621 Print CRTC ID instead of liftoff_output pointer address in logs
Easier to read and match with KMS state.
2024-05-16 09:47:55 +02:00
Simon Ser
ee3769e678 test: add prop@fb-damage-clips
Ensure that FB_DAMAGE_CLIPS is ignored if a plane is missing the
property.
2024-05-15 22:12:28 +02:00
Simon Ser
0c65405d54 Use [0] to get element size when allocating arrays
This is clearer than using * or hardcoding a type.
2024-05-15 12:00:31 +02:00
Simon Ser
4e11884228 Use initializers instead of memset()
This is more type-safe.
2024-05-15 11:57:44 +02:00
Simon Ser
f53b541473 Drop outdated TODO about format list in struct liftoff_plane 2024-05-15 11:54:48 +02:00
Simon Ser
15f6ce7832 ci: use alpine/latest instead of alpine/edge
Right now alpine/edge has a broken gcovr package. We don't need
the bleeding edge so let's switch to alpine/latest for stability.
2024-05-14 16:21:08 +02:00
Sergei Trofimovich
29a06add8e layer.c: fix build against upcoming gcc-14 (-Werror=calloc-transposed-args)
`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `libliftoff`:

    ../layer.c: In function 'liftoff_layer_create':
    ../layer.c:20:48: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in t
    ument [-Werror=calloc-transposed-args]
       20 |         layer->candidate_planes = calloc(sizeof(layer->candidate_planes[0]),
          |                                                ^
    ../layer.c:20:48: note: earlier argument should specify number of elements, later size of each element
2023-12-21 20:15:29 +00:00
Leo Li
4124ee8c7a Keep output layers ordered by allocation priority
To optimize for offloading success, the list of output layers can be
ordered by allocation priority, improving the chances of a higher
allocation score before the deadline.

The allocation algorithm picks DRM planes first, then tests output
layers against them. To reduce the number of tests, the layers can be
ordered such that it matches the DRM plane order. DRM planes in
libliftoff are ordered by primary, followed by all other planes in
descending z-order. We order the layers similarly, with the composition
layer first, followed by layers of descending priority.

In addition to layer priority, it's z-pos and intersection with other
layers are considered. Since to offload a high priority layer, all
intersection layers with higher z-pos will also need to be offloaded.

This also changes when reallocation is necessary. On top of the existing
criteria, reallocation is done when a layer's ordering changes.

With layer priority now considered, the priority test now passes --
enable it.
2023-12-20 16:03:49 +00:00
Leo Li
a08c4d1f08 Introduce liftoff_list_swap
Introduce a function to swap elements in a doubly linked list. This will
be helpful when keeping the list of output layers sorted by priority.

v2: re-define in terms of list_inserts and list_removes
2023-12-20 16:03:49 +00:00
Leo Li
19e56163c2 Mark layers clean, even when allocation is reused
Otherwise, layer properties/priority will be stale on next output_apply.
2023-12-20 16:03:49 +00:00
Simon Ser
58b8494dd5 ci: halt on UBSan errors
By default UBSan prints a message and carries on, which makes it
easy to miss errors.
2023-11-02 11:11:34 +01:00
Simon Ser
7ceaf440e2 Add a deadline for liftoff_output_apply()
We don't want libliftoff to take too long.

References: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/16
2023-06-20 22:58:26 +02:00
Simon Ser
d98ae24328 Switch to "meson setup"
Fixes this warning:

    WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
2023-02-22 10:57:03 +01:00
Simon Ser
0e3519fd80 ci: drop unnecessary gcovr.cfg lines
This file is checked in now.
2023-02-22 10:47:23 +01:00
Simon Ser
25dd6d662e Fix -Wsign-conversion on 32-bit
Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/75
2023-02-22 10:45:05 +01:00
Simon Ser
314684fc64 plane: add NULL check to liftoff_plane_destroy()
All other libliftoff destructors already check for NULL, except
this one.
2023-02-22 10:15:19 +01:00
Simon Ser
94eb185771 build: bump to 0.5.0-dev 2023-02-20 22:09:53 +01:00
Simon Ser
40834142e1 build: bump version to 0.4.0 2023-02-20 22:04:22 +01:00
Simon Ser
ce325b1ee6 Turn on -Wsign-conversion
References: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/74
2023-02-16 21:33:36 +01:00
Simon Ser
b2721f739c Turn on -Wfloat-conversion
References: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/74
2023-02-16 21:07:05 +01:00
Simon Ser
8c5b0857f0 Add gcovr.cfg
Exclude test code and example code from code coverage results.
2023-02-16 20:05:48 +01:00
Simon Ser
99ed53677a Turn on -Wdeclaration-after-statement
Enforces code style.
2023-02-16 20:03:42 +01:00
Simon Ser
fb8ede8f89 editorconfig: increase max line length to 100
That's what the kernel uses.
2023-02-16 19:56:31 +01:00
Simon Ser
2045e7d070 Log reason why a previous allocation is not re-used 2023-02-16 19:55:30 +01:00
Simon Ser
63c6043b15 Fix disabled layers forcing realloc 2023-02-16 19:51:42 +01:00
Simon Ser
2f461be62c Add missing braces for code style 2023-02-16 19:51:24 +01:00
Simon Ser
9e44872217 test/prop: add range/enum/bitmask tests 2023-02-16 12:36:24 +01:00
Simon Ser
a002a240e9 test/prop: simplify by introducing commit() function 2023-02-15 20:12:37 +01:00
Simon Ser
0b910624f5 plane: check value for range/enum/bitmask properties
We need to drop the assert from apply_current(): the new value
may be outside the range for instance.

Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/47
2023-02-15 20:11:57 +01:00
Simon Ser
46f35829e0 plane: check IMMUTABLE flag in plane_set_prop() 2023-02-15 19:30:04 +01:00
Simon Ser
9568888b99 plane: store drmModePropertyRes
This retains all of the info we need: ID, name, type, possible
enum values. We'll need the possible enum values in the next
commit.
2023-02-15 19:30:04 +01:00
Simon Ser
8ec1203e64 test: add IN_FORMATS test 2023-02-15 19:19:24 +01:00
Simon Ser
94f45a91c4 test: add liftoff_mock_plane_add_in_formats() 2023-02-15 19:19:24 +01:00
Simon Ser
944ff20b13 alloc: check FB format and modifier
Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/12
2023-02-15 19:19:24 +01:00
Simon Ser
8a9167f9fd test/libdrm_mock: add stub blob functions 2023-02-15 19:12:46 +01:00
Simon Ser
0811ce855b test/libdrm_mock: take initial prop value as separate arg
drmModePropertyRes.values never holds the current value. Stop
abusing this field.
2023-02-15 18:39:57 +01:00
Simon Ser
afeeafd6d7 test: add basic test for candidate planes 2023-02-15 18:20:23 +01:00
Simon Ser
3e72fc3c5d test/libdrm_mock: add liftoff_mock_plane_get_id()
Useful when manually calling liftoff_plane_create() is desirable.
2023-02-15 18:20:23 +01:00
Simon Ser
6e8998c8a8 Add API to query candidate planes
This can be used to implement Wayland's linux-dmabuf-unstable-v1's
feedback mechanism.

Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/70
2023-02-15 18:20:22 +01:00