1
0
Fork 0

kms: Don't disarm deadline timer when compositing

If we finish compositing in time, the composited result will be
submitted prior to the deadline timer is triggered, and we'll be fine,
and if not, at least the cursor updates will be smooth, which makes it
appear smoother than not.

There is a risk that this can negatively impact composited updates when
moving the cursor, so make it possible to toggle a paint-debug flag for
now until this has been more tested.

This also mean we need to disarm the deadline timer after handling
update, as there might be a scheduled cursor update pending, but we
already handled it, so disarm the timer.

Here is an illustration of the difference.

In the following scenario, with disarming, the composited frame E, and
the cursor movement C gets presented. With this branch, only the cursor
movement C gets presented.
```
 * A: beginning of composited frame
 * B: begin notification reaches KMS thread
 * C: cursor moved
 * D: calculated deadline dispatch time (disabled with the branch)
 * E: KMS update posted
 * F: KMS update reaches KMS thread
 * G: actual deadline (and with branch and gets committed)
Compositor thread: --------A---------------E---------
                            \               \
                             \               \
KMS thread:        -----------B------C----D---F-G----
```

In the following scenario, by not disarming, the cursor update C will be
presented, and the would-be-delayed composited frame E would be delayed
anyway, i.e. fixing cursor stutter.
```
 * A: beginning of composited frame
 * B: begin notification reaches KMS thread
 * C: cursor moved
 * D: calculated deadline dispatch time (and with branch will be dispatched)
 * E: KMS update posted
 * F: actual deadline
 * G: KMS update reaches KMS thread (and with branch gets postponed)
Compositor thread: --------A---------------E---------
                            \               \
                             \               \
KMS thread:        -----------B------C----D-F-G------
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3184>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
This commit is contained in:
Jonas Ådahl 2023-08-15 15:24:11 +02:00 committed by Mingi Sung
parent efadfc4a94
commit c9bb8a16a2
Signed by: sungmg
GPG key ID: 41BAFD6FFD8036C5
3 changed files with 16 additions and 4 deletions

View file

@ -1601,6 +1601,11 @@ meta_kms_impl_device_handle_update (MetaKmsImplDevice *impl_device,
meta_kms_device_handle_flush (priv->device, latch_crtc);
feedback = do_process (impl_device, latch_crtc, update, flags);
if (meta_kms_feedback_did_pass (feedback) &&
crtc_frame->deadline.armed)
disarm_crtc_frame_deadline_timer (crtc_frame);
meta_kms_feedback_unref (feedback);
return;

View file

@ -1759,11 +1759,15 @@ meta_onscreen_native_before_redraw (CoglOnscreen *onscreen,
ClutterFrame *frame)
{
MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen);
MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc);
MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
meta_kms_device_await_flush (meta_kms_crtc_get_device (kms_crtc),
kms_crtc);
if (meta_get_debug_paint_flags () & META_DEBUG_PAINT_SYNC_CURSOR_PRIMARY)
{
MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc);
MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
meta_kms_device_await_flush (meta_kms_crtc_get_device (kms_crtc), kms_crtc);
}
maybe_update_frame_sync (onscreen_native, frame);
}

View file

@ -51,11 +51,14 @@ void meta_fatal (const char *format,
* MetaDebugPaintFlag:
* @META_DEBUG_PAINT_NONE: default
* @META_DEBUG_PAINT_OPAQUE_REGION: paint opaque regions
* @META_DEBUG_PAINT_SYNC_CURSOR_PRIMARY: make cursor updates await compositing
* frames
*/
typedef enum
{
META_DEBUG_PAINT_NONE = 0,
META_DEBUG_PAINT_OPAQUE_REGION = 1 << 0,
META_DEBUG_PAINT_SYNC_CURSOR_PRIMARY = 1 << 1,
} MetaDebugPaintFlag;
META_EXPORT