[Intel-gfx] [PATCH] double buffer cursor updates

Jesse Barnes jbarnes at virtuousgeek.org
Fri May 15 01:51:24 CEST 2009


Some people have complained about cursor flicker when KMS is active.
If you've been seeing that, please try this patch.  It creates a new
cursor object each time the load function is called, and calls the set
cursor function once the object has been loaded.  The actual cursor
base write should be sync'd to vblank, so hopefully this will be
solid.

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 15ffc29..75266ca 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -260,17 +260,31 @@ drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
 static void
 drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)
 {
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	ScrnInfoPtr pScrn = crtc->scrn;
 	I830Ptr pI830 = I830PTR(pScrn);
 	int ret;
+	dri_bo *bo;
+
+	/* If we can, double buffer cursor updates so we can avoid flicker */
+	bo = dri_bo_alloc(pI830->bufmgr, "cursor", 64*64*4, 0);
+	if (!bo)
+		bo = pI830->cursor_mem->bo;
 
-	/* cursor should be mapped already */
-	ret = dri_bo_subdata(pI830->cursor_mem->bo, 0, 64*64*4, image);
+	ret = dri_bo_subdata(bo, 0, 64*64*4, image);
 	if (ret)
 		xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
 			   "failed to set cursor: %s", strerror(-ret));
 
-	return;
+	/* If we allocated the new object, go ahead and set the cursor */
+	if (bo != pI830->cursor_mem->bo) {
+		drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+				 bo->handle, 64, 64);
+
+		dri_bo_unreference(pI830->cursor_mem->bo);
+		pI830->cursor_mem->bo = bo;
+	}
 }
 
 



More information about the Intel-gfx mailing list