xf86-video-intel: 3 commits - src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_io.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Jan 26 06:43:40 PST 2012


 src/sna/kgem.c      |   21 +++++++++++----
 src/sna/kgem.h      |   14 +++++++++-
 src/sna/sna_accel.c |   12 ++++++---
 src/sna/sna_io.c    |   69 ++++++++++++++++++++++++++++++++++------------------
 4 files changed, 82 insertions(+), 34 deletions(-)

New commits:
commit b1f9415bf355e9fbd6fc3ce8fa1af59083ca2943
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 26 13:59:24 2012 +0000

    sna: Allow gen4+ to use larger GPU bo
    
    As the blitter on gen4+ does not require fence registers, it is not
    restricted to operating on large objects within the mappable aperture.
    As we do not need to operate on such large GPU bo in place, we can relax
    the restriction on the maximum bo size for gen4+ to allocate for use
    with the GPU.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 6cd86e6..4df29d2 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -658,15 +658,22 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen)
 		 * disable dual-stream mode */
 		kgem->min_alignment = 64;
 
-	kgem->max_gpu_size = kgem->aperture_mappable / 2;
-	if (kgem->max_gpu_size > kgem->aperture_low)
-		kgem->max_gpu_size = kgem->aperture_low;
-	if (kgem->max_gpu_size > MAX_OBJECT_SIZE)
-		kgem->max_gpu_size = MAX_OBJECT_SIZE;
-
 	kgem->max_cpu_size = kgem->aperture_total / 2;
 	if (kgem->max_cpu_size > MAX_OBJECT_SIZE)
 		kgem->max_cpu_size = MAX_OBJECT_SIZE;
+
+	kgem->max_gpu_size = -1;
+	if (gen < 40) {
+		/* If we have to use fences for blitting, we have to make
+		 * sure we can fit them into the aperture.
+		 */
+		kgem->max_gpu_size = kgem->aperture_mappable / 2;
+		if (kgem->max_gpu_size > kgem->aperture_low)
+			kgem->max_gpu_size = kgem->aperture_low;
+	}
+	if (kgem->max_gpu_size > kgem->max_cpu_size)
+		kgem->max_gpu_size = kgem->max_cpu_size;
+
 	DBG(("%s: max object size (tiled=%d, linear=%d)\n",
 	     __FUNCTION__, kgem->max_gpu_size, kgem->max_cpu_size));
 
@@ -2729,6 +2736,8 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
 
 	ptr = bo->map;
 	if (ptr == NULL) {
+		assert(bo->size <= kgem->aperture_mappable / 4);
+
 		kgem_trim_vma_cache(kgem, MAP_GTT, bo->bucket);
 
 		ptr = gem_mmap(kgem->fd, bo->handle, bo->size,
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 0cc4fd3..0dc67da 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -363,10 +363,16 @@ static inline bool kgem_bo_is_mappable(struct kgem *kgem,
 	if (bo->domain == DOMAIN_GTT)
 		return true;
 
+	if (IS_GTT_MAP(bo->map))
+		return true;
+
 	if (kgem->gen < 40 && bo->tiling &&
 	    bo->presumed_offset & (kgem_bo_fenced_size(kgem, bo) - 1))
 		return false;
 
+	if (!bo->presumed_offset)
+		return bo->size <= kgem->aperture_mappable / 4;
+
 	return bo->presumed_offset + bo->size <= kgem->aperture_mappable;
 }
 
commit d35b6955dbb5d652d8685d2c1ea82c5e08de55ea
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 26 14:34:36 2012 +0000

    sna: Prevent mapping through the GTT for large bo
    
    If the bo is larger than a quarter of the aperture, it is unlikely that
    we will be able to evict enough contiguous space in the GATT to
    accommodate that buffer. So don't attempt to map them and use the
    indirect access instead.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index db4f061..0cc4fd3 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -394,13 +394,19 @@ static inline bool kgem_bo_map_will_stall(struct kgem *kgem, struct kgem_bo *bo)
 	     __FUNCTION__, bo->handle,
 	     bo->domain, bo->presumed_offset, bo->size));
 
+	if (!kgem_bo_is_mappable(kgem, bo))
+		return true;
+
+	if (kgem->wedged)
+		return false;
+
 	if (kgem_bo_is_busy(bo))
 		return true;
 
 	if (bo->presumed_offset == 0)
 		return !list_is_empty(&kgem->requests);
 
-	return !kgem_bo_is_mappable(kgem, bo);
+	return false;
 }
 
 static inline bool kgem_bo_is_dirty(struct kgem_bo *bo)
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index b3b968c..7fe06de 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -797,7 +797,7 @@ sna_pixmap_create_mappable_gpu(PixmapPtr pixmap)
 			       sna_pixmap_choose_tiling(pixmap),
 			       CREATE_GTT_MAP | CREATE_INACTIVE);
 
-	return priv->gpu_bo != NULL;
+	return priv->gpu_bo && kgem_bo_is_mappable(&sna->kgem, priv->gpu_bo);
 }
 
 bool
@@ -835,7 +835,8 @@ _sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags)
 				    priv->gpu_bo->exec == NULL)
 					kgem_retire(&sna->kgem);
 
-				if (kgem_bo_is_busy(priv->gpu_bo)) {
+				if (kgem_bo_map_will_stall(&sna->kgem,
+							   priv->gpu_bo)) {
 					if (priv->pinned)
 						goto skip_inplace_map;
 
@@ -897,7 +898,7 @@ skip_inplace_map:
 
 	if (flags & MOVE_INPLACE_HINT &&
 	    priv->stride && priv->gpu_bo &&
-	    !kgem_bo_is_busy(priv->gpu_bo) &&
+	    !kgem_bo_map_will_stall(&sna->kgem, priv->gpu_bo) &&
 	    pixmap_inplace(sna, pixmap, priv) &&
 	    sna_pixmap_move_to_gpu(pixmap, flags)) {
 		assert(flags & MOVE_WRITE);
@@ -1250,7 +1251,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 
 	if (flags & MOVE_INPLACE_HINT &&
 	    priv->stride && priv->gpu_bo &&
-	    !kgem_bo_is_busy(priv->gpu_bo) &&
+	    !kgem_bo_map_will_stall(&sna->kgem, priv->gpu_bo) &&
 	    region_inplace(sna, pixmap, region, priv) &&
 	    sna_pixmap_move_area_to_gpu(pixmap, &region->extents, flags)) {
 		assert(flags & MOVE_WRITE);
diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c
index a2e7a59..f3ca212 100644
--- a/src/sna/sna_io.c
+++ b/src/sna/sna_io.c
@@ -122,8 +122,7 @@ void sna_read_boxes(struct sna *sna,
 	 * this path.
 	 */
 
-	if (DEBUG_NO_IO || kgem->wedged ||
-	    !kgem_bo_map_will_stall(kgem, src_bo) ||
+	if (!kgem_bo_map_will_stall(kgem, src_bo) ||
 	    src_bo->tiling == I915_TILING_NONE) {
 fallback:
 		read_boxes_inplace(kgem,
@@ -386,10 +385,7 @@ static bool upload_inplace(struct kgem *kgem,
 			   int n, int bpp)
 {
 	if (DEBUG_NO_IO)
-		return true;
-
-	if (unlikely(kgem->wedged))
-		return true;
+		return kgem_bo_is_mappable(kgem, bo);
 
 	/* If we are writing through the GTT, check first if we might be
 	 * able to almagamate a series of small writes into a single
@@ -993,14 +989,27 @@ struct kgem_bo *sna_replace(struct sna *sna,
 		kgem_bo_write(kgem, bo, src,
 			      (pixmap->drawable.height-1)*stride + pixmap->drawable.width*pixmap->drawable.bitsPerPixel/8);
 	} else {
-		dst = kgem_bo_map(kgem, bo);
-		if (dst) {
-			memcpy_blt(src, dst, pixmap->drawable.bitsPerPixel,
-				   stride, bo->pitch,
-				   0, 0,
-				   0, 0,
-				   pixmap->drawable.width,
-				   pixmap->drawable.height);
+		if (kgem_bo_is_mappable(kgem, bo)) {
+			dst = kgem_bo_map(kgem, bo);
+			if (dst) {
+				memcpy_blt(src, dst, pixmap->drawable.bitsPerPixel,
+					   stride, bo->pitch,
+					   0, 0,
+					   0, 0,
+					   pixmap->drawable.width,
+					   pixmap->drawable.height);
+			}
+		} else {
+			BoxRec box;
+
+			box.x1 = box.y1 = 0;
+			box.x2 = pixmap->drawable.width;
+			box.y2 = pixmap->drawable.height;
+
+			sna_write_boxes(sna, pixmap,
+					bo, 0, 0,
+					src, stride, 0, 0,
+					&box, 1);
 		}
 	}
 
@@ -1038,15 +1047,29 @@ struct kgem_bo *sna_replace__xor(struct sna *sna,
 		}
 	}
 
-	dst = kgem_bo_map(kgem, bo);
-	if (dst) {
-		memcpy_xor(src, dst, pixmap->drawable.bitsPerPixel,
-			   stride, bo->pitch,
-			   0, 0,
-			   0, 0,
-			   pixmap->drawable.width,
-			   pixmap->drawable.height,
-			   and, or);
+	if (kgem_bo_is_mappable(kgem, bo)) {
+		dst = kgem_bo_map(kgem, bo);
+		if (dst) {
+			memcpy_xor(src, dst, pixmap->drawable.bitsPerPixel,
+				   stride, bo->pitch,
+				   0, 0,
+				   0, 0,
+				   pixmap->drawable.width,
+				   pixmap->drawable.height,
+				   and, or);
+		}
+	} else {
+		BoxRec box;
+
+		box.x1 = box.y1 = 0;
+		box.x2 = pixmap->drawable.width;
+		box.y2 = pixmap->drawable.height;
+
+		sna_write_boxes__xor(sna, pixmap,
+				     bo, 0, 0,
+				     src, stride, 0, 0,
+				     &box, 1,
+				     and, or);
 	}
 
 	return bo;
commit 7c81bcd0c425cc0f7ddf2ad8289bb739c8d44289
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 26 13:35:15 2012 +0000

    sna: Add FORCE_FALLBACK debugging hook for PutImage
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 759e0fe..b3b968c 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2907,6 +2907,9 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth,
 
 	RegionTranslate(&region, dx, dy);
 
+	if (FORCE_FALLBACK)
+		goto fallback;
+
 	if (wedged(sna))
 		goto fallback;
 


More information about the xorg-commit mailing list