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

Chris Wilson ickle at kemper.freedesktop.org
Mon Dec 19 14:53:05 PST 2011


 src/sna/kgem.c      |    2 -
 src/sna/kgem.h      |    2 -
 src/sna/sna.h       |    1 
 src/sna/sna_accel.c |   86 +++++++++++++++++++++++++++-------------------------
 4 files changed, 47 insertions(+), 44 deletions(-)

New commits:
commit 06a1792f91d3ae2ebb17e4ad55caec10c5407aa6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 19 21:04:02 2011 +0000

    sna: Avoid the GPU readback with READ==0 move_to_cpu
    
    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 079a65f..cc244cb 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -837,6 +837,8 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 				sna_pixmap_free_cpu(sna, priv);
 			}
 		}
+
+		sna_damage_subtract(&priv->gpu_damage, region);
 	}
 
 	if (priv->mapped) {
commit 0b5fec3f80c8d2e4d3b504af5bb02fb76be6b3a6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 19 20:13:05 2011 +0000

    sna: Drop the is-mapped flag after operating via the GPU
    
    Mark the end of a sequence of CPU operations and force the decision to
    map again to be based on the current upload operation.
    
    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 4aed6a6..079a65f 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1341,6 +1341,10 @@ done:
 	sna_damage_reduce_all(&priv->gpu_damage,
 			      pixmap->drawable.width,
 			      pixmap->drawable.height);
+	if (priv->mapped) {
+		pixmap->devPrivate.ptr = NULL;
+		priv->mapped = 0;
+	}
 	list_del(&priv->list);
 	if (!priv->pinned)
 		list_move(&priv->inactive, &sna->active_pixmaps);
commit 351c8f16336e757b8a4d218b3afda0698781d143
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 19 19:51:12 2011 +0000

    sna: Discard all damage when replacing pixmap contents
    
    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 68fb700..4aed6a6 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -624,6 +624,9 @@ sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags)
 	if ((flags & MOVE_READ) == 0) {
 		assert(flags == MOVE_WRITE);
 
+		sna_damage_destroy(&priv->cpu_damage);
+		sna_damage_destroy(&priv->gpu_damage);
+
 		if (priv->gpu_bo && pixmap_inplace(sna, pixmap, priv)) {
 			if (kgem_bo_is_busy(priv->gpu_bo) &&
 			    priv->gpu_bo->exec == NULL)
commit addf66dda7cecaee8e58f53bb4e8d725dfdd2717
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 19 18:37:08 2011 +0000

    sna: Tweak the rendering priorities
    
    If the last operation was on the GPU, continue on the GPU if this
    operation overlaps any GPU damage or does not overlap CPU damage.
    Otherwise, if the last operation was on the CPU only switch to the GPU
    if we do not overlap any CPU damage and overlap existing GPU damage.
    
    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 a88257f..68fb700 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1048,20 +1048,29 @@ _sna_drawable_use_gpu_bo(DrawablePtr drawable,
 	extents.y1 += dy;
 	extents.y2 += dy;
 
-	if (priv->cpu_damage == NULL)
-		goto done;
-
-	if (sna_damage_contains_box(priv->cpu_damage,
-				    &extents) == PIXMAN_REGION_OUT)
-		goto done;
-
-	if (!priv->gpu || priv->gpu_damage == NULL)
-		return FALSE;
+	if (priv->gpu) {
+		if (priv->gpu_damage &&
+		    sna_damage_contains_box(priv->gpu_damage,
+					    &extents) != PIXMAN_REGION_OUT)
+			goto move_to_gpu;
+
+		if (priv->cpu_damage &&
+		    sna_damage_contains_box(priv->cpu_damage,
+					    &extents) != PIXMAN_REGION_OUT)
+			return FALSE;
+	} else {
+		if (priv->cpu_damage == NULL ||
+		    sna_damage_contains_box(priv->cpu_damage,
+					    &extents) == PIXMAN_REGION_OUT)
+			goto done;
 
-	if (sna_damage_contains_box(priv->gpu_damage,
-				    &extents) == PIXMAN_REGION_OUT)
-		return FALSE;
+		if (priv->gpu_damage == NULL ||
+		    sna_damage_contains_box(priv->gpu_damage,
+					    &extents) == PIXMAN_REGION_OUT)
+			return FALSE;
+	}
 
+move_to_gpu:
 	sna_pixmap_move_area_to_gpu(pixmap, &extents);
 done:
 	if (sna_damage_contains_box(priv->gpu_damage,
commit 9b6ade12346efa5b9cc095ad44c7d71880a19ab0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 19 17:21:26 2011 +0000

    sna: Create a GPU bo for accelerated core drawing
    
    As we now can accelerate most of the common core drawing operations, we
    can create GPU bo for accelerated drawing on first use without undue
    fear of readbacks. This benefits Qt especially which heavily uses core
    the drawing operations.
    
    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 5978811..a88257f 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1032,6 +1032,11 @@ _sna_drawable_use_gpu_bo(DrawablePtr drawable,
 
 	if (priv == NULL)
 		return FALSE;
+
+	if (pixmap->devPrivate.ptr == NULL &&
+	    !sna_pixmap_move_to_gpu(pixmap))
+		return FALSE;
+
 	if (priv->gpu_bo == NULL)
 		return FALSE;
 
commit eeb81dd6b4651c6b3e8676007d37480888726efa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 19 16:48:02 2011 +0000

    sna: Remove the forced inplace upload
    
    Make the decision per-operation, with a tendency to remain mapped.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 6c64d64..8869937 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -142,7 +142,6 @@ struct sna_pixmap {
 #define SOURCE_BIAS 4
 	uint16_t source_count;
 	uint8_t pinned :1;
-	uint8_t inplace :1;
 	uint8_t mapped :1;
 	uint8_t flush :1;
 	uint8_t gpu :1;
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 39aebb6..5978811 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -62,7 +62,6 @@
 #define USE_SPANS 0
 #define USE_ZERO_SPANS 1
 #define USE_BO_FOR_SCRATCH_PIXMAP 1
-#define INPLACE_MAP 1
 
 static int sna_font_key;
 
@@ -380,24 +379,6 @@ static struct sna_pixmap *_sna_pixmap_attach(struct sna *sna,
 	if (!priv)
 		return NULL;
 
-#if FORCE_INPLACE > 0
-	priv->inplace = 1;
-#elif FORCE_INPLACE < 0
-	priv->inplace = 0;
-#else
-	/* If the typical operation on the pixmap is larger than the
-	 * L2 cache, we presume that it will always be quicker to
-	 * upload directly than to copy via the shadow.
-	 *
-	 * "Typical operation" is currently chosen to maximise
-	 * x11perf on the various chipsets.
-	 */
-	priv->inplace =
-		(min(pixmap->drawable.width, 500) *
-		 min(pixmap->drawable.height, 500) *
-		 pixmap->drawable.bitsPerPixel >> 15) >
-		sna->kgem.cpu_cache_pages;
-#endif
 	list_init(&priv->list);
 	list_init(&priv->inactive);
 	priv->pixmap = pixmap;
@@ -510,7 +491,6 @@ sna_pixmap_create_scratch(ScreenPtr screen,
 	}
 
 	priv->freed = 1;
-	priv->inplace = 1;
 	sna_damage_all(&priv->gpu_damage, width, height);
 
 	miModifyPixmapHeader(pixmap,
@@ -614,10 +594,10 @@ static inline bool pixmap_inplace(struct sna *sna,
 				  PixmapPtr pixmap,
 				  struct sna_pixmap *priv)
 {
-	if (!INPLACE_MAP)
-		return false;
+	if (FORCE_INPLACE)
+		return FORCE_INPLACE > 0;
 
-	if (priv->inplace)
+	if (priv->mapped)
 		return true;
 
 	return (pixmap->devKind * pixmap->drawable.height >> 12) >
@@ -774,16 +754,16 @@ static inline bool region_inplace(struct sna *sna,
 				  RegionPtr region,
 				  struct sna_pixmap *priv)
 {
-	if (!INPLACE_MAP)
-		return false;
+	if (FORCE_INPLACE)
+		return FORCE_INPLACE > 0;
 
-	if (priv->inplace)
+	if (priv->mapped)
 		return true;
 
 	return ((region->extents.x2 - region->extents.x1) *
 		(region->extents.y2 - region->extents.y1) *
 		pixmap->drawable.bitsPerPixel >> 15)
-		> sna->kgem.half_cpu_cache_pages;
+		>= sna->kgem.half_cpu_cache_pages/2;
 }
 
 bool
@@ -985,7 +965,6 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box)
 
 	DBG(("%s()\n", __FUNCTION__));
 
-	assert(priv->gpu);
 	assert(priv->gpu_bo);
 
 	sna_damage_reduce(&priv->cpu_damage);
@@ -1038,6 +1017,7 @@ done:
 		list_del(&priv->list);
 	if (!priv->pinned)
 		list_move(&priv->inactive, &sna->active_pixmaps);
+	priv->gpu = true;
 }
 
 static inline Bool
@@ -1628,7 +1608,8 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 	 * So we try again with vma caching and only for pixmaps who will be
 	 * immediately flushed...
 	 */
-	if ((priv->flush || (priv->inplace && priv->gpu_bo)) &&
+	if ((priv->flush ||
+	     (priv->gpu_bo && region_inplace(sna, pixmap, region, priv))) &&
 	    sna_put_image_upload_blt(drawable, gc, region,
 				     x, y, w, h, bits, stride)) {
 		if (region_subsumes_drawable(region, &pixmap->drawable)) {
commit c3a8d77a2b6806a69de87fbaadea8612ef5f91dd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 19 16:51:29 2011 +0000

    sna: Tune the inplace cross-over point to be half-cache size
    
    The theory being that we will also require cache space to copy from when
    uploading into the shadow.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 41aded6..2d0b344 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -467,7 +467,7 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen)
 	kgem->wedged = drmCommandNone(kgem->fd, DRM_I915_GEM_THROTTLE) == -EIO;
 	kgem->wedged |= DBG_NO_HW;
 
-	kgem->cpu_cache_pages = cpu_cache_size() >> 12;
+	kgem->half_cpu_cache_pages = cpu_cache_size() >> 13;
 
 	list_init(&kgem->partial);
 	list_init(&kgem->requests);
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index efc4e80..42a0ba4 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -130,7 +130,7 @@ struct kgem {
 	uint32_t has_relaxed_fencing :1;
 
 	uint16_t fence_max;
-	uint16_t cpu_cache_pages;
+	uint16_t half_cpu_cache_pages;
 	uint32_t aperture_high, aperture_low, aperture;
 	uint32_t aperture_fenced, aperture_mappable;
 	uint32_t max_object_size;
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index e00f620..39aebb6 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -621,7 +621,7 @@ static inline bool pixmap_inplace(struct sna *sna,
 		return true;
 
 	return (pixmap->devKind * pixmap->drawable.height >> 12) >
-		sna->kgem.cpu_cache_pages;
+		sna->kgem.half_cpu_cache_pages;
 }
 
 bool
@@ -783,7 +783,7 @@ static inline bool region_inplace(struct sna *sna,
 	return ((region->extents.x2 - region->extents.x1) *
 		(region->extents.y2 - region->extents.y1) *
 		pixmap->drawable.bitsPerPixel >> 15)
-		> sna->kgem.cpu_cache_pages;
+		> sna->kgem.half_cpu_cache_pages;
 }
 
 bool


More information about the xorg-commit mailing list