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

Chris Wilson ickle at kemper.freedesktop.org
Mon Jul 9 02:18:50 PDT 2012


 src/sna/fb/Makefile.am |    1 
 src/sna/fb/fb.h        |    2 +
 src/sna/fb/fbclip.c    |   38 +++----------------
 src/sna/fb/fbclip.h    |   16 +++++++-
 src/sna/fb/fbpict.h    |    2 +
 src/sna/fb/sfb.h       |   40 ++++++++++++++++++++
 src/sna/sna_accel.c    |   94 +++++++++++++++++++++++++++----------------------
 7 files changed, 117 insertions(+), 76 deletions(-)

New commits:
commit 21798a88676e91049917fafd3196dd4374b94226
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jul 9 09:23:20 2012 +0100

    sna: Promote large operations to use the whole 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 fd1abc9..973ac32 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1050,9 +1050,6 @@ static inline bool pixmap_inplace(struct sna *sna,
 }
 
 static bool
-sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned flags);
-
-static bool
 sna_pixmap_create_mappable_gpu(PixmapPtr pixmap)
 {
 	struct sna *sna = to_sna_from_pixmap(pixmap);
@@ -2067,6 +2064,25 @@ drawable_gc_flags(DrawablePtr draw, GCPtr gc, bool partial)
 	return (partial ? MOVE_READ : 0) | MOVE_WRITE | MOVE_INPLACE_HINT;
 }
 
+static inline bool
+box_inplace(PixmapPtr pixmap, const BoxRec *box)
+{
+	struct sna *sna = to_sna_from_pixmap(pixmap);
+	return ((int)(box->x2 - box->x1) * (int)(box->y2 - box->y1) * pixmap->drawable.bitsPerPixel >> 12) >= sna->kgem.half_cpu_cache_pages;
+}
+
+static inline struct sna_pixmap *
+sna_pixmap_mark_active(struct sna *sna, struct sna_pixmap *priv)
+{
+	assert(priv->gpu_bo);
+	if (!priv->pinned && priv->gpu_bo->proxy == NULL &&
+	    (priv->create & KGEM_CAN_CREATE_LARGE) == 0)
+		list_move(&priv->inactive, &sna->active_pixmaps);
+	priv->clear = false;
+	priv->cpu = false;
+	return priv;
+}
+
 static bool
 sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int flags)
 {
@@ -2088,6 +2104,12 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 		goto done;
 	}
 
+	if ((flags & MOVE_READ) == 0)
+		sna_damage_subtract_box(&priv->cpu_damage, box);
+
+	sna_damage_reduce(&priv->cpu_damage);
+	assert_pixmap_damage(pixmap);
+
 	if (priv->gpu_bo == NULL) {
 		unsigned create, tiling;
 
@@ -2115,16 +2137,12 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 			sna_damage_all(&priv->gpu_damage,
 				       pixmap->drawable.width,
 				       pixmap->drawable.height);
+			list_del(&priv->list);
 			goto done;
 		}
 	}
 	assert(priv->gpu_bo->proxy == NULL);
 
-	if ((flags & MOVE_READ) == 0)
-		sna_damage_subtract_box(&priv->cpu_damage, box);
-
-	sna_damage_reduce(&priv->cpu_damage);
-	assert_pixmap_damage(pixmap);
 	if (priv->cpu_damage == NULL) {
 		list_del(&priv->list);
 		goto done;
@@ -2243,18 +2261,19 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 	}
 
 done:
-	if (!priv->pinned && (priv->create & KGEM_CAN_CREATE_LARGE) == 0)
-		list_move(&priv->inactive, &sna->active_pixmaps);
-	priv->clear = false;
-	assert_pixmap_damage(pixmap);
-	return true;
-}
+	if (priv->cpu_damage == NULL &&
+	    flags & MOVE_WRITE &&
+	    box_inplace(pixmap, box)) {
+		DBG(("%s: large operation on undamaged, promoting to full GPU\n",
+		     __FUNCTION__));
+		sna_damage_all(&priv->gpu_damage,
+			       pixmap->drawable.width,
+			       pixmap->drawable.height);
+		priv->undamaged = false;
+	}
 
-static inline bool
-box_inplace(PixmapPtr pixmap, const BoxRec *box)
-{
-	struct sna *sna = to_sna_from_pixmap(pixmap);
-	return ((int)(box->x2 - box->x1) * (int)(box->y2 - box->y1) * pixmap->drawable.bitsPerPixel >> 12) >= sna->kgem.half_cpu_cache_pages;
+	assert(!priv->gpu_bo->proxy || (flags & MOVE_WRITE) == 0);
+	return sna_pixmap_mark_active(sna, priv) != NULL;
 }
 
 #define PREFER_GPU	0x1
@@ -2550,18 +2569,6 @@ sna_pixmap_create_upload(ScreenPtr screen,
 	return pixmap;
 }
 
-static inline struct sna_pixmap *
-sna_pixmap_mark_active(struct sna *sna, struct sna_pixmap *priv)
-{
-	assert(priv->gpu_bo);
-	if (!priv->pinned && priv->gpu_bo->proxy == NULL &&
-	    (priv->create & KGEM_CAN_CREATE_LARGE) == 0)
-		list_move(&priv->inactive, &sna->active_pixmaps);
-	priv->clear = false;
-	priv->cpu = false;
-	return priv;
-}
-
 struct sna_pixmap *
 sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 {
@@ -2638,8 +2645,6 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 			sna_damage_all(&priv->gpu_damage,
 				       pixmap->drawable.width,
 				       pixmap->drawable.height);
-			list_del(&priv->list);
-			priv->undamaged = false;
 			DBG(("%s: marking as all-damaged for GPU\n",
 			     __FUNCTION__));
 			goto active;
commit 1b6ad7a6ae6820c8f66d1c80613885ee84e7d316
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jul 9 08:54:11 2012 +0100

    sna: Only consider large clears as candidates for GPU migration
    
    If we only operating on a small region of the pixmap and have require
    damage migration in the past, we are likely to require migration again
    at some point. So keep track of small damage areas.
    
    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 ac98d35..fd1abc9 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2254,7 +2254,7 @@ static inline bool
 box_inplace(PixmapPtr pixmap, const BoxRec *box)
 {
 	struct sna *sna = to_sna_from_pixmap(pixmap);
-	return ((box->x2 - box->x1) * (box->y2 - box->y1) * pixmap->drawable.bitsPerPixel >> 15) >= sna->kgem.half_cpu_cache_pages;
+	return ((int)(box->x2 - box->x1) * (int)(box->y2 - box->y1) * pixmap->drawable.bitsPerPixel >> 12) >= sna->kgem.half_cpu_cache_pages;
 }
 
 #define PREFER_GPU	0x1
@@ -10381,22 +10381,27 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect)
 	 */
 	hint = PREFER_GPU;
 	if (n == 1 && gc->fillStyle != FillStippled && alu_overwrites(gc->alu)) {
+		region.data = NULL;
 		if (priv->cpu_damage &&
 		    region_is_singular(gc->pCompositeClip)) {
-			region.data = NULL;
 			if (region_subsumes_damage(&region, priv->cpu_damage)) {
+				DBG(("%s: discarding existing CPU damage\n", __FUNCTION__));
 				sna_damage_destroy(&priv->cpu_damage);
 				list_del(&priv->list);
 			}
 		}
-		if (priv->cpu_damage == NULL) {
-			sna_damage_all(&priv->gpu_damage,
-				       pixmap->drawable.width,
-				       pixmap->drawable.height);
-			priv->undamaged = false;
-			priv->cpu = false;
+		if (region_subsumes_drawable(&region, &pixmap->drawable) ||
+		    box_inplace(pixmap, &region.extents)) {
+			DBG(("%s: promoting to full GPU\n", __FUNCTION__));
+			if (priv->cpu_damage == NULL) {
+				sna_damage_all(&priv->gpu_damage,
+					       pixmap->drawable.width,
+					       pixmap->drawable.height);
+				priv->undamaged = false;
+				priv->cpu = false;
+			}
+			hint |= IGNORE_CPU;
 		}
-		hint |= IGNORE_CPU;
 	}
 
 	bo = sna_drawable_use_bo(draw, hint, &region.extents, &damage);
commit d8a75538ea1d2a79d6282b0e2dfd73cfdea1a480
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jul 9 08:38:39 2012 +0100

    sna: PadPixmap only writes to the out-of-bounds bits
    
    So we only need to delcare it as reading the source pixmap and not mark
    it as damaged.
    
    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 cb99e6a..ac98d35 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2735,7 +2735,7 @@ static bool must_check sna_validate_pixmap(DrawablePtr draw, PixmapPtr pixmap)
 	    FbEvenTile(pixmap->drawable.width *
 		       pixmap->drawable.bitsPerPixel)) {
 		DBG(("%s: flushing pixmap\n", __FUNCTION__));
-		if (!sna_pixmap_move_to_cpu(pixmap, MOVE_READ | MOVE_WRITE))
+		if (!sna_pixmap_move_to_cpu(pixmap, MOVE_READ))
 			return false;
 
 		fbPadPixmap(pixmap);
commit eafb454edf188e7dada1ddf886d1e46f0151968d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jul 9 08:38:08 2012 +0100

    sna: Rename conflicting symbols with uxa
    
    Reported-by: Christoph Reiter <reiter.christoph at gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51887
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/fb/Makefile.am b/src/sna/fb/Makefile.am
index 16f9b28..72d9bbf 100644
--- a/src/sna/fb/Makefile.am
+++ b/src/sna/fb/Makefile.am
@@ -5,6 +5,7 @@ libfb_la_LIBADD = $(PIXMAN_LIBS)
 
 libfb_la_SOURCES = 	\
 	fb.h		\
+	sfb.h		\
 	fbarc.c		\
 	fbarcbits.h	\
 	fbbitmap.c	\
diff --git a/src/sna/fb/fb.h b/src/sna/fb/fb.h
index 7847951..3339236 100644
--- a/src/sna/fb/fb.h
+++ b/src/sna/fb/fb.h
@@ -43,6 +43,8 @@
 #define DBG(x)
 #endif
 
+#include "sfb.h"
+
 #define WRITE(ptr, val) (*(ptr) = (val))
 #define READ(ptr) (*(ptr))
 
diff --git a/src/sna/fb/fbpict.h b/src/sna/fb/fbpict.h
index 6bcee34..1ce09df 100644
--- a/src/sna/fb/fbpict.h
+++ b/src/sna/fb/fbpict.h
@@ -24,6 +24,8 @@
 #ifndef FBPICT_H
 #define FBPICT_H
 
+#include "sfb.h"
+
 extern void
 fbComposite(CARD8 op,
             PicturePtr pSrc,
diff --git a/src/sna/fb/sfb.h b/src/sna/fb/sfb.h
new file mode 100644
index 0000000..a4d9d17
--- /dev/null
+++ b/src/sna/fb/sfb.h
@@ -0,0 +1,40 @@
+/* And rename to avoid symbol clashes with UXA */
+#define fbPolyArc sfbPolyArc
+#define fbBlt sfbBlt
+#define fbBltOne sfbBltOne
+#define fbBltPlane sfbBltPlane
+#define fbCopyNtoN sfbCopyNtoN
+#define fbCopy1toN sfbCopy1toN
+#define fbCopyNto1 sfbCopyNto1
+#define fbCopyArea sfbCopyArea
+#define fbCopyPlane sfbCopyPlane
+#define fbFill sfbFill
+#define fbSolidBoxClipped sfbSolidBoxClipped
+#define fbPolyFillRect sfbPolyFillRect
+#define fbFillSpans sfbFillSpans
+#define fbPadPixmap sfbPadPixmap
+#define fbValidateGC sfbValidateGC
+#define fbGetSpans sfbGetSpans
+#define fbPolyGlyphBlt sfbPolyGlyphBlt
+#define fbImageGlyphBlt sfbImageGlyphBlt
+#define fbPutImage sfbPutImage
+#define fbPuXYtImage sfbPutXYImage
+#define fbGetImage sfbGetImage
+#define fbPolyLine sfbPolyLine
+#define fbFixCoordModePrevious sfbFixCoordModePrevious
+#define fbPolySegment sfbPolySegment
+#define fbBitmapToRegion sfbBitmapToRegion
+#define fbPolyPoint sfbPolyPoint
+#define fbPushImage sfbPushImage
+#define fbPushPixels sfbPushPixels
+#define fbSetSpans sfbSetSpans
+#define fbSegment sfbSegment
+#define fbSegment1 sfbSegment1
+#define fbTransparentSpan sfbTransparentSpan
+#define fbStipple sfbStipple
+#define fbTile sfbTile
+#define fbReplicatePixel sfbReplicatePixel
+
+#define fbComposite sfbComposite
+#define image_from_pict simage_from_pict
+#define free_pixmap_pict sfree_pixmap_pict
commit 0af29175a087cc2e509962f8828790c8f7232611
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jul 9 01:24:23 2012 +0100

    sna: Just use a linear scan to find the terminating clip box
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/fb/fbclip.c b/src/sna/fb/fbclip.c
index 5a8eefa..8d9c4db 100644
--- a/src/sna/fb/fbclip.c
+++ b/src/sna/fb/fbclip.c
@@ -29,7 +29,7 @@
 #include "fbclip.h"
 
 static const BoxRec *
-find_c0(const BoxRec *begin, const BoxRec *end, int16_t y)
+find_clip_row_for_y(const BoxRec *begin, const BoxRec *end, int16_t y)
 {
 	const BoxRec *mid;
 
@@ -45,31 +45,9 @@ find_c0(const BoxRec *begin, const BoxRec *end, int16_t y)
 
 	mid = begin + (end - begin) / 2;
 	if (mid->y2 > y)
-		return find_c0(begin, mid, y);
+		return find_clip_row_for_y(begin, mid, y);
 	else
-		return find_c0(mid, end, y);
-}
-
-static const BoxRec *
-find_c1(const BoxRec *begin, const BoxRec *end, int16_t y)
-{
-	const BoxRec *mid;
-
-	if (end == begin)
-		return end;
-
-	if (end - begin == 1) {
-		if (begin->y1 > y)
-			return begin;
-		else
-			return end;
-	}
-
-	mid = begin + (end - begin) / 2;
-	if (mid->y1 > y)
-		return find_c1(begin, mid, y);
-	else
-		return find_c1(mid, end, y);
+		return find_clip_row_for_y(mid, end, y);
 }
 
 const BoxRec *
@@ -99,14 +77,10 @@ fbClipBoxes(const RegionRec *region, const BoxRec *box, const BoxRec **end)
 	c1 = c0 + region->data->numRects;
 
 	if (c0->y2 <= box->y1)
-		c0 = find_c0(c0, c1, box->y1);
-	if (c1[-1].y1 >= box->y2)
-		c1 = find_c1(c0, c1, box->y2);
+		c0 = find_clip_row_for_y(c0, c1, box->y1);
 
-	DBG(("%s: c0=(%d, %d),(%d, %d); c1=(%d, %d),(%d, %d)\n",
-	     __FUNCTION__,
-	     c0->x1, c0->y1, c0->x2, c0->y2,
-	     c1[-1].x1, c1[-1].y1, c1[-1].x2, c1[-1].y2));
+	DBG(("%s: c0=(%d, %d),(%d, %d)\n",
+	     __FUNCTION__, c0->x1, c0->y1, c0->x2, c0->y2));
 
 	*end = c1;
 	return c0;
diff --git a/src/sna/fb/fbclip.h b/src/sna/fb/fbclip.h
index 0436c40..feb2d2c 100644
--- a/src/sna/fb/fbclip.h
+++ b/src/sna/fb/fbclip.h
@@ -55,8 +55,14 @@ fbDrawableRun(DrawablePtr d, GCPtr gc, const BoxRec *box,
 	for (c = fbClipBoxes(gc->pCompositeClip, box, &end); c != end; c++) {
 		BoxRec b;
 
-		if (box->x2 <= c->x1 || box->x1 >= c->x2)
+		if (box->x1 >= c->x2)
 			continue;
+		if (box->x2 <= c->x1) {
+			if (box->y2 <= c->y2)
+				break;
+			else
+				continue;
+		}
 
 		b = *box;
 		if (box_intersect(&b, c))
@@ -71,8 +77,14 @@ fbDrawableRunUnclipped(DrawablePtr d, GCPtr gc, const BoxRec *box,
 {
 	const BoxRec *c, *end;
 	for (c = fbClipBoxes(gc->pCompositeClip, box, &end); c != end; c++) {
-		if (box->x2 <= c->x1 || box->x1 >= c->x2)
+		if (box->x1 >= c->x2)
 			continue;
+		if (box->x2 <= c->x1) {
+			if (box->y2 <= c->y2)
+				break;
+			else
+				continue;
+		}
 		func(d, gc, c, data);
 	}
 }


More information about the xorg-commit mailing list