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

Chris Wilson ickle at kemper.freedesktop.org
Tue Dec 20 05:09:43 PST 2011


 src/sna/kgem.c      |    2 
 src/sna/sna.h       |    2 
 src/sna/sna_accel.c |  136 ++++++++++++++++++++++++++++++++--------------------
 3 files changed, 87 insertions(+), 53 deletions(-)

New commits:
commit d257a967396c517146cfb12bbec5cd28418752a3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 20 12:53:42 2011 +0000

    sna: Explicitly handle depth==1 scratch pixmaps
    
    Short-cut the determination of whether it can be tiled and accelerated
    -- we know it can't! This is mainly to cleanup the debug logs.
    
    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 4fd4fd9..47665dd 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -469,16 +469,21 @@ sna_pixmap_create_scratch(ScreenPtr screen,
 			  uint32_t tiling)
 {
 	struct sna *sna = to_sna_from_screen(screen);
-	PixmapPtr pixmap;
 	struct sna_pixmap *priv;
-	int bpp = BitsPerPixel(depth);
+	PixmapPtr pixmap;
+	int bpp;
 
 	DBG(("%s(%d, %d, %d, tiling=%d)\n", __FUNCTION__,
 	     width, height, depth, tiling));
 
+	if (depth < 8)
+		return create_pixmap(sna, screen, width, height, depth,
+				     CREATE_PIXMAP_USAGE_SCRATCH);
+
 	if (tiling == I915_TILING_Y && !sna->have_render)
 		tiling = I915_TILING_X;
 
+	bpp = BitsPerPixel(depth);
 	tiling = kgem_choose_tiling(&sna->kgem, tiling, width, height, bpp);
 	if (!kgem_can_create_2d(&sna->kgem, width, height, bpp, tiling))
 		return create_pixmap(sna, screen, width, height, depth,
commit 0c12f7cb01e75de3bf9c2af8ac6d5b4152566457
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 20 10:19:01 2011 +0000

    sna: Tidy up some recent valgrind complaints with reuse of scratch pixmaps
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 8869937..8deccc1 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -145,7 +145,7 @@ struct sna_pixmap {
 	uint8_t mapped :1;
 	uint8_t flush :1;
 	uint8_t gpu :1;
-	uint8_t freed :1;
+	uint8_t header :1;
 };
 
 struct sna_glyph {
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 183541d..4fd4fd9 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -269,11 +269,12 @@ static Bool sna_destroy_private(PixmapPtr pixmap, struct sna_pixmap *priv)
 		kgem_bo_destroy(&sna->kgem, priv->cpu_bo);
 	}
 
-	if (!sna->freed_pixmap && priv->freed) {
+	if (!sna->freed_pixmap && priv->header) {
 		sna->freed_pixmap = pixmap;
 		assert(priv->ptr == NULL);
 		priv->gpu_bo = NULL;
 		priv->cpu_bo = NULL;
+		priv->mapped = 0;
 		return false;
 	}
 
@@ -370,6 +371,35 @@ static inline void sna_set_pixmap(PixmapPtr pixmap, struct sna_pixmap *sna)
 	dixSetPrivate(&pixmap->devPrivates, &sna_pixmap_index, sna);
 }
 
+static struct sna_pixmap *
+_sna_pixmap_init(struct sna_pixmap *priv, PixmapPtr pixmap)
+{
+	list_init(&priv->list);
+	list_init(&priv->inactive);
+	priv->source_count = SOURCE_BIAS;
+	priv->pixmap = pixmap;
+
+	return priv;
+}
+
+static struct sna_pixmap *
+_sna_pixmap_reset(PixmapPtr pixmap)
+{
+	struct sna_pixmap *priv;
+
+	assert(pixmap->drawable.type == DRAWABLE_PIXMAP);
+	assert(pixmap->drawable.class == 0);
+	assert(pixmap->drawable.id == 0);
+	assert(pixmap->drawable.x == 0);
+	assert(pixmap->drawable.y == 0);
+
+	priv = sna_pixmap(pixmap);
+	assert(priv != NULL);
+
+	memset(priv, 0, sizeof(*priv));
+	return _sna_pixmap_init(priv, pixmap);
+}
+
 static struct sna_pixmap *_sna_pixmap_attach(struct sna *sna,
 					     PixmapPtr pixmap)
 {
@@ -379,12 +409,8 @@ static struct sna_pixmap *_sna_pixmap_attach(struct sna *sna,
 	if (!priv)
 		return NULL;
 
-	list_init(&priv->list);
-	list_init(&priv->inactive);
-	priv->pixmap = pixmap;
-
 	sna_set_pixmap(pixmap, priv);
-	return priv;
+	return _sna_pixmap_init(priv, pixmap);
 }
 
 struct sna_pixmap *sna_pixmap_attach(PixmapPtr pixmap)
@@ -463,15 +489,15 @@ sna_pixmap_create_scratch(ScreenPtr screen,
 		pixmap = sna->freed_pixmap;
 		sna->freed_pixmap = NULL;
 
-		priv = sna_pixmap(pixmap);
-		memset(priv, 0, sizeof(*priv));
-		list_init(&priv->list);
-		list_init(&priv->inactive);
-		priv->pixmap = pixmap;
+		pixmap->usage_hint = CREATE_PIXMAP_USAGE_SCRATCH;
+		pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+		pixmap->refcnt = 1;
+
+		priv = _sna_pixmap_reset(pixmap);
 	} else {
 		pixmap = create_pixmap(sna, screen, 0, 0, depth,
 				       CREATE_PIXMAP_USAGE_SCRATCH);
-		if (!pixmap)
+		if (pixmap == NullPixmap)
 			return NullPixmap;
 
 		priv = _sna_pixmap_attach(sna, pixmap);
@@ -490,12 +516,14 @@ sna_pixmap_create_scratch(ScreenPtr screen,
 		return NullPixmap;
 	}
 
-	priv->freed = 1;
+	priv->header = true;
 	sna_damage_all(&priv->gpu_damage, width, height);
 
-	miModifyPixmapHeader(pixmap,
-			     width, height, depth, bpp,
-			     priv->gpu_bo->pitch, NULL);
+	pixmap->drawable.width = width;
+	pixmap->drawable.height = height;
+	pixmap->drawable.depth = depth;
+	pixmap->drawable.bitsPerPixel = bpp;
+	pixmap->devKind = PixmapBytePad(width, depth);
 	pixmap->devPrivate.ptr = NULL;
 
 	return pixmap;
@@ -506,7 +534,6 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 				   unsigned int usage)
 {
 	PixmapPtr pixmap;
-	struct sna_pixmap *priv;
 	int pad, size;
 
 	DBG(("%s(%d, %d, %d, usage=%x)\n", __FUNCTION__,
@@ -538,34 +565,33 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 		usage = CREATE_PIXMAP_USAGE_SCRATCH_HEADER;
 #endif
 
-	/* XXX could use last deferred free? */
-
 	pad = PixmapBytePad(width, depth);
 	size = pad * height;
-	if (size < 4096) {
+	if (size <= 4096) {
 		pixmap = create_pixmap(to_sna_from_screen(screen), screen,
 				       width, height, depth, usage);
 		if (pixmap == NullPixmap)
 			return NullPixmap;
 
-		priv = sna_pixmap_attach(pixmap);
+		sna_pixmap_attach(pixmap);
 	} else {
-		pixmap = create_pixmap(to_sna_from_screen(screen), screen,
-				       0, 0, depth, usage);
+		struct sna *sna = to_sna_from_screen(screen);
+
+		pixmap = create_pixmap(sna, screen, 0, 0, depth, usage);
 		if (pixmap == NullPixmap)
 			return NullPixmap;
 
+		if (sna_pixmap_attach(pixmap) == NULL) {
+			free(pixmap);
+			return create_pixmap(sna, screen,
+					     width, height, depth,
+					     usage);
+		}
+
 		pixmap->drawable.width = width;
 		pixmap->drawable.height = height;
 		pixmap->devKind = pad;
 		pixmap->devPrivate.ptr = NULL;
-
-		priv = sna_pixmap_attach(pixmap);
-		if (priv == NULL) {
-			free(pixmap);
-			return create_pixmap(to_sna_from_screen(screen), screen,
-					     width, height, depth, usage);
-		}
 	}
 
 	return pixmap;
@@ -1175,7 +1201,9 @@ sna_pixmap_create_upload(ScreenPtr screen,
 		pixmap = sna->freed_pixmap;
 		sna->freed_pixmap = NULL;
 
-		priv = sna_pixmap(pixmap);
+		pixmap->usage_hint = CREATE_PIXMAP_USAGE_SCRATCH;
+		pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+		pixmap->refcnt = 1;
 	} else {
 		pixmap = create_pixmap(sna, screen, 0, 0, depth,
 				       CREATE_PIXMAP_USAGE_SCRATCH);
@@ -1187,8 +1215,13 @@ sna_pixmap_create_upload(ScreenPtr screen,
 			fbDestroyPixmap(pixmap);
 			return NullPixmap;
 		}
+
+		sna_set_pixmap(pixmap, priv);
 	}
 
+	priv = _sna_pixmap_reset(pixmap);
+	priv->header = true;
+
 	priv->gpu_bo = kgem_create_buffer(&sna->kgem,
 					  pad*height, KGEM_BUFFER_WRITE,
 					  &ptr);
@@ -1200,19 +1233,14 @@ sna_pixmap_create_upload(ScreenPtr screen,
 
 	priv->gpu_bo->pitch = pad;
 
-	priv->source_count = SOURCE_BIAS;
-	priv->cpu_bo = NULL;
-	priv->cpu_damage = priv->gpu_damage = NULL;
-	priv->ptr = NULL;
-	priv->pinned = 0;
-	priv->freed = 1;
-	list_init(&priv->list);
-	list_init(&priv->inactive);
-
-	priv->pixmap = pixmap;
-	sna_set_pixmap(pixmap, priv);
+	pixmap->drawable.width = width;
+	pixmap->drawable.height = height;
+	pixmap->drawable.depth = depth;
+	pixmap->drawable.bitsPerPixel = bpp;
+	pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+	pixmap->devKind = pad;
+	pixmap->devPrivate.ptr = ptr;
 
-	miModifyPixmapHeader(pixmap, width, height, depth, bpp, pad, ptr);
 	return pixmap;
 }
 
commit d3a4f5db149888239b78df1b9fcc5379b1603005
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 20 12:12:39 2011 +0000

    sna: Fixup the refcnt to avoid an assert
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 598df78..4ae7d14 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -991,6 +991,7 @@ static void kgem_finish_partials(struct kgem *kgem)
 				DBG(("%s: discarding unused partial array: %d/%d\n",
 				     __FUNCTION__, bo->used, bo->alloc));
 
+				bo->base.refcnt = 0; /* for valgrind */
 				kgem_bo_free(kgem, &bo->base);
 			}
 
commit ac52a1fcd11a3ab10e1843ed2d19f9cf818de4c1
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 20 02:20:48 2011 +0000

    sna: Don't immediately check for region intersection after subtract
    
    In the READ==0 case we know that the region does not intersect damage
    because we have just subtracted, and checking the intersection causes us
    to immediately apply the subtraction operation defeating the
    optimisation and forcing the expensive operation each time.
    
    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 833ffd1..183541d 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -837,8 +837,6 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 				sna_pixmap_free_cpu(sna, priv);
 			}
 		}
-
-		sna_damage_subtract(&priv->gpu_damage, region);
 	}
 
 	if (priv->mapped) {
@@ -853,6 +851,12 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 	if (priv->gpu_bo == NULL)
 		goto done;
 
+	if ((flags & MOVE_READ) == 0) {
+		assert(flags == MOVE_WRITE);
+		sna_damage_subtract(&priv->gpu_damage, region);
+		goto done;
+	}
+
 	if (sna_damage_contains_box(priv->gpu_damage,
 				    REGION_EXTENTS(NULL, region)) != PIXMAN_REGION_OUT) {
 		DBG(("%s: region (%dx%d) intersects gpu damage\n",
@@ -860,10 +864,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 		     region->extents.x2 - region->extents.x1,
 		     region->extents.y2 - region->extents.y1));
 
-		if ((flags & MOVE_READ) == 0) {
-			assert(flags == MOVE_WRITE);
-			sna_damage_subtract(&priv->gpu_damage, region);
-		} else if ((flags & MOVE_WRITE) == 0 &&
+		if ((flags & MOVE_WRITE) == 0 &&
 			   region->extents.x2 - region->extents.x1 == 1 &&
 			   region->extents.y2 - region->extents.y1 == 1) {
 			/*  Often associated with synchronisation, KISS */
commit 4071dca0ef8b2b1605f16bed5c42991885a35efd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 20 00:25:29 2011 +0000

    sna: Don't mark mapping as synchronous by default
    
    Only those that point into scratch memory need to synchronized before
    control is handed back to the client.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 2d0b344..598df78 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -2398,7 +2398,6 @@ struct kgem_bo *kgem_create_map(struct kgem *kgem,
 	}
 
 	bo->reusable = false;
-	bo->sync = true;
 	DBG(("%s(ptr=%p, size=%d, read_only=%d) => handle=%d\n",
 	     __FUNCTION__, ptr, size, read_only, handle));
 	return bo;


More information about the xorg-commit mailing list