xf86-video-intel: Branch 'dri2-swapbuffers' - src/i830_dri.c

Jesse Barnes jbarnes at kemper.freedesktop.org
Wed Jun 3 08:53:41 PDT 2009


 src/i830_dri.c |  106 ++++++++++++---------------------------------------------
 1 file changed, 24 insertions(+), 82 deletions(-)

New commits:
commit 44d21f09475d207757518e6953c4e4b311504420
Author: Jesse Barnes <jbarnes at jbarnes-x200.(none)>
Date:   Wed Jun 3 16:51:27 2009 +0100

    Update swapbuffers to use invalidatebuffers stuff
    
    Now that the clients will invalidate their buffers after swapping, we don't
    need to return a whole new set.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 32201f1..5b80a55 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -352,98 +352,40 @@ i830_flip_ok(DrawablePtr pDraw)
  *   - otherwise we try to swap, and return to the caller the new front
  *     and back buffers
  */
-static DRI2BufferPtr *
-I830DRI2SwapBuffers(DrawablePtr pDraw, DRI2BufferPtr *buffers, int count)
+static Bool
+I830DRI2SwapBuffers(DrawablePtr pDraw, DRI2BufferPtr front, DRI2BufferPtr back)
 {
-    DRI2BufferPtr new_buffer, *new_buffer_ptrs;
-    I830DRI2BufferPrivatePtr private, old_priv;
-    PixmapPtr pPixmap, new_front_pixmap, old_front_pixmap;
-    int i, j, front_buffer, back_buffer, tmp;
-    dri_bo *bo, *new_front_bo, *old_front_bo;
-
-    if (!i830_flip_ok(pDraw))
-	return NULL;
-
-    new_buffer_ptrs = xcalloc(count, sizeof(DRI2BufferRec *));
-    if (new_buffer_ptrs == NULL)
-	return NULL;
-
-    for (i = 0; i < count; i++) {
-	old_priv = buffers[i]->driverPrivate;
-	pPixmap = old_priv->pPixmap;
-	pPixmap->refcnt++;
-
-	new_buffer = xcalloc(1, sizeof(DRI2BufferRec));
-	if (!new_buffer) {
-	    for (j = 0; j < i; j++) {
-		xfree(new_buffer_ptrs[j]->driverPrivate);
-		xfree(new_buffer_ptrs[j]);
-	    }
-	    return NULL;
-	}
-
-	private = xcalloc(1, sizeof *private);
-	if (!private) {
-	    for (j = 0; j < i; j++) {
-		xfree(new_buffer_ptrs[j]->driverPrivate);
-		xfree(new_buffer_ptrs[j]);
-	    }
-	    return NULL;
-	}
-
-
-	private->pPixmap = pPixmap;
-	private->attachment = buffers[i]->attachment;
-
-	new_buffer->attachment = buffers[i]->attachment;
-	new_buffer->pitch = buffers[i]->pitch;
-	new_buffer->cpp = buffers[i]->cpp;
-	new_buffer->driverPrivate = private;
-	new_buffer->name = buffers[i]->name;
-
-	bo = i830_get_pixmap_bo(pPixmap);
+    ScreenPtr pScreen = pDraw->pScreen;
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    I830DRI2BufferPrivatePtr front_priv, back_priv;
+    dri_bo *tmp_bo;
+    int tmp, ret;
 
-	new_buffer_ptrs[i] = new_buffer;
+    front_priv = front->driverPrivate;
+    back_priv = back->driverPrivate;
 
-	/* Swap the attachment types */
-	if (buffers[i]->attachment == DRI2BufferFrontLeft) {
-	    old_front_bo = bo;
-	    old_front_pixmap = pPixmap;
-	    front_buffer = i;
-	}
-	if (buffers[i]->attachment == DRI2BufferBackLeft) {
-	    new_front_bo = bo;
-	    new_front_pixmap = pPixmap;
-	    back_buffer = i;
-	    drm_intel_bo_reference(bo);
-	}
-    }
+    if (!i830_flip_ok(pDraw))
+	return FALSE;
 
     /* Swap BO names so DRI works */
-    tmp = new_buffer_ptrs[front_buffer]->name;
-    new_buffer_ptrs[front_buffer]->name = new_buffer_ptrs[back_buffer]->name;
-    new_buffer_ptrs[back_buffer]->name = tmp;
+    tmp = front->name;
+    front->name = back->name;
+    back->name = tmp;
 
-    /* Swap pixmaps */
-    private = new_buffer_ptrs[back_buffer]->driverPrivate;
-    i830_set_pixmap_bo(private->pPixmap, old_front_bo);
+    /* Swap pixmap bos */
+    dri_bo_reference(i830_get_pixmap_bo(front_priv->pPixmap));
 
-    private = new_buffer_ptrs[front_buffer]->driverPrivate;
-    i830_set_pixmap_bo(private->pPixmap, new_front_bo); /* should be screen */
+    tmp_bo = i830_get_pixmap_bo(front_priv->pPixmap);
+    i830_set_pixmap_bo(front_priv->pPixmap,
+		       i830_get_pixmap_bo(back_priv->pPixmap));
+    i830_set_pixmap_bo(back_priv->pPixmap, tmp_bo); /* should be screen */
 
-    /* Needed to hold refs around the set_bo calls... */
-    drm_intel_bo_unreference(old_front_bo);
+    if (front_priv->pPixmap != pScreen->GetScreenPixmap(pScreen))
+	FatalError("swapbuffers with bad front\n");
 
     /* Page flip the full screen buffer */
-    if (!drmmode_do_pageflip(pDraw, new_front_bo, old_front_bo)) {
-	for (i = 0; i < count; i++) {
-	    xfree(new_buffer_ptrs[i]->driverPrivate);
-	    xfree(new_buffer_ptrs[i]);
-	}
-	return NULL;
-    }
-
-    return new_buffer_ptrs;
+    return drmmode_do_pageflip(pDraw, i830_get_pixmap_bo(front_priv->pPixmap),
+			       i830_get_pixmap_bo(back_priv->pPixmap));
 }
 
 Bool I830DRI2ScreenInit(ScreenPtr pScreen)


More information about the xorg-commit mailing list