Commit graph

276 commits

Author SHA1 Message Date
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
Simon Ser
62cd0aad09 test: add dynamic@change-fb-modifier 2023-02-15 18:14:13 +01:00
Simon Ser
ab72b0d5c6 Stop re-using a previous configuration when FB attributes change
If FB attributes change, we might be able to take advantage of a
plane we couldn't  use before.

Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/71
2023-02-15 18:14:13 +01:00
Simon Ser
a669c85be6 test/libdrm_mock: implement drmCloseBufferHandle() stub 2023-02-15 18:14:13 +01:00
Simon Ser
e03edeffba test/libdrm_mock: implement drmModeGetFB2()
By default, drmModeGetFB2() behaves as-if the kernel didn't support
the IOCTL. That way we don't need to update all tests to set sensible
FB info.

If a test is specifically interested in testing drmModeGetFB2()
behavior, it can call liftoff_mock_drm_set_fb_info().
2023-02-15 18:14:13 +01:00
Simon Ser
d39d1837fb test/libdrm_mock: add helpers to convert from/to object index
libdrm_mock's KMS object IDs record the type and index.
2023-02-15 17:56:50 +01:00
Simon Ser
e1ccdff079 build: set pkg-config URL 2023-02-15 11:50:33 +01:00
Simon Ser
97e0695932 build: remove unnecessary version param in pkgconfig.generate() 2023-02-06 11:20:24 +01:00
Simon Ser
363951a084 build: override Meson dependency
Eases use as a subproject.
2023-02-06 11:18:16 +01:00
Simon Ser
73c44aa52a readme: disambiguate short description a bit 2022-10-07 07:04:24 +02:00
Simon Ser
f83d81c91e readme: indicate which compositors use the library 2022-10-07 07:02:55 +02:00
Simon Ser
47b92cb22f Switch to kernel-doc style references in comments 2022-09-28 21:00:06 +02:00
Simon Ser
bcfca8f602 build: bump version to 0.4.0-dev 2022-08-18 09:18:44 +02:00