Skip to content

Commit d26d08c

Browse files
vsyrjalametux
authored andcommitted
present: Don't ping-pong between sync and async flips
Many Intel GPUs can't switch between sync and async flips willy nilly. Sometimes that change itself will take one extra frame. This means that constant ping-pong between sync and async flips is only going to cause problems. Stay in async flip mode as long as the client is requesting it. The present protocol spec does say: "If 'options' contains PresentOptionAsync, and the 'target-msc' is less than or equal to the current msc for 'window', then the operation will be performed as soon as possible, not necessarily waiting for the next vertical blank interval." So there is an expectation that a future target-msc will still be respected even when PresentOptionAsync is specified. Staying in async flip mode won't actually change that given that present_scmd_pixmap() takes the flip mode into account when calculating exec_msc. So visually the flip should still happen on the correct target_msc regardles of whether we executed it as sync or async. Signed-off-by: notbabaisyou <[email protected]>
1 parent 003d734 commit d26d08c

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

present/present_vblank.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, uint64_
4141
}
4242
}
4343

44+
static Bool
45+
present_want_async_flip(uint32_t options, uint32_t capabilities)
46+
{
47+
if (options & PresentOptionAsync &&
48+
capabilities & PresentCapabilityAsync)
49+
return TRUE;
50+
51+
if (options & PresentOptionAsyncMayTear &&
52+
capabilities & PresentCapabilityAsyncMayTear)
53+
return TRUE;
54+
55+
return FALSE;
56+
}
57+
4458
/* The memory vblank points to must be 0-initialized before calling this function.
4559
*
4660
* If this function returns FALSE, present_vblank_destroy must be called to clean
@@ -119,15 +133,14 @@ present_vblank_init(present_vblank_ptr vblank,
119133
if (pixmap != NULL &&
120134
!(options & PresentOptionCopy) &&
121135
screen_priv->check_flip) {
122-
if (msc_is_after(target_msc, crtc_msc) &&
123-
screen_priv->check_flip (target_crtc, window, pixmap, TRUE, valid, x_off, y_off, &reason))
124-
{
125-
vblank->flip = TRUE;
126-
vblank->sync_flip = TRUE;
127-
} else if ((capabilities & PresentAllAsyncCapabilities) &&
128-
screen_priv->check_flip (target_crtc, window, pixmap, FALSE, valid, x_off, y_off, &reason))
136+
137+
Bool sync_flip = !present_want_async_flip(options, capabilities);
138+
139+
if (screen_priv->check_flip (target_crtc, window, pixmap,
140+
sync_flip, valid, x_off, y_off, &reason))
129141
{
130142
vblank->flip = TRUE;
143+
vblank->sync_flip = sync_flip;
131144
}
132145
}
133146
vblank->reason = reason;

0 commit comments

Comments
 (0)