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

Chris Wilson ickle at kemper.freedesktop.org
Wed Jan 11 07:59:34 PST 2012


 src/sna/kgem.c      |   18 +++++++++++-------
 src/sna/kgem.h      |    1 +
 src/sna/sna_accel.c |   19 +++++++++++++++++++
 3 files changed, 31 insertions(+), 7 deletions(-)

New commits:
commit b82851e74d5010ee08938ee42fa44c29fed633b1
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 11 15:42:00 2012 +0000

    sna: Mark upload pixmaps as being wholly GPU damaged
    
    So that subsequent code resists performing CPU operations with them
    (after they have been populated.)
    
    Marking both sides as wholly damaged breaks the rules, but should work
    out so long as we check whether we can perform the operation within the
    target damage first.
    
    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 2c61b09..ef0c577 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -746,6 +746,9 @@ _sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags)
 	     priv->gpu_bo ? priv->gpu_bo->handle : 0,
 	     priv->gpu_damage));
 
+	if (priv->cpu_damage && priv->cpu_damage->mode == DAMAGE_ALL)
+		goto done;
+
 	if ((flags & MOVE_READ) == 0) {
 		assert(flags == MOVE_WRITE);
 
@@ -995,6 +998,9 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 		return _sna_pixmap_move_to_cpu(pixmap, flags);
 	}
 
+	if (priv->cpu_damage && priv->cpu_damage->mode == DAMAGE_ALL)
+		goto done;
+
 	if ((flags & MOVE_READ) == 0) {
 		assert(flags == MOVE_WRITE);
 
@@ -1196,6 +1202,9 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box)
 
 	DBG(("%s()\n", __FUNCTION__));
 
+	if (priv->gpu_damage && priv->gpu_damage->mode == DAMAGE_ALL)
+		goto done;
+
 	if (priv->gpu_bo == NULL) {
 		struct sna *sna = to_sna_from_pixmap(pixmap);
 		unsigned flags;
@@ -1487,6 +1496,13 @@ sna_pixmap_create_upload(ScreenPtr screen,
 		return NullPixmap;
 	}
 
+	/* Marking both the shadow and the GPU bo is a little dubious,
+	 * but will work so long as we always check before doing the
+	 * transfer.
+	 */
+	sna_damage_all(&priv->gpu_damage, width, height);
+	sna_damage_all(&priv->cpu_damage, width, height);
+
 	pixmap->drawable.width = width;
 	pixmap->drawable.height = height;
 	pixmap->drawable.depth = depth;
@@ -1569,6 +1585,9 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 	if (priv == NULL)
 		return NULL;
 
+	if (priv->gpu_damage && priv->gpu_damage->mode == DAMAGE_ALL)
+		goto done;
+
 	sna_damage_reduce(&priv->cpu_damage);
 	DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL));
 
commit 2a5ab05f1690484c230e8f876a3f7aefb371af71
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 11 15:24:28 2012 +0000

    sna: Use a minimum alignment of 64
    
    We should be able to reduce this by disabling dual-stream mode of the
    GPU (which we want to achieve any way for 2D performance). Artefacts
    in small uploads demonstrate that we fail to do.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=44150
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index f7bf116..7636387 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -594,6 +594,12 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen)
 	DBG(("%s: aperture mappable=%d [%d]\n", __FUNCTION__,
 	     kgem->aperture_mappable, kgem->aperture_mappable / (1024*1024)));
 
+	kgem->min_alignment = 4;
+	if (gen < 60)
+		/* XXX workaround an issue where we appear to fail to
+		 * disable dual-stream mode */
+		kgem->min_alignment = 64;
+
 	kgem->max_object_size = kgem->aperture_mappable / 2;
 	if (kgem->max_object_size > kgem->aperture_low)
 		kgem->max_object_size = kgem->aperture_low;
@@ -621,10 +627,8 @@ static uint32_t kgem_untiled_pitch(struct kgem *kgem,
 				   uint32_t width, uint32_t bpp,
 				   bool scanout)
 {
-	/* XXX workaround an issue on gen3 where we appear to fail to
-	 * disable dual-stream mode */
-	return ALIGN(width * bpp,
-		     scanout || (kgem->gen >= 30 && kgem->gen < 33) ? 8*64 : 8*4) >> 3;
+	width = width * bpp >> 3;
+	return ALIGN(width, scanout ? 64 : kgem->min_alignment);
 }
 
 static uint32_t kgem_surface_size(struct kgem *kgem,
@@ -644,13 +648,13 @@ static uint32_t kgem_surface_size(struct kgem *kgem,
 			tile_width = 512;
 			tile_height = 16;
 		} else {
-			tile_width = scanout ? 64 : 4;
+			tile_width = scanout ? 64 : kgem->min_alignment;
 			tile_height = 2;
 		}
 	} else switch (tiling) {
 	default:
 	case I915_TILING_NONE:
-		tile_width = scanout || kgem->gen < 33 ? 64 : 4;
+		tile_width = scanout ? 64 : kgem->min_alignment;
 		tile_height = 2;
 		break;
 	case I915_TILING_X:
@@ -3077,7 +3081,7 @@ struct kgem_bo *kgem_create_buffer_2d(struct kgem *kgem,
 	int stride;
 
 	stride = ALIGN(width, 2) * bpp >> 3;
-	stride = ALIGN(stride, 4);
+	stride = ALIGN(stride, kgem->min_alignment);
 
 	bo = kgem_create_buffer(kgem, stride * ALIGN(height, 2), flags, ret);
 	if (bo == NULL)
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index d6fdfbc..12e5c2f 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -148,6 +148,7 @@ struct kgem {
 	uint16_t half_cpu_cache_pages;
 	uint32_t aperture_high, aperture_low, aperture;
 	uint32_t aperture_fenced, aperture_mappable;
+	uint32_t min_alignment;
 	uint32_t max_object_size;
 
 	void (*context_switch)(struct kgem *kgem, int new_mode);


More information about the xorg-commit mailing list