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

Chris Wilson ickle at kemper.freedesktop.org
Tue Mar 13 15:17:24 PDT 2012


 src/sna/kgem.c      |   49 ++++++++++++++++++++++++++++++++-----------------
 src/sna/sna_accel.c |   11 ++++++++++-
 2 files changed, 42 insertions(+), 18 deletions(-)

New commits:
commit d23ee0380b61e0dfd3ed56b8b4a15fd0b7956491
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Mar 13 22:00:25 2012 +0000

    sna: Reuse the cached upload as a source GPU bo
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=42426
    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 b0b55a4..ce13982 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2236,6 +2236,11 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 	if (priv->cpu_damage == NULL)
 		goto done;
 
+	if (priv->gpu_bo->proxy) {
+		assert((flags & MOVE_WRITE) ==0);
+		goto done;
+	}
+
 	if (priv->mapped) {
 		assert(priv->stride);
 		pixmap->devPrivate.ptr = priv->ptr;
commit 0acec1685328b1dd9dffa804a27a122fc6e4225a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Mar 13 21:29:57 2012 +0000

    sna: Defer the release of the upload buffer cache till retirement
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index cee4513..72751f3 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1238,7 +1238,26 @@ static void kgem_retire_partials(struct kgem *kgem)
 		assert(next->base.list.prev == &bo->base.list);
 		assert(bo->base.io);
 
-		if (bo->base.refcnt != 1 || bo->base.rq)
+		if (bo->base.rq)
+			continue;
+
+		DBG(("%s: releasing upload cache for handle=%d? %d\n",
+		     __FUNCTION__, bo->base.handle, !list_is_empty(&bo->base.vma)));
+		while (!list_is_empty(&bo->base.vma)) {
+			struct kgem_bo *cached;
+
+			cached = list_first_entry(&bo->base.vma, struct kgem_bo, vma);
+			assert(cached->proxy == &bo->base);
+			list_del(&cached->vma);
+
+			assert(*(struct kgem_bo **)cached->map == cached);
+			*(struct kgem_bo **)cached->map = NULL;
+			cached->map = NULL;
+
+			kgem_bo_destroy(kgem, cached);
+		}
+
+		if (bo->base.refcnt != 1)
 			continue;
 
 		DBG(("%s: handle=%d, used %d/%d\n", __FUNCTION__,
@@ -1256,6 +1275,8 @@ static void kgem_retire_partials(struct kgem *kgem)
 		bo->base.needs_flush = false;
 		bo->used = 0;
 
+		DBG(("%s: transferring partial handle=%d to inactive\n",
+		     __FUNCTION__, bo->base.handle));
 		list_move_tail(&bo->base.list, &kgem->inactive_partials);
 		bubble_sort_partial(&kgem->inactive_partials, bo);
 	}
@@ -1381,9 +1402,7 @@ static void kgem_commit(struct kgem *kgem)
 {
 	struct kgem_request *rq = kgem->next_request;
 	struct kgem_bo *bo, *next;
-	struct list release;
 
-	list_init(&release);
 	list_for_each_entry_safe(bo, next, &rq->buffers, request) {
 		assert(next->request.prev == &bo->request);
 
@@ -1392,7 +1411,7 @@ static void kgem_commit(struct kgem *kgem)
 		     bo->dirty, bo->needs_flush, (unsigned)bo->exec->offset));
 
 		assert(!bo->purged);
-		assert(bo->proxy || bo->rq == rq);
+		assert(bo->rq == rq || (bo->proxy->rq == rq));
 
 		bo->presumed_offset = bo->exec->offset;
 		bo->exec = NULL;
@@ -1411,20 +1430,8 @@ static void kgem_commit(struct kgem *kgem)
 			list_del(&bo->request);
 			bo->rq = NULL;
 			bo->exec = &_kgem_dummy_exec;
-			if (bo->map)
-				list_add_tail(&bo->request, &release);
 		}
 	}
-	while (!list_is_empty(&release)) {
-		bo = list_first_entry(&release, struct kgem_bo, request);
-		DBG(("%s: releasing upload cache, handle=%d\n",
-		     __FUNCTION__, bo->handle));
-		list_del(&bo->request);
-		assert(*(struct kgem_bo **)bo->map == bo);
-		*(struct kgem_bo **)bo->map = NULL;
-		bo->map = NULL;
-		kgem_bo_destroy(kgem, bo);
-	}
 
 	if (rq == &_kgem_static_request) {
 		struct drm_i915_gem_set_domain set_domain;
@@ -2869,11 +2876,12 @@ void _kgem_bo_destroy(struct kgem *kgem, struct kgem_bo *bo)
 	     __FUNCTION__, bo->handle, bo->proxy != NULL));
 
 	if (bo->proxy) {
+		_list_del(&bo->vma);
+		_list_del(&bo->request);
 		if (bo->io && (bo->exec == NULL || bo->proxy->rq == NULL))
 			_kgem_bo_delete_partial(kgem, bo);
 		kgem_bo_unref(kgem, bo->proxy);
 		kgem_bo_binding_free(kgem, bo);
-		_list_del(&bo->request);
 		free(bo);
 		return;
 	}
@@ -3468,6 +3476,11 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
 			}
 		}
 
+		if (bo->used && bo->base.rq == NULL && bo->base.refcnt == 1) {
+			bo->used = 0;
+			bubble_sort_partial(&kgem->active_partials, bo);
+		}
+
 		if (bo->used + size <= bytes(&bo->base)) {
 			DBG(("%s: reusing partial buffer? used=%d + size=%d, total=%d\n",
 			     __FUNCTION__, bo->used, size, bytes(&bo->base)));
@@ -3895,6 +3908,8 @@ void kgem_proxy_bo_attach(struct kgem_bo *bo,
 {
 	DBG(("%s: handle=%d\n", __FUNCTION__, bo->handle));
 	assert(bo->map == NULL);
+	assert(bo->proxy);
+	list_add(&bo->vma, &bo->proxy->vma);
 	bo->map = ptr;
 	*ptr = kgem_bo_reference(bo);
 }
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index c9016a1..b0b55a4 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -11822,6 +11822,7 @@ static void sna_accel_inactive(struct sna *sna)
 					inactive);
 		assert((priv->create & KGEM_CAN_CREATE_LARGE) == 0);
 		assert(priv->gpu_bo);
+		assert(!priv->gpu_bo->proxy);
 
 		/* XXX Rather than discarding the GPU buffer here, we
 		 * could mark it purgeable and allow the shrinker to
commit 06b28d541bdf2607edc2eb476919b28e747885d8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Mar 13 20:01:53 2012 +0000

    sna: Destroy the cached upload buffer if before copying into it
    
    As we discard the buffer after the next batch, we will lose the contents
    of the pixmap. Instead discard the cache, and treat it as a normal
    shadow again.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=42426
    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 d5420a3..c9016a1 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3402,7 +3402,10 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 		dst_priv->clear = false;
 	}
 
-	assert(dst_priv->gpu_bo == NULL || dst_priv->gpu_bo->proxy == NULL);
+	if (dst_priv->gpu_bo && dst_priv->gpu_bo->proxy) {
+		kgem_bo_destroy(&sna->kgem, dst_priv->gpu_bo);
+		dst_priv->gpu_bo = NULL;
+	}
 
 	/* Try to maintain the data on the GPU */
 	if (dst_priv->gpu_bo == NULL &&


More information about the xorg-commit mailing list