Commit graph

45 commits

Author SHA1 Message Date
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
ce325b1ee6 Turn on -Wsign-conversion
References: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/74
2023-02-16 21:33:36 +01:00
Simon Ser
378ccb4f84 test/alloc: add zpos-3x-zero-alpha
References: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/59
2022-01-31 14:29:16 +01:00
Simon Ser
223e288ae6 test/alloc: add zpos-3x-zero-fb-id
References: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/59
2022-01-31 14:26:20 +01:00
Simon Ser
7a06f8c597 test/alloc: rename composition-zero-fb-id to composition-no-props
This is more consistent with other test names.
2022-01-31 14:05:58 +01:00
Simon Ser
3004a0dcbd test/alloc: move zero-fb-id-fail to test data 2022-01-31 14:03:47 +01:00
Simon Ser
998d8c6a59 test/alloc: drop test_needs_composition logic
This was fine for simple test cases, but would need to become
more complicated for cases where e.g. zero FB_ID or alpha is
involved. Let's just hardcode the expected value in the test data
instead.
2022-01-31 14:00:20 +01:00
Simon Ser
61a8b85059 test/alloc: pass full test_case to run_test
More metadata will be added to the test_case struct soon.
2022-01-31 14:00:20 +01:00
Simon Ser
addeaf6097 test/alloc: replace test_layer.zpos with test_prop
This allows setting arbitrary props.
2022-01-31 13:39:47 +01:00
Simon Ser
32f97b1c51 test/alloc: check test_layer.compat length
Avoid iterating past the array bounds as a safety net. We should
have more than enough room for now, but let's make sure we don't
get caught.
2022-01-31 13:30:45 +01:00
Simon Ser
3ced3be25a test/alloc: make test data const
We should never mutate the test data.
2022-01-31 13:29:58 +01:00
Simon Ser
2e1dd93b60 test/alloc: add zpos-2x-fail 2021-12-14 18:57:04 +01:00
Simon Ser
1db99c213c test/alloc: add zpos-2x-reverse 2021-12-14 18:57:04 +01: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
8a971695bd test: introduce liftoff_mock_require_primary_plane
This allows to mimick i915's requirement of failing all commits
which don't have the primary plane enabled.

We could expand our test matrix to test with the param *and* without
it, but since enabling the param just makes the atomic check more
strict there's no real benefit of doing that. Enabling the param
can only make tests fail more often, not the other way around.
2021-08-13 12:28:13 +02:00
Simon Ser
6321e7c5aa Add needs_composition APIs
Right now, compositors are expected to query liftoff_layer_get_plane_id to
decide whether a layer needs to be composited.

However there are cases where a layer has no plane, but still doesn't need
composition (e.g. when FB_ID is zero or when alpha is zero, in the future when
the layer is out of CRTC bounds etc).

Add a new API to make users' life simpler.

Closes: https://github.com/emersion/libliftoff/issues/54
2021-08-09 11:56:55 +02:00
Simon Ser
516cf9404d Stop including stdbool.h from libliftoff.h
We don't use bool there anymore.
2021-07-30 16:22:58 +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
bcb6e3cfb8 Replace liftoff_layer_get_plane_id with liftoff_layer_get_plane
Users can get back the plane ID with liftoff_plane_get_id.
2021-07-01 11:49:36 +02:00
Simon Ser
562f8b0af6 Allow to choose which planes are managed by libliftoff
Closes: https://github.com/emersion/libliftoff/issues/10
2021-07-01 11:37:10 +02:00
Simon Ser
1616f8ae6a test/alloc: document test_layer and test_setup 2021-06-24 19:05:01 +02:00
Simon Ser
b08bbaa5e6 Split liftoff_log_init into set_handler and set_priority
This allows callers to change only one of those, without the other.
Also rename importance to priority and func to handler.
2021-03-31 12:44:24 +02: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
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
Simon Ser
6d4e22a5f8
test: a test-only commit doesn't apply properties
This fixes a misunderstanding of the DRM API. Only a regular commit applies
properties.

Fixes: b16078769e ("test/libdrm_mock: a test-only commit applies properties")
2020-05-26 18:49:04 +02:00
Simon Ser
b16078769e
test/libdrm_mock: a test-only commit applies properties
The previous mock library assumed the DRM client would always set all
properties in the atomic request. However, if a previous test-only commit
has set a property, there's no need to set it again.

Accomodate for this in libdrm_mock. This will be useful when we'll skip
setting properties that haven't changed in libliftoff.

References: https://github.com/emersion/libliftoff/issues/37
2020-01-13 12:14:33 +01:00
Simon Ser
7286146341
test: add a test with a zero FB_ID
References: 53a7bfebc9 ("Don't allocate planes for layers without a FB")
2019-12-19 17:54:49 +01:00
Simon Ser
71200724c5
test: add a test with a layer without any prop set
Makes sure libliftoff doesn't allocate a plane for the layer and doesn't crash.

References: 799f694587 ("Fix segfault when FB_ID isn't set")
References: 53a7bfebc9 ("Don't allocate planes for layers without a FB")
2019-12-19 17:50:40 +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
e09ebdac27
test: add empty test
Make sure calling apply() with no layer works as expected.
2019-11-29 10:57:24 +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
44d65288d7
Fixup display → device bulk rename
I managed to do a bit of a mess here.

Fixes: b0e2b083f9 ("Rename display to device")
2019-11-24 13:07:12 +01:00
Simon Ser
5115e96cd9
test: add composition tests 2019-10-11 14:31:17 +03:00
Simon Ser
1ee86c6290
Add logging functions
This allows turning on and off debug logs, as well as defining a logging
callback.
2019-10-11 12:03:14 +03:00
Simon Ser
c63c8c0d15
test: add zpos-4x-disjoint-alt
And restore the original zpos-4x-disjoint test. Depending on the constraints on
the last two layers, one branch of the layer zpos check or the other is taken.

Fixes: 8617ddfd05 ("Add intersection check for planes under the current one")
2019-09-15 23:48:10 +03:00
Simon Ser
8617ddfd05
Add intersection check for planes under the current one
References: https://github.com/emersion/libliftoff/issues/3
2019-09-15 22:31:10 +03:00
Simon Ser
b447a3bc34
test: prevent layers from being assigned to primary plane
In these tests, we always want to use the same layer for the primary plane.
Prevent othr layers from ending up on the primary plane.
2019-09-15 16:56:24 +03:00
Simon Ser
8c93a6fc88
test: add alloc@zpos-4x-domino-partial
This is a variant of alloc@zpos-4x-domino-fail, with plane ordering changed so
that one layer can be mapped to a plane.
2019-09-14 21:18:20 +03:00
Simon Ser
a93ea4a300
test: add alloc@zpos-4x-domino-fail
This test makes sure composited layers make layers underneath fall back to
composition too, in a transitive manner. That is, if plane A is under plane B
which is itself under plane C, plane A falling back to composition means that
both planes B and C fall back to composition too (even if C isn't directly
underneath A).
2019-09-14 21:05:14 +03:00
Simon Ser
07e04a50b6
Make composited layers prevent plane allocation underneath
If a layer cannot be mapped to a plane, make it so all layers under it also fail
plane allocation so that they can be properly composited on the primary plane.

A test was incorrect and has been fixed. Another test had two possible solutions
and has been updated with the one libliftoff yields.
2019-09-14 21:03:30 +03:00
Simon Ser
a3b8bc33ea
test: add various zpos tests
Some of these are failing, so they are disabled for now.
2019-09-14 12:59:37 +03:00
Simon Ser
3200016033
test: add basic zpos tests
zpos-3x maps three layers to primary, cursor and one of the overlays planes.

zpos-4x-partial sets up 4 layers but is only able to find a plane for 3 layers,
because ordering between the two overlay planes is undefined.
2019-09-13 22:53:15 +03:00
Simon Ser
de8175c998
test: add an alloc test with 3 layers 2019-09-13 22:35:23 +03:00
Simon Ser
fccdebfd6e
test: introduce structured alloc tests
This is a new kind of tests defined by a static structure. The structure
contains the layers and planes to setup as well as the expected result.
2019-09-13 19:47:00 +03:00
Simon Ser
5afeeb531a
Add test framework
When testing the library, the libdrm dependency is swapped with a mock libdrm.
The test sets up the mock libdrm's internal state and then runs the test.
2019-09-13 10:33:49 +03:00