Commit graph

44 commits

Author SHA1 Message Date
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
Simon Ser
5f39331f78
Keep track of the update frequency of each layer
Keep track of the number of layer updates per 60 page-flips.

We could implement a more fine-grained tracking, for instance with a sliding
window. However it's a lot more complex than the current solution and the gains
are not clear. I'd prefer to keep the current solution and experiment with other
solutions once we have a good test-bed.

References: https://github.com/emersion/libliftoff/issues/22
2019-11-15 21:43:44 +01:00
Simon Ser
5faa1e466b
Remove outdated TODO 2019-10-30 20:45:15 +01:00
Simon Ser
ef29d341cb
Move plane allocation algorithm to alloc.c
And move plane-related functions to plane.c.
2019-10-19 13:43:09 +03:00