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

Chris Wilson ickle at kemper.freedesktop.org
Sat Jul 21 08:47:08 PDT 2012


 src/sna/kgem.h      |    4 ++--
 src/sna/sna_accel.c |   36 ++++++++++++++++++++++++++++--------
 2 files changed, 30 insertions(+), 10 deletions(-)

New commits:
commit f1e7248cb353d634f27d297059911168ce1a0762
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 21 16:08:31 2012 +0100

    sna: Expand the heuristic for predicting when to use CPU bo for readback
    
    For tiny transfers, the cost of setting up the GPU operation outweighs
    the actual savings through increased throughput. So we try to guess when
    it will be preferrable to simply read from the GPU bo directly.
    
    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 5a9eb1e..5bec59a 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1093,12 +1093,31 @@ sna_pixmap_create_mappable_gpu(PixmapPtr pixmap)
 }
 
 static inline bool use_cpu_bo_for_download(struct sna *sna,
-					   struct sna_pixmap *priv)
+					   struct sna_pixmap *priv,
+					   const BoxRec *box)
 {
 	if (DBG_NO_CPU_DOWNLOAD)
 		return false;
 
-	return priv->cpu_bo != NULL && sna->kgem.can_blt_cpu;
+	if (priv->cpu_bo == NULL || !sna->kgem.can_blt_cpu)
+		return false;
+
+	if (kgem_bo_is_busy(priv->gpu_bo) || kgem_bo_is_busy(priv->cpu_bo)) {
+		DBG(("%s: yes, either bo is busy, so use GPU for readback\n",
+		     __FUNCTION__));
+		return true;
+	}
+
+	/* Is it worth detiling? */
+	if (kgem_bo_is_mappable(&sna->kgem, priv->gpu_bo) &&
+	    (box->y2 - box->y1 - 1) * priv->gpu_bo->pitch < 4096) {
+		DBG(("%s: no, tiny transfer, expect to read inplace\n",
+		     __FUNCTION__));
+		return false;
+	}
+
+	DBG(("%s: yes, default action\n", __FUNCTION__));
+	return true;
 }
 
 static inline bool use_cpu_bo_for_upload(struct sna_pixmap *priv,
@@ -1329,7 +1348,7 @@ skip_inplace_map:
 		if (n) {
 			bool ok = false;
 
-			if (use_cpu_bo_for_download(sna, priv)) {
+			if (use_cpu_bo_for_download(sna, priv, &priv->gpu_damage->extents)) {
 				DBG(("%s: using CPU bo for download from GPU\n", __FUNCTION__));
 				ok = sna->render.copy_boxes(sna, GXcopy,
 							    pixmap, priv->gpu_bo, 0, 0,
@@ -1794,7 +1813,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 			assert(pixmap_contains_damage(pixmap, priv->gpu_damage));
 
 			ok = false;
-			if (use_cpu_bo_for_download(sna, priv)) {
+			if (use_cpu_bo_for_download(sna, priv, &priv->gpu_damage->extents)) {
 				DBG(("%s: using CPU bo for download from GPU\n", __FUNCTION__));
 				ok = sna->render.copy_boxes(sna, GXcopy,
 							    pixmap, priv->gpu_bo, 0, 0,
@@ -1904,7 +1923,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 				if (n) {
 					bool ok = false;
 
-					if (use_cpu_bo_for_download(sna, priv)) {
+					if (use_cpu_bo_for_download(sna, priv, &priv->gpu_damage->extents)) {
 						DBG(("%s: using CPU bo for download from GPU\n", __FUNCTION__));
 						ok = sna->render.copy_boxes(sna, GXcopy,
 									    pixmap, priv->gpu_bo, 0, 0,
@@ -1931,7 +1950,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 				DBG(("%s: region wholly inside damage\n",
 				     __FUNCTION__));
 
-				if (use_cpu_bo_for_download(sna, priv)) {
+				if (use_cpu_bo_for_download(sna, priv, &r->extents)) {
 					DBG(("%s: using CPU bo for download from GPU\n", __FUNCTION__));
 					ok = sna->render.copy_boxes(sna, GXcopy,
 								    pixmap, priv->gpu_bo, 0, 0,
@@ -1958,7 +1977,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 					DBG(("%s: region intersects damage\n",
 					     __FUNCTION__));
 
-					if (use_cpu_bo_for_download(sna, priv)) {
+					if (use_cpu_bo_for_download(sna, priv, &need.extents)) {
 						DBG(("%s: using CPU bo for download from GPU\n", __FUNCTION__));
 						ok = sna->render.copy_boxes(sna, GXcopy,
 									    pixmap, priv->gpu_bo, 0, 0,
commit 06db69c2c7023f702f9773be90144fdf7a1159e4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 21 15:28:10 2012 +0100

    sna: Update assertion for cached io buffers
    
    As kgem_buffers may be reused and repurposed through the snoop cache it
    is no longer true that only proxies will have the io flag set.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 7b388fb..d7c3812 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -417,7 +417,7 @@ void kgem_get_tile_size(struct kgem *kgem, int tiling,
 
 static inline int __kgem_buffer_size(struct kgem_bo *bo)
 {
-	assert(bo->proxy && bo->io);
+	assert(bo->proxy != NULL);
 	return bo->size.bytes;
 }
 
@@ -429,7 +429,7 @@ static inline int __kgem_bo_size(struct kgem_bo *bo)
 
 static inline int kgem_bo_size(struct kgem_bo *bo)
 {
-	if (bo->io)
+	if (bo->proxy)
 		return __kgem_buffer_size(bo);
 	else
 		return __kgem_bo_size(bo);
commit d715e1e01437049e167462281d51b5e214594361
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 21 15:04:31 2012 +0100

    sna: Also discard the last-was-cpu flag when overwriting cpu damage
    
    We interpret a FillRect that erradicates the existing damage as a
    clear-event and an opportunity to see if it is worth migrating the
    render commands to the GPU. This is undermined if we leave the
    'prefer-cpu' flag intact.
    
    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 16f0c4e..5a9eb1e 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -10701,10 +10701,11 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect)
 					       pixmap->drawable.width,
 					       pixmap->drawable.height);
 				priv->undamaged = false;
-				priv->cpu = false;
 			}
 			hint |= IGNORE_CPU;
 		}
+		if (priv->cpu_damage == NULL)
+			priv->cpu = false;
 	}
 
 	bo = sna_drawable_use_bo(draw, hint, &region.extents, &damage);


More information about the xorg-commit mailing list