xf86-video-intel: 5 commits - src/sna/sna_accel.c src/sna/sna_composite.c src/sna/sna_display.c src/sna/sna.h

Chris Wilson ickle at kemper.freedesktop.org
Mon Mar 31 04:32:18 PDT 2014


 src/sna/sna.h           |    8 +++++
 src/sna/sna_accel.c     |   75 ++++++++++++++++++++++++++++++------------------
 src/sna/sna_composite.c |    4 +-
 src/sna/sna_display.c   |   23 ++++++++------
 4 files changed, 72 insertions(+), 38 deletions(-)

New commits:
commit c4c8a1b180a9d4c1126ee4fe3120128aa560306c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Mar 31 11:23:45 2014 +0100

    sna: Discard damage tracking for operations to the whole pixmap
    
    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 25b2ec3..6a58598 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3566,6 +3566,18 @@ create_gpu_bo:
 	if (priv->gpu_damage) {
 		assert(priv->gpu_bo);
 		if (!priv->cpu_damage || flags & IGNORE_CPU) {
+			if (box_covers_pixmap(pixmap, &region.extents)) {
+				unsigned int move;
+
+				if (flags & IGNORE_CPU)
+					move = MOVE_WRITE;
+				else
+					move = MOVE_WRITE | MOVE_READ;
+
+				if (sna_pixmap_move_to_gpu(pixmap, move))
+					goto use_gpu_bo;
+			}
+
 			if (sna_damage_contains_box__no_reduce(priv->gpu_damage,
 							       &region.extents)) {
 				DBG(("%s: region wholly contained within GPU damage\n",
commit 8f796d4586507a0a6e9ca3608f43448983a3b965
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Mar 31 11:14:46 2014 +0100

    sna: Promote to the GPU operations that cover the whole pixmap
    
    If the pixmap is already partially on the GPU, and the next operation
    touches the entire pixmap, promote that operation back to the whole GPU.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index a2b5e83..0017582 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -632,6 +632,14 @@ static inline bool box_empty(const BoxRec *box)
 }
 
 static inline bool
+box_covers_pixmap(PixmapPtr pixmap, const BoxRec *box)
+{
+	int w = box->x2 - box->x1;
+	int h = box->y2 - box->y1;
+	return pixmap->drawable.width <= w && pixmap->drawable.height <= h;
+}
+
+static inline bool
 box_inplace(PixmapPtr pixmap, const BoxRec *box)
 {
 	struct sna *sna = to_sna_from_pixmap(pixmap);
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 3640b57..25b2ec3 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3348,7 +3348,8 @@ done:
 		priv->clear = false;
 		if (!DAMAGE_IS_ALL(priv->gpu_damage) &&
 		    priv->cpu_damage == NULL &&
-		    box_inplace(pixmap, &r.extents)) {
+		    (box_covers_pixmap(pixmap, &r.extents) ||
+		     box_inplace(pixmap, &r.extents))) {
 			DBG(("%s: large operation on undamaged, promoting to full GPU\n",
 			     __FUNCTION__));
 			assert(priv->gpu_bo);
@@ -3442,7 +3443,7 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box,
 		flags &= ~PREFER_GPU;
 
 	if ((flags & (PREFER_GPU | IGNORE_CPU)) == IGNORE_CPU) {
-		if (priv->gpu_bo && box_inplace(pixmap, box))
+		if (priv->gpu_bo && (box_covers_pixmap(pixmap, box) || box_inplace(pixmap, box)))
 			flags |= PREFER_GPU;
 	}
 
@@ -14145,7 +14146,9 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect)
 		}
 		if (priv->cpu_damage == NULL) {
 			if (priv->gpu_bo &&
-			    (hint & REPLACES || box_inplace(pixmap, &region.extents))) {
+			    (hint & REPLACES ||
+			     box_covers_pixmap(pixmap, &region.extents) ||
+			     box_inplace(pixmap, &region.extents))) {
 				DBG(("%s: promoting to full GPU\n",
 				     __FUNCTION__));
 				assert(priv->gpu_bo->proxy == NULL);
diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c
index d34b517..5bcea88 100644
--- a/src/sna/sna_composite.c
+++ b/src/sna/sna_composite.c
@@ -955,7 +955,9 @@ sna_composite_rectangles(CARD8		 op,
 		}
 		if (region_subsumes_drawable(&region, &pixmap->drawable))
 			hint |= REPLACES;
-		if (hint & REPLACES || box_inplace(pixmap, &region.extents)) {
+		if (hint & REPLACES ||
+		    box_covers_pixmap(pixmap, &region.extents) ||
+		    box_inplace(pixmap, &region.extents)) {
 			DBG(("%s: promoting to full GPU\n", __FUNCTION__));
 			if (priv->gpu_bo && priv->cpu_damage == NULL) {
 				assert(priv->gpu_bo->proxy == NULL);
commit 27c086a89d838fe0060e5ddd0fb2f37434078e4d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Mar 31 10:01:38 2014 +0100

    sna: Regularly check that damage does exceed the pixmap
    
    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 4d87ed4..3640b57 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -241,6 +241,33 @@ typedef struct box32 {
 #define PM_IS_SOLID(_draw, _pm) \
 	(((_pm) & FbFullMask((_draw)->depth)) == FbFullMask((_draw)->depth))
 
+#ifndef NDEBUG
+static bool
+pixmap_contains_damage(PixmapPtr pixmap, struct sna_damage *damage)
+{
+	if (damage == NULL)
+		return true;
+
+	damage = DAMAGE_PTR(damage);
+	return (damage->extents.x2 <= pixmap->drawable.width &&
+		damage->extents.y2 <= pixmap->drawable.height &&
+		damage->extents.x1 >= 0 &&
+		damage->extents.y1 >= 0);
+}
+#endif
+
+#define __assert_pixmap_damage(p) do { \
+	struct sna_pixmap *priv__ = sna_pixmap(p); \
+	if (priv__) { \
+		assert(priv__->gpu_damage == NULL || priv__->gpu_bo); \
+		assert(priv__->gpu_bo == NULL || priv__->gpu_bo->refcnt); \
+		assert(priv__->cpu_bo == NULL || priv__->cpu_bo->refcnt); \
+		assert(!pixmap_contains_damage(p, priv__->gpu_damage)); \
+		assert(!pixmap_contains_damage(p, priv__->cpu_damage)); \
+		assert_pixmap_map(p, priv__); \
+	} \
+} while (0)
+
 #ifdef DEBUG_PIXMAP
 static void _assert_pixmap_contains_box(PixmapPtr pixmap, const BoxRec *box, const char *function)
 {
@@ -340,10 +367,7 @@ static void assert_pixmap_damage(PixmapPtr p)
 	if (priv == NULL)
 		return;
 
-	assert(priv->gpu_damage == NULL || priv->gpu_bo);
-	assert(priv->gpu_bo == NULL || priv->gpu_bo->refcnt);
-	assert(priv->cpu_bo == NULL || priv->cpu_bo->refcnt);
-	assert_pixmap_map(p, priv);
+	__assert_pixmap_damage(p);
 
 	if (priv->clear) {
 		assert(DAMAGE_IS_ALL(priv->gpu_damage));
@@ -392,12 +416,7 @@ static void assert_pixmap_damage(PixmapPtr p)
 #define assert_pixmap_contains_points(p, pt, n, x, y)
 #define assert_drawable_contains_box(d, b)
 #ifndef NDEBUG
-#define assert_pixmap_damage(p) do { \
-	struct sna_pixmap *priv__ = sna_pixmap(p); \
-	assert(priv__ == NULL || priv__->gpu_damage == NULL || priv__->gpu_bo); \
-	assert(priv__ == NULL || priv__->gpu_bo == NULL || priv__->gpu_bo->refcnt); \
-	assert(priv__ == NULL || priv__->cpu_bo == NULL || priv__->cpu_bo->refcnt); \
-} while (0)
+#define assert_pixmap_damage(p) __assert_pixmap_damage(p)
 #else
 #define assert_pixmap_damage(p)
 #endif
@@ -2282,21 +2301,6 @@ region_overlaps_damage(const RegionRec *region,
 		re->y1 + dy < de->y2 && re->y2 + dy > de->y1);
 }
 
-#ifndef NDEBUG
-static bool
-pixmap_contains_damage(PixmapPtr pixmap, struct sna_damage *damage)
-{
-	if (damage == NULL)
-		return true;
-
-	damage = DAMAGE_PTR(damage);
-	return (damage->extents.x2 <= pixmap->drawable.width &&
-		damage->extents.y2 <= pixmap->drawable.height &&
-		damage->extents.x1 >= 0 &&
-		damage->extents.y1 >= 0);
-}
-#endif
-
 static inline bool region_inplace(struct sna *sna,
 				  PixmapPtr pixmap,
 				  RegionPtr region,
commit a8a5a5a58786445d393c3d6388904c0975c364a6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Mar 31 09:36:05 2014 +0100

    sna: Search cursor cache first
    
    We can reuse the current cursor size rather than determine it every
    time.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index b7f423d..b186c98 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3119,21 +3119,26 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
 	       sna->cursor.ref->bits->height,
 	       sna->cursor.serial));
 
-	i = MAX(sna->cursor.ref->bits->width, sna->cursor.ref->bits->height);
-	for (size = 64; size < i; size <<= 1)
-		;
-	assert(size <= sna->cursor.max_size);
-
 	rotation = crtc->transform_in_use ? crtc->rotation : RR_Rotate_0;
 	for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) {
 		if (cursor->serial == sna->cursor.serial && cursor->rotation == rotation) {
-			__DBG(("%s: reusing handle=%d, serial=%d, rotation=%d\n",
-			       __FUNCTION__, cursor->handle, cursor->serial, cursor->rotation));
+			__DBG(("%s: reusing handle=%d, serial=%d, rotation=%d, size=%d\n",
+			       __FUNCTION__, cursor->handle, cursor->serial, cursor->rotation, cursor->size));
+#if HAS_DEBUG_FULL
+			i = MAX(sna->cursor.ref->bits->width, sna->cursor.ref->bits->height);
+			for (size = 64; size < i; size <<= 1)
+				;
 			assert(cursor->size == size);
+#endif
 			return cursor;
 		}
 	}
 
+	i = MAX(sna->cursor.ref->bits->width, sna->cursor.ref->bits->height);
+	for (size = 64; size < i; size <<= 1)
+		;
+	assert(size <= sna->cursor.max_size);
+
 	for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) {
 		if (cursor->alloc >= 4*size*size && cursor->serial != sna->cursor.serial) {
 			__DBG(("%s: stealing handle=%d, serial=%d, rotation=%d, alloc=%d\n",
commit e892b789c4c6359e4fb2e11f552b3e43a466c49e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Mar 28 11:34:03 2014 +0000

    sna: Suppress a compiler warning
    
    sna_display.c: In function '__sna_get_cursor':
    sna_display.c:3153:6: warning: assignment from incompatible pointer type [enabled by default]
      src = sna->cursor.ref->bits->argb;
          ^
    sna_display.c:3209:10: warning: comparison of distinct pointer types lacks a cast [enabled by default]
      if (src != sna->cursor.ref->bits->argb)
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 8d271fd..b7f423d 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3150,7 +3150,7 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
 
 	width = sna->cursor.ref->bits->width;
 	height = sna->cursor.ref->bits->height;
-	src = sna->cursor.ref->bits->argb;
+	src = (uint32_t *)sna->cursor.ref->bits->argb;
 	if (src == NULL) {
 		const uint8_t *source = sna->cursor.ref->bits->source;
 		const uint8_t *mask = sna->cursor.ref->bits->mask;
@@ -3206,7 +3206,7 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
 			}
 	}
 
-	if (src != sna->cursor.ref->bits->argb)
+	if (src != (uint32_t *)sna->cursor.ref->bits->argb)
 		free(src);
 
 	cursor->size = size;


More information about the xorg-commit mailing list