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
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
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
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
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
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
99ed53677a
Turn on -Wdeclaration-after-statement
...
Enforces code style.
2023-02-16 20:03:42 +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
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
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
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
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
76f456d62e
Check layers zpos over the primary plane
...
The following commits contain tests for the pathological cases.
2021-12-14 18:57:04 +01:00
Simon Ser
b7a6958bca
ENOSPC is not fatal for test-only commits
...
drm_atomic_plane_check may return it for an invalid SRC coord.
2021-10-08 13:00:40 +02:00
Simon Ser
aa30b8fb97
Log number of atomic test-only commits
2021-09-30 09:41:39 +02:00
Simon Ser
32683879e7
Add newline after function return type
...
Aligns our style with Linux' and Weston's.
2021-08-13 22:02:33 +02:00
Simon Ser
120ad6fb73
build: turn on additional warnings
...
Functions without a prototype can be static, we don't want to deal
with alloca, and undefined definitions should be tested with #ifdef.
2021-08-13 15:40:35 +02:00
Simon Ser
447a9e8921
Document why the primary plane is a special case
...
For instance, i915 requires the primary plane to be enabled.
2021-08-13 12:38:05 +02:00
Simon Ser
149e149643
Improve alloc debug logging
...
Don't increase indent when skipping a plane. Better indent layer
and plane logs.
2021-08-13 09:23:16 +02:00
Simon Ser
8360818a7e
Zero-initialize alloc_step and alloc_result
...
Avoids having to deal with uninitialized memory issues.
2021-08-12 19:30:34 +02:00
Simon Ser
cc3eec82fd
Print alloc debug logs as a tree
...
The allocation process explores a tree, let's represent that tree
in the debug logs.
2021-08-12 19:27:17 +02:00
Simon Ser
f88df73fad
Log when a test-only commit fails
2021-08-12 19:12:08 +02:00
Simon Ser
fe76702dfb
Log number of candidate planes
...
This can be useful to figure out why liftoff_output_apply returns
an empty plane allocation.
2021-08-09 13:08:48 +02:00
Simon Ser
30ba835645
Log when no layer has been a plane
2021-08-09 12:58:35 +02:00
Simon Ser
61fd4c099a
Make liftoff_output_apply return an int
...
Callers may want to get more details about the failure, in
particular EPERM indicates that the user isn't DRM master (can
happen on VT switch).
2021-07-27 12:28:00 +02:00
Simon Ser
c4ef21af35
Move layer_is_visible to layer.c
2021-02-24 11:40:01 +01:00
Simon Ser
40411f6d3e
Don't re-alloc when FB_DAMAGE_CLIPS changes
...
This is updated at each atomic commit.
2020-12-05 14:36:47 +01:00
Simon Ser
9bfe58b7d2
Don't re-alloc when alpha changes
2020-12-05 13:24:17 +01:00
Simon Ser
eda317c25c
Don't re-alloc on IN_FENCE_FD change
2020-12-05 12:44:08 +01:00
Simon Ser
89b37acd98
Force re-alloc when previous FB_ID was 0
2020-12-05 12:34:25 +01:00
Simon Ser
b936348acc
Replace liftoff_layer_property.changed with prev_value
...
Keep track of the previous value, e.g. to figure out when a layer goes from
disabled (no FB_ID or zero alpha) to enabled.
2020-12-05 12:28:50 +01:00
Simon Ser
1700cbf1c9
Force re-alloc when setting FB to 0
2020-12-05 12:18:36 +01:00
Simon Ser
679e2bb0cd
Allow caller to pass commit flags
...
When the caller wants to perform a modeset, they will need to pass
DRM_MODE_ATOMIC_ALLOW_MODESET in the atomic commit flags, otherwise the driver
will fail the commit. libliftoff also needs to provide these flags in its
test-only commits.
2020-11-10 16:27:55 +01:00
Simon Ser
8ff01dc6a1
Don't pick a plane for fully transparent layers
...
Layers with alpha = 0 don't need a plane since they aren't visible.
Closes: https://github.com/emersion/libliftoff/issues/48
2020-05-26 21:29:59 +02:00
Simon Ser
5603060a9b
Take disabled layers into account in non_composition_layers_len
...
Disabled layers (with FB_ID = 0) don't need a plane. Fix the
non_composition_layers_len count in this case.
Closes: https://github.com/emersion/libliftoff/issues/49
2020-05-26 20:08:12 +02:00
Roman Gilg
6b2cbeb0d4
Indent log on property applying and layer assignment
...
Indent when applying properties and assigning the layers. The log is better to
read this way. Example:
Apply on output 0x55c447db2b50.
Layers on CRTC 62:
Layer 0x55c447db2a40:
FB_ID = 108
zpos = 0
alpha = 65535
SRC_X = 0
SRC_Y = 0
SRC_W = 3840
SRC_H = 2160
CRTC_X = 0
CRTC_Y = 0
CRTC_W = 3840
CRTC_H = 2160
Disabling planes: 55 52 49 46 43 40 71 69 67 65 63 61 58
Performing allocation for plane 55 (1/13)
Layer 0x55c447db2a40 -> plane 55: applying properties...
Layer 0x55c447db2a40 -> plane 55: incompatible properties
Performing allocation for plane 61 (12/13)
Layer 0x55c447db2a40 -> plane 61: applying properties...
Layer 0x55c447db2a40 -> plane 61: incompatible properties
Performing allocation for plane 58 (13/13)
Layer 0x55c447db2a40 -> plane 58: applying properties...
Layer 0x55c447db2a40 -> plane 58: success
Found a better allocation with score=1
Found plane allocation for output 0x55c447db2b50 with score=1
Assigning layers to planes:
Layer 0x55c447db2a40 -> plane 58
2020-03-08 14:18:09 +01:00
Roman Gilg
b713b17d31
Log re-use only on change
...
On debug verbosity logging every reuse of planes is spamming the log making it
difficult to debug the process.
With this patch only the change of reusing the same allocation is logged and
how often the allocation was reused after this changed back again.
2020-03-08 13:00:08 +01:00
Simon Ser
95d16704b9
Move device_test_commit to device.c
2020-01-13 12:22:47 +01:00
Simon Ser
64cfbc8e58
Fix format string for plane ID
2020-01-13 10:42:46 +01:00
Simon Ser
53a7bfebc9
Don't allocate planes for layers without a FB
...
When FB_ID is unet or zero, don't try to allocate a plane for the layer. There's
nothing to display anyway.
2019-12-19 17:50:20 +01:00
Simon Ser
657a9917c5
Add a way to force FB composition
...
Closes: https://github.com/emersion/libliftoff/issues/17
2019-12-13 11:38:14 +01:00
Simon Ser
c9cdf8ec50
Log layer configuration before alloc
2019-12-12 23:40:01 +01:00
Simon Ser
ceb4a1ff9e
Replace liftoff_device_apply with liftoff_output_apply
...
Compositors need to drive multiple connectors, each with its own vblank timings.
For each device, there's one separate rendering loop per output.
It's not possible to call liftoff_device_apply each time we want to submit a new
frame to one output, because this could touch another's output state, submitting
a new frame there in the process. When the other output will submit a new frame,
it'll get EBUSY (can't submit two frames without waiting for vblank).
Closes: https://github.com/emersion/libliftoff/issues/21
2019-11-24 18:13:40 +01:00
Simon Ser
ef75ba26e0
Don't re-use previous allocation if a layer has been removed
...
Start from scratch since we may be able to come up with a better allocation
(if the layer made another layer fall back to composition for instance).
Closes: https://github.com/emersion/libliftoff/issues/30
2019-11-24 13:25:59 +01:00
Simon Ser
b0e2b083f9
Rename display to device
...
"Display" can also mean "screen"/"monitor", so it's kind of confusing for
this usage.
2019-11-24 12:59:10 +01:00