Commit c3e4c1a0 authored by Michel Dänzer's avatar Michel Dänzer Committed by Michel Dänzer
Browse files

present/wnmd: Execute copies at target_msc-1 already

It always takes one update cycle for the copy to become visible on the
host windowing system, so waiting for the target MSC resulted in 1 cycle

We re-use the idle list for copies which were executed but need their
completion event sent.

Fixes black seams when resizing the "Builder" sub-window of

 GDK_BACKEND=x11 gtk4-demo

on Xwayland (see


Unfortunately, this cannot completely fix the seams with apps which
queue up multiple frames in advance, since there's always at least one
queued frame corresponding to the old window size. But it should at
least help a little in that case as well.

* Bug fix: Don't update exec_msc in present_wnmd_check_flip_window.
  (Roman Gilg)
* Use exec_msc = target_msc - 1 instead of exec_msc--, and add a
  comment, for clarity.
* Drop exec_msc = target_msc again in present_wnmd_execute.
* present_execute_copy should never set vblank->queued in
  present_wnmd_execute now, so replace that branch with an assertion.
  (Roman Gilg)
Reviewed-by: Roman Gilg's avatarRoman Gilg <>
Tested-by: Roman Gilg's avatarRoman Gilg <>
(cherry picked from commit 1cccb486)
[Since present_wnmd_event_notify hasn't been split up on the 1.20
branch, it needs to check vblank->flip. Doing the same in
present_wnmd_free_idle_vblanks to be safe, though I'm not sure it's
actually possible to hit non-flips there.]
parent 96ef31e0
Pipeline #211252 passed with stages
in 6 minutes and 26 seconds
......@@ -122,7 +122,8 @@ present_wnmd_free_idle_vblanks(WindowPtr window)
present_vblank_ptr vblank, tmp;
xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->idle_queue, event_queue) {
if (vblank->flip)
if (window_priv->flip_active) {
......@@ -245,7 +246,12 @@ present_wnmd_event_notify(WindowPtr window, uint64_t event_id, uint64_t ust, uin
xorg_list_for_each_entry(vblank, &window_priv->idle_queue, event_queue) {
if (vblank->event_id == event_id) {
if (vblank->flip)
/* Copies which were executed but need their completion event sent */
present_execute_post(vblank, ust, msc);
......@@ -353,8 +359,6 @@ present_wnmd_check_flip_window (WindowPtr window)
vblank->sync_flip, vblank->valid, 0, 0, &reason)) {
vblank->flip = FALSE;
vblank->reason = reason;
if (vblank->sync_flip)
vblank->exec_msc = vblank->target_msc;
......@@ -454,6 +458,7 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
vblank->queued = FALSE;
if (vblank->pixmap && vblank->window) {
ScreenPtr screen = window->drawable.pScreen;
if (vblank->flip) {
RegionPtr damage;
......@@ -479,7 +484,6 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
// ask the driver
if (present_wnmd_flip(vblank->window, vblank->crtc, vblank->event_id,
vblank->target_msc, vblank->pixmap, vblank->sync_flip, damage)) {
ScreenPtr screen = window->drawable.pScreen;
WindowPtr toplvl_window = present_wnmd_toplvl_pixmap_window(vblank->window);
PixmapPtr old_pixmap = screen->GetWindowPixmap(window);
......@@ -502,7 +506,6 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
window_priv->flip_pending = NULL;
vblank->flip = FALSE;
vblank->exec_msc = vblank->target_msc;
DebugPresent(("\tc %p %" PRIu64 ": %08" PRIx32 " -> %08" PRIx32 "\n",
vblank, crtc_msc, vblank->pixmap->, vblank->window->;
......@@ -510,9 +513,12 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
present_execute_copy(vblank, crtc_msc);
if (vblank->queued) {
xorg_list_add(&vblank->event_queue, &window_priv->exec_queue);
if (present_wnmd_queue_vblank(screen, window, vblank->crtc,
vblank->event_id, crtc_msc + 1)
== Success) {
xorg_list_add(&vblank->event_queue, &window_priv->idle_queue);
xorg_list_append(&vblank->window_list, &window_priv->vblank);
......@@ -632,8 +638,10 @@ present_wnmd_pixmap(WindowPtr window,
if (!vblank)
return BadAlloc;
if (vblank->flip && vblank->sync_flip)
/* WNMD presentations always complete (at least) one frame after they
* are executed
vblank->exec_msc = vblank->target_msc - 1;
xorg_list_append(&vblank->event_queue, &window_priv->exec_queue);
vblank->queued = TRUE;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment