xf86-video-intel: 5 commits - src/intel_driver.h src/intel.h src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_render.c

Chris Wilson ickle at kemper.freedesktop.org
Sun Dec 18 09:46:29 PST 2011


 src/intel.h           |    2 -
 src/intel_driver.h    |    3 +
 src/sna/gen5_render.c |   41 ++++++++++++++------------
 src/sna/gen6_render.c |    4 +-
 src/sna/gen7_render.c |    4 +-
 src/sna/kgem.c        |   78 ++++++++++++++++++++++++++------------------------
 src/sna/sna_accel.c   |   13 ++++----
 src/sna/sna_render.c  |    3 +
 8 files changed, 80 insertions(+), 68 deletions(-)

New commits:
commit a0c0a3765ca348c74096fb157885da5b1258ee08
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Dec 18 16:59:15 2011 +0000

    sna: Retire if the inactive vma list is empty
    
    Try to recycle vma by first trying to populate the inactive list before
    scanning for a vma bo to harvest.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 80ed710..3033f5f 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1709,43 +1709,45 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem,
 		/* We presume that we will need to upload to this bo,
 		 * and so would prefer to have an active VMA.
 		 */
-		list_for_each_entry(bo, &kgem->vma_inactive, vma) {
-			assert(bo->refcnt == 0);
-			assert(bo->map);
-			assert(bo->rq == NULL);
-			assert(list_is_empty(&bo->request));
+		do {
+			list_for_each_entry(bo, &kgem->vma_inactive, vma) {
+				assert(bo->refcnt == 0);
+				assert(bo->map);
+				assert(bo->rq == NULL);
+				assert(list_is_empty(&bo->request));
+
+				if (size > bo->size || 2*size < bo->size) {
+					DBG(("inactive vma too small/large: %d < %d\n",
+					     bo->size, size));
+					continue;
+				}
 
-			if (size > bo->size || 2*size < bo->size) {
-				DBG(("inactive vma too small/large: %d < %d\n",
-				     bo->size, size));
-				continue;
-			}
+				if (bo->tiling != tiling ||
+				    (tiling != I915_TILING_NONE && bo->pitch != pitch)) {
+					DBG(("inactive vma with wrong tiling: %d < %d\n",
+					     bo->tiling, tiling));
+					continue;
+				}
 
-			if (bo->tiling != tiling ||
-			    (tiling != I915_TILING_NONE && bo->pitch != pitch)) {
-				DBG(("inactive vma with wrong tiling: %d < %d\n",
-				     bo->tiling, tiling));
-				continue;
-			}
+				bo->pitch = pitch;
+				list_del(&bo->list);
 
-			bo->pitch = pitch;
-			list_del(&bo->list);
+				if (bo->purged && !kgem_bo_clear_purgeable(kgem, bo)) {
+					kgem_bo_free(kgem, bo);
+					break;
+				}
 
-			if (bo->purged && !kgem_bo_clear_purgeable(kgem, bo)) {
-				kgem_bo_free(kgem, bo);
-				break;
+				bo->delta = 0;
+				bo->unique_id = kgem_get_unique_id(kgem);
+				list_move_tail(&bo->vma, &kgem->vma_cache);
+				assert(bo->pitch);
+				DBG(("  from inactive vma: pitch=%d, tiling=%d: handle=%d, id=%d\n",
+				     bo->pitch, bo->tiling, bo->handle, bo->unique_id));
+				assert(bo->reusable);
+				assert(bo->domain != DOMAIN_GPU && !kgem_busy(kgem, bo->handle));
+				return kgem_bo_reference(bo);
 			}
-
-			bo->delta = 0;
-			bo->unique_id = kgem_get_unique_id(kgem);
-			list_move_tail(&bo->vma, &kgem->vma_cache);
-			assert(bo->pitch);
-			DBG(("  from inactive vma: pitch=%d, tiling=%d: handle=%d, id=%d\n",
-			     bo->pitch, bo->tiling, bo->handle, bo->unique_id));
-			assert(bo->reusable);
-			assert(bo->domain != DOMAIN_GPU && !kgem_busy(kgem, bo->handle));
-			return kgem_bo_reference(bo);
-		}
+		} while (kgem_retire(kgem));
 
 		goto skip_active_search;
 	}
@@ -2077,17 +2079,21 @@ static void kgem_trim_vma_cache(struct kgem *kgem)
 					      struct kgem_bo,
 					      vma);
 		}
-		DBG(("%s: discarding %s vma cache for %d\n",
-		     __FUNCTION__, IS_CPU_MAP(old->map) ? "CPU" : "GTT",
-		     old->handle));
+		DBG(("%s: discarding %s %s vma cache for %d\n",
+		     __FUNCTION__,
+		     list_is_empty(&kgem->vma_inactive) ? "cached" : "inactive",
+		     IS_CPU_MAP(old->map) ? "CPU" : "GTT", old->handle));
 		assert(old->map);
 		munmap(CPU_MAP(old->map), old->size);
 		old->map = NULL;
 		list_del(&old->vma);
 		kgem->vma_count--;
 
-		if (old->rq == NULL && old->refcnt == 0)
+		if (old->rq == NULL && old->refcnt == 0) {
+			DBG(("%s: discarding unused vma bo handle=%d\n",
+			     __FUNCTION__, old->handle));
 			kgem_bo_free(kgem, old);
+}
 	}
 }
 
commit 34efb7314612cedcda4f866bc33f3ad5b6929ae2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Dec 18 16:58:04 2011 +0000

    sna: Hint likely usage of CPU bo
    
    If we are going to transfer GPU damage back to the CPU bo, then we can
    reuse an active buffer and so improve the recycling.
    
    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 fdd3e90..976066e 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -187,7 +187,8 @@ static void sna_pixmap_destroy_gpu_bo(struct sna *sna, struct sna_pixmap *priv)
 static bool must_check
 sna_pixmap_alloc_cpu(struct sna *sna,
 		     PixmapPtr pixmap,
-		     struct sna_pixmap *priv)
+		     struct sna_pixmap *priv,
+		     bool from_gpu)
 {
 	assert(priv->ptr == NULL);
 	assert(pixmap->devKind);
@@ -201,7 +202,7 @@ sna_pixmap_alloc_cpu(struct sna *sna,
 					      pixmap->drawable.height,
 					      pixmap->drawable.bitsPerPixel,
 					      I915_TILING_NONE,
-					      CREATE_INACTIVE);
+					      from_gpu ? 0 : CREATE_INACTIVE);
 		DBG(("%s: allocated CPU handle=%d\n", __FUNCTION__,
 		     priv->cpu_bo->handle));
 
@@ -685,7 +686,7 @@ skip_inplace_map:
 	}
 
 	if (pixmap->devPrivate.ptr == NULL &&
-	    !sna_pixmap_alloc_cpu(sna, pixmap, priv))
+	    !sna_pixmap_alloc_cpu(sna, pixmap, priv, priv->gpu_damage != NULL))
 		return false;
 
 	if (priv->gpu_bo == NULL) {
@@ -856,7 +857,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 	}
 
 	if (pixmap->devPrivate.ptr == NULL &&
-	    !sna_pixmap_alloc_cpu(sna, pixmap, priv))
+	    !sna_pixmap_alloc_cpu(sna, pixmap, priv, priv->gpu_damage != NULL))
 		return false;
 
 	if (priv->gpu_bo == NULL)
@@ -1680,7 +1681,7 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 	}
 
 	if (pixmap->devPrivate.ptr == NULL &&
-	    !sna_pixmap_alloc_cpu(sna, pixmap, priv))
+	    !sna_pixmap_alloc_cpu(sna, pixmap, priv, false))
 		return true;
 
 	if (region_subsumes_drawable(region, &pixmap->drawable)) {
@@ -8974,7 +8975,7 @@ sna_pixmap_free_gpu(struct sna *sna, struct sna_pixmap *priv)
 	assert (!priv->flush);
 
 	if (pixmap->devPrivate.ptr == NULL &&
-	    !sna_pixmap_alloc_cpu(sna, pixmap, priv))
+	    !sna_pixmap_alloc_cpu(sna, pixmap, priv, priv->gpu_damage != NULL))
 		return false;
 
 	if (priv->gpu_damage) {
commit 301896743867de0cbd22063c4bf2e1a8cf491656
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Dec 18 16:17:04 2011 +0000

    sna: Only upload to the source GPU bo if we need tiling to avoid TLB misses
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index c92ecb6..40318aa 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -273,7 +273,8 @@ use_cpu_bo(struct sna *sna, PixmapPtr pixmap, const BoxRec *box)
 		goto done;
 
 	if (priv->gpu_bo) {
-		if (priv->gpu_bo != I915_TILING_NONE) {
+		if (priv->gpu_bo != I915_TILING_NONE &&
+		    priv->cpu_bo->pitch >= 4096) {
 			DBG(("%s: GPU bo exists and is tiled [%d], upload\n",
 			     __FUNCTION__, priv->gpu_bo->tiling));
 			return NULL;
commit b7f5d75aa54db7d0542b09f4b3081f7692ede602
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Dec 18 16:11:34 2011 +0000

    Silence uxa-only compilation
    
    Kill the stray warning for the undeclared extern used by the module
    loader.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel.h b/src/intel.h
index b497bdf..5698131 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -721,8 +721,6 @@ static inline Bool pixmap_is_scanout(PixmapPtr pixmap)
 	return pixmap == screen->GetScreenPixmap(screen);
 }
 
-const OptionInfoRec *intel_uxa_available_options(int chipid, int busid);
-
 Bool intel_uxa_init(ScreenPtr pScreen);
 Bool intel_uxa_create_screen_resources(ScreenPtr pScreen);
 void intel_uxa_block_handler(intel_screen_private *intel);
diff --git a/src/intel_driver.h b/src/intel_driver.h
index 4a584fe..e9d6d9e 100644
--- a/src/intel_driver.h
+++ b/src/intel_driver.h
@@ -246,4 +246,7 @@ void intel_detect_chipset(ScrnInfoPtr scrn,
 			  struct pci_device *pci,
 			  struct intel_chipset *chipset);
 
+const OptionInfoRec *intel_uxa_available_options(int chipid, int busid);
+
+
 #endif /* INTEL_DRIVER_H */
commit a73cc4bf1e554806f403c6704d1cf98491f4d444
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Dec 18 14:54:12 2011 +0000

    sna/gen5: Tidy checking against hardcoded maximum 3D size
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index da9de8d..4f5b57c 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -56,6 +56,8 @@
 #define DBG_NO_STATE_CACHE 0
 #define DBG_NO_SURFACE_CACHE 0
 
+#define MAX_3D_SIZE 8192
+
 #define GEN5_GRF_BLOCKS(nreg)    ((nreg + 15) / 16 - 1)
 
 /* Set up a default static partitioning of the URB, which is supposed to
@@ -278,6 +280,11 @@ gen5_emit_pipelined_pointers(struct sna *sna,
 #define OUT_VERTEX(x,y) vertex_emit_2s(sna, x,y)
 #define OUT_VERTEX_F(v) vertex_emit(sna, v)
 
+static inline bool too_large(int width, int height)
+{
+	return (width | height) > MAX_3D_SIZE;
+}
+
 static int
 gen5_choose_composite_kernel(int op, Bool has_mask, Bool is_ca, Bool is_affine)
 {
@@ -1811,7 +1818,7 @@ gen5_composite_picture(struct sna *sna,
 		return sna_render_picture_convert(sna, picture, channel, pixmap,
 						  x, y, w, h, dst_x, dst_y);
 
-	if (pixmap->drawable.width > 8192 || pixmap->drawable.height > 8192)
+	if (too_large(pixmap->drawable.width, pixmap->drawable.height))
 		return sna_render_picture_extract(sna, picture, channel,
 						  x, y, w, h, dst_x, dst_y);
 
@@ -1899,8 +1906,7 @@ picture_is_cpu(PicturePtr picture)
 	    picture->repeat)
 		return FALSE;
 
-	if (picture->pDrawable->width > 8192 ||
-	    picture->pDrawable->height > 8192)
+	if (too_large(picture->pDrawable->width, picture->pDrawable->height))
 		return TRUE;
 
 	return is_cpu(picture->pDrawable);
@@ -1916,14 +1922,13 @@ try_blt(struct sna *sna,
 		return TRUE;
 	}
 
-	if (width > 8192 || height > 8192) {
+	if (too_large(width, height)) {
 		DBG(("%s: operation too large for 3D pipe (%d, %d)\n",
 		     __FUNCTION__, width, height));
 		return TRUE;
 	}
 
-	if (dst->pDrawable->width > 8192 ||
-	    dst->pDrawable->height > 8192)
+	if (too_large(dst->pDrawable->width, dst->pDrawable->height))
 		return TRUE;
 
 	/* is the source picture only in cpu memory e.g. a shm pixmap? */
@@ -2088,7 +2093,7 @@ gen5_render_composite(struct sna *sna,
 
 	sna_render_reduce_damage(tmp, dst_x, dst_y, width, height);
 
-	if (tmp->dst.width > 8192 || tmp->dst.height > 8192) {
+	if (too_large(tmp->dst.width, tmp->dst.height)) {
 		if (!sna_render_composite_redirect(sna, tmp,
 						   dst_x, dst_y, width, height))
 			return FALSE;
@@ -2455,7 +2460,7 @@ gen5_render_composite_spans(struct sna *sna,
 		return FALSE;
 	sna_render_reduce_damage(&tmp->base, dst_x, dst_y, width, height);
 
-	if (tmp->base.dst.width > 8192 || tmp->base.dst.height > 8192) {
+	if (too_large(tmp->base.dst.width, tmp->base.dst.height)) {
 		if (!sna_render_composite_redirect(sna, &tmp->base,
 						   dst_x, dst_y, width, height))
 			return FALSE;
@@ -2575,8 +2580,8 @@ gen5_render_copy_boxes(struct sna *sna, uint8_t alu,
 		return TRUE;
 
 	if (!(alu == GXcopy || alu == GXclear) || src_bo == dst_bo ||
-	    src->drawable.width > 8192 || src->drawable.height > 8192 ||
-	    dst->drawable.width > 8192 || dst->drawable.height > 8192) {
+	    too_large(src->drawable.width, src->drawable.height) ||
+	    too_large(dst->drawable.width, dst->drawable.height)) {
 		if (!sna_blt_compare_depth(&src->drawable, &dst->drawable))
 			return FALSE;
 
@@ -2724,8 +2729,8 @@ gen5_render_copy(struct sna *sna, uint8_t alu,
 		return TRUE;
 
 	if (!(alu == GXcopy || alu == GXclear) || src_bo == dst_bo ||
-	    src->drawable.width > 8192 || src->drawable.height > 8192 ||
-	    dst->drawable.width > 8192 || dst->drawable.height > 8192) {
+	    too_large(src->drawable.width, src->drawable.height) ||
+	    too_large(dst->drawable.width, dst->drawable.height)) {
 		if (!sna_blt_compare_depth(&src->drawable, &dst->drawable))
 			return FALSE;
 
@@ -2840,8 +2845,7 @@ gen5_render_fill_boxes(struct sna *sna,
 	}
 
 	if (prefer_blt_fill(sna) ||
-	    dst->drawable.width > 8192 ||
-	    dst->drawable.height > 8192 ||
+	    too_large(dst->drawable.width, dst->drawable.height) ||
 	    !gen5_check_dst_format(format)) {
 		uint8_t alu = -1;
 
@@ -2868,8 +2872,7 @@ gen5_render_fill_boxes(struct sna *sna,
 				       pixel, box, n))
 			return TRUE;
 
-		if (dst->drawable.width > 8192 ||
-		    dst->drawable.height > 8192 ||
+		if (too_large(dst->drawable.width, dst->drawable.height) ||
 		    !gen5_check_dst_format(format))
 			return FALSE;
 	}
@@ -3053,7 +3056,7 @@ gen5_render_fill(struct sna *sna, uint8_t alu,
 		return TRUE;
 
 	if (!(alu == GXcopy || alu == GXclear) ||
-	    dst->drawable.width > 8192 || dst->drawable.height > 8192)
+	    too_large(dst->drawable.width, dst->drawable.height))
 		return sna_blt_fill(sna, alu,
 				    dst_bo, dst->drawable.bitsPerPixel,
 				    color,
@@ -3143,7 +3146,7 @@ gen5_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
 
 	/* Must use the BLT if we can't RENDER... */
 	if (!(alu == GXcopy || alu == GXclear) ||
-	    dst->drawable.width > 8192 || dst->drawable.height > 8192)
+	    too_large(dst->drawable.width, dst->drawable.height))
 		return gen5_render_fill_one_try_blt(sna, dst, bo, color,
 						    x1, y1, x2, y2, alu);
 
@@ -3511,6 +3514,6 @@ Bool gen5_render_init(struct sna *sna)
 	sna->render.reset = gen5_render_reset;
 	sna->render.fini = gen5_render_fini;
 
-	sna->render.max_3d_size = 8192;
+	sna->render.max_3d_size = MAX_3D_SIZE;
 	return TRUE;
 }
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 5a83fd0..8808300 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -2647,7 +2647,7 @@ gen6_render_composite_spans(struct sna *sna,
 		return FALSE;
 	sna_render_reduce_damage(&tmp->base, dst_x, dst_y, width, height);
 
-	if (tmp->base.dst.width > 8192 || tmp->base.dst.height > 8192) {
+	if (too_large(tmp->base.dst.width, tmp->base.dst.height)) {
 		if (!sna_render_composite_redirect(sna, &tmp->base,
 						   dst_x, dst_y, width, height))
 			return FALSE;
@@ -3371,7 +3371,7 @@ gen6_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
 
 	/* Must use the BLT if we can't RENDER... */
 	if (!(alu == GXcopy || alu == GXclear) ||
-	    dst->drawable.width > 8192 || dst->drawable.height > 8192)
+	    too_large(dst->drawable.width, dst->drawable.height))
 		return gen6_render_fill_one_try_blt(sna, dst, bo, color,
 						    x1, y1, x2, y2, alu);
 
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index aeef0ae..0e18bad 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -2760,7 +2760,7 @@ gen7_render_composite_spans(struct sna *sna,
 		return FALSE;
 	sna_render_reduce_damage(&tmp->base, dst_x, dst_y, width, height);
 
-	if (tmp->base.dst.width > 8192 || tmp->base.dst.height > 8192) {
+	if (too_large(tmp->base.dst.width, tmp->base.dst.height)) {
 		if (!sna_render_composite_redirect(sna, &tmp->base,
 						   dst_x, dst_y, width, height))
 			return FALSE;
@@ -3490,7 +3490,7 @@ gen7_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
 
 	/* Must use the BLT if we can't RENDER... */
 	if (!(alu == GXcopy || alu == GXclear) ||
-	    dst->drawable.width > 8192 || dst->drawable.height > 8192)
+	    too_large(dst->drawable.width, dst->drawable.height))
 		return gen7_render_fill_one_try_blt(sna, dst, bo, color,
 						    x1, y1, x2, y2, alu);
 


More information about the xorg-commit mailing list