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

Chris Wilson ickle at kemper.freedesktop.org
Tue Aug 14 04:08:28 PDT 2012


 src/sna/sna_accel.c |   36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

New commits:
commit 9f07d1fc0181f22da36837337241f228626e0d88
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Aug 14 12:03:24 2012 +0100

    sna: Enable use of shm pixmap for readback
    
    A little too overzealous in the degradation of writing to the CPU bo
    if we need to read from a GPU bo.
    
    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 136aceb..bd07662 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2341,6 +2341,8 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box,
 	}
 
 	if (priv->gpu_bo && priv->gpu_bo->proxy) {
+		DBG(("%s: cached upload proxy, discard and revert to GPU\n",
+		     __FUNCTION__));
 		kgem_bo_destroy(&to_sna_from_pixmap(pixmap)->kgem,
 				priv->gpu_bo);
 		priv->gpu_bo = NULL;
@@ -2350,19 +2352,32 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box,
 	if (priv->flush)
 		flags |= PREFER_GPU;
 	if (priv->shm)
-		flags = 0;
+		flags &= ~PREFER_GPU;
 	if (priv->cpu && (flags & FORCE_GPU) == 0)
-		flags = 0;
+		flags &= ~PREFER_GPU;
+
+	DBG(("%s: flush=%d, shm=%d, cpu=%d => flags=%x\n",
+	     __FUNCTION__, priv->flush, priv->shm, priv->cpu, flags));
 
-	if (!flags && (!priv->gpu_damage || !kgem_bo_is_busy(priv->gpu_bo)))
+	if ((flags & PREFER_GPU) == 0 &&
+	    (!priv->gpu_damage || !kgem_bo_is_busy(priv->gpu_bo))) {
+		DBG(("%s: try cpu as GPU bo is idle\n", __FUNCTION__));
 		goto use_cpu_bo;
+	}
 
-	if (DAMAGE_IS_ALL(priv->gpu_damage))
+	if (DAMAGE_IS_ALL(priv->gpu_damage)) {
+		DBG(("%s: use GPU fast path (all-damaged)\n", __FUNCTION__));
 		goto use_gpu_bo;
+	}
 
-	if (DAMAGE_IS_ALL(priv->cpu_damage))
+	if (DAMAGE_IS_ALL(priv->cpu_damage)) {
+		DBG(("%s: use CPU fast path (all-damaged)\n", __FUNCTION__));
 		goto use_cpu_bo;
+	}
 
+	DBG(("%s: gpu? %d, damaged? %d; cpu? %d, damaged? %d\n", __FUNCTION__,
+	     priv->gpu_bo ? priv->gpu_bo->handle : 0, priv->gpu_damage != NULL,
+	     priv->cpu_bo ? priv->cpu_bo->handle : 0, priv->cpu_damage != NULL));
 	if (priv->gpu_bo == NULL) {
 		unsigned int move;
 
@@ -2502,7 +2517,7 @@ use_cpu_bo:
 	if (!to_sna_from_pixmap(pixmap)->kgem.can_blt_cpu)
 		return NULL;
 
-	if (flags == 0 && !kgem_bo_is_busy(priv->cpu_bo))
+	if ((flags & FORCE_GPU) == 0 && !kgem_bo_is_busy(priv->cpu_bo))
 		return NULL;
 
 	get_drawable_deltas(drawable, pixmap, &dx, &dy);
@@ -4008,6 +4023,9 @@ source_prefer_gpu(struct sna_pixmap *priv)
 		return PREFER_GPU | FORCE_GPU;
 	}
 
+	if (DAMAGE_IS_ALL(priv->cpu_damage))
+		return 0;
+
 	DBG(("%s: source has GPU bo? %d\n",
 	     __FUNCTION__, priv->gpu_bo != NULL));
 	return priv->gpu_bo != NULL;
commit 9b016d2e466f342cc6649504fa48ab6a810c7e94
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Aug 12 21:36:30 2012 +0100

    sna: do not bother attaching to a miniscule ShmPixmap
    
    If the pixmap is less than a page in size we are unlikely to recover the
    cost of tracking it via the GPU.
    
    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 b27e7fb..136aceb 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -757,7 +757,7 @@ sna_pixmap_create_shm(ScreenPtr screen,
 	DBG(("%s(%dx%d, depth=%d, bpp=%d, pitch=%d)\n",
 	     __FUNCTION__, width, height, depth, bpp, pitch));
 
-	if (wedged(sna) || bpp == 0) {
+	if (wedged(sna) || bpp == 0 || pitch*height <= 4096) {
 fallback:
 		pixmap = sna_pixmap_create_unattached(screen, 0, 0, depth);
 		if (pixmap == NULL)
@@ -809,9 +809,7 @@ fallback:
 		}
 	}
 
-	priv->cpu_bo = kgem_create_map(&sna->kgem,
-				       addr, pitch*(height-1)+width*bpp/8,
-				       false);
+	priv->cpu_bo = kgem_create_map(&sna->kgem, addr, pitch*height, false);
 	if (priv->cpu_bo == NULL) {
 		priv->header = true;
 		sna_pixmap_destroy(pixmap);


More information about the xorg-commit mailing list