[Intel-gfx] [PATCH] UXA: Add support for tiled front/back/depth by cutting over to the GTT map.

Eric Anholt eric at anholt.net
Thu Nov 6 04:55:22 CET 2008


XXX: This commit doesn't quite work yet.  2D blits come out OK, but there are
syncing issues between rendering and fallbacks, easily visible in xterm.
---
 src/i830_exa.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/i830_exa.c b/src/i830_exa.c
index 9fcda51..75ec8ad 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -94,6 +94,11 @@ i830_pixmap_tiled(PixmapPtr pPixmap)
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     I830Ptr pI830 = I830PTR(pScrn);
     unsigned long offset;
+    dri_bo *bo;
+
+    bo = i830_get_pixmap_bo(pPixmap);
+    if ((bo != NULL) && bo == pI830->front_buffer->bo)
+	return pI830->front_buffer->tiling != TILE_NONE;
 
     offset = intel_get_pixmap_offset(pPixmap);
     if (offset == pI830->front_buffer->offset &&
@@ -747,6 +752,8 @@ i830_uxa_set_pixmap_bo (PixmapPtr pixmap, dri_bo *bo)
 static Bool
 i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 {
+    ScrnInfoPtr pScrn = xf86Screens[pixmap->drawable.pScreen->myNum];
+    I830Ptr pI830 = I830PTR(pScrn);
     dri_bo *bo = i830_get_pixmap_bo (pixmap);
 
     if (bo) {
@@ -755,10 +762,21 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 	I830Ptr i830 = I830PTR(scrn);
 	
 	intel_batch_flush(scrn, FALSE);
+	/* XXX: dri_bo_map should handle syncing for us, what's the deal? */
 	if (i830->need_sync) {
 	    I830Sync(scrn);
 	    i830->need_sync = FALSE;
 	}
+
+	/* For tiled front buffer, short-circuit to the GTT mapping. */
+	if (bo == pI830->front_buffer->bo &&
+	    pI830->front_buffer->tiling != TILE_NONE) {
+
+	    dri_bo_wait_rendering(bo);
+	    pixmap->devPrivate.ptr = pI830->FbBase + bo->offset;
+	    return TRUE;
+	}
+
 	if (dri_bo_map (bo, access == UXA_ACCESS_RW) != 0)
 	    return FALSE;
         pixmap->devPrivate.ptr = bo->virtual;
@@ -769,14 +787,29 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 static void
 i830_uxa_finish_access (PixmapPtr pixmap)
 {
+    ScrnInfoPtr pScrn = xf86Screens[pixmap->drawable.pScreen->myNum];
+    I830Ptr pI830 = I830PTR(pScrn);
     dri_bo *bo = i830_get_pixmap_bo (pixmap);
 
     if (bo) {
 	ScreenPtr screen = pixmap->drawable.pScreen;
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	I830Ptr i830 = I830PTR(scrn);
-	
-	dri_bo_unmap (bo);
+
+	/* Flush the caches since we just touched pixels in the GTT without
+	 * GEM getting to know about it.
+	 */
+	if (bo == pI830->front_buffer->bo &&
+	    pI830->front_buffer->tiling != TILE_NONE) {
+	    BEGIN_BATCH(2);
+	    OUT_BATCH(MI_FLUSH |
+		      MI_STATE_INSTRUCTION_CACHE_FLUSH |
+		      BRW_MI_GLOBAL_SNAPSHOT_RESET);
+	    OUT_BATCH(MI_NOOP);
+	    ADVANCE_BATCH();
+	} else
+	    dri_bo_unmap(bo);
+
 	pixmap->devPrivate.ptr = NULL;
 	if (bo == i830->front_buffer->bo)
 	    i830->need_flush = TRUE;
-- 
1.5.6.5




More information about the Intel-gfx mailing list