xf86-video-intel: src/sna/sna_dri2.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Aug 14 12:55:39 PDT 2015


 src/sna/sna_dri2.c |   40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

New commits:
commit 521b2c5a3b29a399b4b32b027eeb097accd4b3dd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Aug 14 18:49:43 2015 +0100

    sna/dri2: Use the primary CRTC for swap completion for offscreen Windows
    
    Letting GL clients run amok when offscreen (or when hidden) has
    unexpected UX behaviour. Instead we can elect to throttle them to the
    nearest CRTC and keep the desktop running smoothly.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c
index e6f4d43..22456f2 100644
--- a/src/sna/sna_dri2.c
+++ b/src/sna/sna_dri2.c
@@ -3287,6 +3287,8 @@ sna_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 		bool sync = current_msc < *target_msc;
 		sna_dri2_immediate_blit(sna, info, sync);
 		*target_msc = current_msc + sync;
+		DBG(("%s: reported target_msc=%llu\n",
+		     __FUNCTION__, *target_msc));
 		return TRUE;
 	}
 
@@ -3321,8 +3323,6 @@ sna_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 
 blit:
 	DBG(("%s -- blit\n", __FUNCTION__));
-	if (info)
-		sna_dri2_event_free(info);
 	if (can_xchg(sna, draw, front, back)) {
 		sna_dri2_xchg(draw, front, back);
 	} else {
@@ -3334,8 +3334,38 @@ skip:
 	DBG(("%s: unable to show frame, unblocking client\n", __FUNCTION__));
 	if (crtc == NULL)
 		crtc = sna_primary_crtc(sna);
-	fake_swap_complete(sna, client, draw, crtc, type, func, data);
-	*target_msc = 0; /* offscreen, so zero out target vblank count */
+	if (crtc) {
+		if (!info)
+			info = sna_dri2_add_event(sna, draw, client, crtc);
+		if (!info)
+			goto fake;
+
+		info->type = SWAP_WAIT;
+		info->event_complete = func;
+		info->event_data = data;
+		info->queued = true;
+
+		VG_CLEAR(vbl);
+		vbl.request.type =
+			DRM_VBLANK_RELATIVE |
+			DRM_VBLANK_EVENT;
+		vbl.request.signal = (uintptr_t)info;
+		vbl.request.sequence = 1;
+
+		if (sna_wait_vblank(sna, &vbl, info->pipe))
+			goto fake;
+
+		*target_msc = current_msc + 1;
+	} else {
+fake:
+		/* XXX Use a Timer to throttle the client? */
+		fake_swap_complete(sna, client, draw, crtc, type, func, data);
+		*target_msc = 0; /* offscreen, so zero out target vblank */
+		if (info)
+			sna_dri2_event_free(info);
+	}
+	swap_limit(draw, 1);
+	DBG(("%s: reported target_msc=%llu\n", __FUNCTION__, *target_msc));
 	return TRUE;
 }
 
@@ -3400,6 +3430,8 @@ sna_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, CARD64 target_msc
 
 	/* Drawable not visible, return immediately */
 	if (crtc == NULL)
+		crtc = sna_primary_crtc(sna);
+	if (crtc == NULL)
 		goto out_complete;
 
 	pipe = sna_crtc_pipe(crtc);


More information about the xorg-commit mailing list