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

Chris Wilson ickle at kemper.freedesktop.org
Mon Oct 6 02:26:04 PDT 2014


 src/sna/sna.h                      |    1 
 src/sna/sna_accel.c                |   38 +++++++++----
 src/sna/sna_trapezoids_imprecise.c |  108 +++++--------------------------------
 3 files changed, 45 insertions(+), 102 deletions(-)

New commits:
commit ec2b9ac81aed0d2dda2948171ca1c260184bf221
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 6 08:18:24 2014 +0100

    sna: Avoid the intermediate allocation for PRIME pixmaps
    
    If we attempt to share an unused Pixmap, we first create an ordinary GPU
    bo when migrating onto the GPU. Add a flag here to cause the migration
    to create a Pixmap suitable for PRIME instead.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 04ee35c..e035634 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -709,6 +709,7 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags);
 #define __MOVE_DRI 0x80
 #define __MOVE_SCANOUT 0x100
 #define __MOVE_TILED 0x200
+#define __MOVE_PRIME 0x400
 
 struct sna_pixmap *
 sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int flags);
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 02ff0c7..a6ba2a0 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1093,7 +1093,7 @@ sna_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave, void **fd_handle)
 	DBG(("%s: pixmap=%ld\n", __FUNCTION__, pixmap->drawable.serialNumber));
 
 	priv = sna_pixmap_move_to_gpu(pixmap,
-				      MOVE_READ | MOVE_WRITE | __MOVE_DRI | __MOVE_FORCE);
+				      MOVE_READ | MOVE_WRITE | __MOVE_DRI | __MOVE_PRIME | __MOVE_FORCE);
 	if (priv == NULL)
 		return FALSE;
 
@@ -1125,7 +1125,7 @@ sna_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave, void **fd_handle)
 				    pixmap->drawable.height,
 				    pixmap->drawable.bitsPerPixel,
 				    I915_TILING_NONE,
-				    CREATE_GTT_MAP | CREATE_PRIME);
+				    CREATE_GTT_MAP | CREATE_PRIME | CREATE_EXACT);
 		if (bo == NULL) {
 			DBG(("%s: allocation failed\n", __FUNCTION__));
 			return FALSE;
@@ -1244,7 +1244,7 @@ sna_create_pixmap_shared(struct sna *sna, ScreenPtr screen,
 					      width, height,
 					      pixmap->drawable.bitsPerPixel,
 					      I915_TILING_NONE,
-					      CREATE_GTT_MAP | CREATE_PRIME);
+					      CREATE_GTT_MAP | CREATE_PRIME | CREATE_EXACT);
 		if (priv->gpu_bo == NULL) {
 			free(priv);
 			FreePixmap(pixmap);
@@ -1921,6 +1921,7 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags)
 
 		if (flags & MOVE_READ) {
 			PixmapPtr pixmap = priv->pixmap;
+			unsigned create, tiling;
 			BoxRec box;
 
 			DBG(("%s: copying cow\n", __FUNCTION__));
@@ -1929,11 +1930,18 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags)
 			box.x2 = pixmap->drawable.width;
 			box.y2 = pixmap->drawable.height;
 
+			if (flags & __MOVE_PRIME) {
+				create|= CREATE_GTT_MAP | CREATE_PRIME | CREATE_EXACT;
+				tiling = I915_TILING_NONE;
+			} else {
+				create = 0;
+				tiling = sna_pixmap_default_tiling(sna, pixmap);
+			}
+
 			bo = kgem_create_2d(&sna->kgem,
 					    box.x2, box.y2,
 					    pixmap->drawable.bitsPerPixel,
-					    sna_pixmap_default_tiling(sna, pixmap),
-					    0);
+					    tiling, create);
 			if (bo == NULL) {
 				cow->refcnt++;
 				DBG(("%s: allocation failed\n", __FUNCTION__));
@@ -4073,6 +4081,10 @@ static bool can_convert_to_gpu(struct sna_pixmap *priv, unsigned flags)
 		if (priv->cpu_bo->pitch & 63)
 			return false;
 
+	if (flags & __MOVE_PRIME)
+		if (priv->cpu_bo->pitch & 255)
+			return false;
+
 	return true;
 }
 
@@ -4160,10 +4172,16 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 			assert(pixmap->drawable.height > 0);
 			assert(pixmap->drawable.bitsPerPixel >= 8);
 
-			is_linear = sna_pixmap_default_tiling(sna, pixmap) == I915_TILING_NONE;
-			if (is_linear && flags & __MOVE_TILED) {
-				DBG(("%s: not creating linear GPU bo\n", __FUNCTION__));
-				return NULL;
+			if (flags & __MOVE_PRIME) {
+				assert((flags & __MOVE_TILED) == 0);
+				is_linear = true;
+			} else {
+				is_linear = sna_pixmap_default_tiling(sna, pixmap) == I915_TILING_NONE;
+				if (is_linear && flags & __MOVE_TILED) {
+					DBG(("%s: not creating linear GPU bo\n",
+					     __FUNCTION__));
+					return NULL;
+				}
 			}
 
 			if (is_linear &&
@@ -4185,6 +4203,8 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 				unsigned create = 0;
 				if (flags & MOVE_INPLACE_HINT || (priv->cpu_damage && priv->cpu_bo == NULL))
 					create = CREATE_GTT_MAP | CREATE_INACTIVE;
+				if (flags & __MOVE_PRIME)
+					create |= CREATE_GTT_MAP | CREATE_PRIME | CREATE_EXACT;
 
 				sna_pixmap_alloc_gpu(sna, pixmap, priv, create);
 			}
commit 649b233f12bdf04c449a813c3a150ac3ccfcab72
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Oct 5 11:06:36 2014 +0100

    sna/trapezoids: Remove redundant coverage scaling
    
    Since we do not perform an analytical pass, we can count samples directly.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c
index b005c97..865a723 100644
--- a/src/sna/sna_trapezoids_imprecise.c
+++ b/src/sna/sna_trapezoids_imprecise.c
@@ -124,7 +124,7 @@ inline static void apply_damage_box(struct sna_composite_op *op, const BoxRec *b
     (i) = FAST_SAMPLES_INT(t);				\
 } while (0)
 
-#define FAST_SAMPLES_XY (2*FAST_SAMPLES_X*FAST_SAMPLES_Y) /* Unit area on the grid. */
+#define FAST_SAMPLES_XY (FAST_SAMPLES_X*FAST_SAMPLES_Y) /* Unit area on the grid. */
 #define AREA_TO_ALPHA(c)  ((c) / (float)FAST_SAMPLES_XY)
 
 struct quorem {
@@ -374,14 +374,14 @@ cell_list_add_subspan(struct cell_list *cells, int x1, int x2)
 
 	cell = cell_list_find(cells, ix1);
 	if (ix1 != ix2) {
-		cell->uncovered_area += 2*fx1;
+		cell->uncovered_area += fx1;
 		++cell->covered_height;
 
 		cell = cell_list_find(cells, ix2);
-		cell->uncovered_area -= 2*fx2;
+		cell->uncovered_area -= fx2;
 		--cell->covered_height;
 	} else
-		cell->uncovered_area += 2*(fx1-fx2);
+		cell->uncovered_area += (fx1-fx2);
 }
 
 inline static void
@@ -399,14 +399,14 @@ cell_list_add_span(struct cell_list *cells, int x1, int x2)
 
 	cell = cell_list_find(cells, ix1);
 	if (ix1 != ix2) {
-		cell->uncovered_area += 2*fx1*FAST_SAMPLES_Y;
+		cell->uncovered_area += fx1*FAST_SAMPLES_Y;
 		cell->covered_height += FAST_SAMPLES_Y;
 
 		cell = cell_list_find(cells, ix2);
-		cell->uncovered_area -= 2*fx2*FAST_SAMPLES_Y;
+		cell->uncovered_area -= fx2*FAST_SAMPLES_Y;
 		cell->covered_height -= FAST_SAMPLES_Y;
 	} else
-		cell->uncovered_area += 2*(fx1-fx2)*FAST_SAMPLES_Y;
+		cell->uncovered_area += (fx1-fx2)*FAST_SAMPLES_Y;
 }
 
 static void
@@ -1094,7 +1094,7 @@ tor_blt(struct sna *sna,
 	box.x1 = converter->extents.x1;
 
 	/* Form the spans from the coverages and areas. */
-	cover = cells->head.covered_height*FAST_SAMPLES_X*2;
+	cover = cells->head.covered_height*FAST_SAMPLES_X;
 	assert(cover >= 0);
 	for (cell = cells->head.next; cell != &cells->tail; cell = cell->next) {
 		int x = cell->x;
@@ -1116,7 +1116,7 @@ tor_blt(struct sna *sna,
 				span(sna, op, clip, &box, cover);
 			}
 			box.x1 = box.x2;
-			cover += cell->covered_height*FAST_SAMPLES_X*2;
+			cover += cell->covered_height*FAST_SAMPLES_X;
 		}
 
 		if (cell->uncovered_area) {
@@ -1451,7 +1451,7 @@ inplace_end_subrows(struct active_list *active, uint8_t *row,
 		buf += 4;
 
 		if (dw == 0) {
-			v = cover * 256 / (FAST_SAMPLES_X * FAST_SAMPLES_Y);
+			v = cover * 256 / FAST_SAMPLES_XY;
 			v -= v >> 8;
 			v |= v << 8;
 			dw = v | v << 16;
@@ -1459,7 +1459,7 @@ inplace_end_subrows(struct active_list *active, uint8_t *row,
 			cover += (int8_t)(dw & 0xff);
 			if (cover) {
 				assert(cover > 0);
-				v = cover * 256 / (FAST_SAMPLES_X * FAST_SAMPLES_Y);
+				v = cover * 256 / FAST_SAMPLES_XY;
 				v -= v >> 8;
 				dw >>= 8;
 				dw |= v << 24;
@@ -1469,7 +1469,7 @@ inplace_end_subrows(struct active_list *active, uint8_t *row,
 			cover += (int8_t)(dw & 0xff);
 			if (cover) {
 				assert(cover > 0);
-				v = cover * 256 / (FAST_SAMPLES_X * FAST_SAMPLES_Y);
+				v = cover * 256 / FAST_SAMPLES_XY;
 				v -= v >> 8;
 				dw >>= 8;
 				dw |= v << 24;
@@ -1479,7 +1479,7 @@ inplace_end_subrows(struct active_list *active, uint8_t *row,
 			cover += (int8_t)(dw & 0xff);
 			if (cover) {
 				assert(cover > 0);
-				v = cover * 256 / (FAST_SAMPLES_X * FAST_SAMPLES_Y);
+				v = cover * 256 / FAST_SAMPLES_XY;
 				v -= v >> 8;
 				dw >>= 8;
 				dw |= v << 24;
@@ -1489,7 +1489,7 @@ inplace_end_subrows(struct active_list *active, uint8_t *row,
 			cover += (int8_t)(dw & 0xff);
 			if (cover) {
 				assert(cover > 0);
-				v = cover * 256 / (FAST_SAMPLES_X * FAST_SAMPLES_Y);
+				v = cover * 256 / FAST_SAMPLES_XY;
 				v -= v >> 8;
 				dw >>= 8;
 				dw |= v << 24;
@@ -1508,7 +1508,7 @@ inplace_end_subrows(struct active_list *active, uint8_t *row,
 		cover += *buf++;
 		assert(cover >= 0);
 
-		v = cover * 256 / (FAST_SAMPLES_X * FAST_SAMPLES_Y);
+		v = cover * 256 / FAST_SAMPLES_XY;
 		v -= v >> 8;
 		*row++ = v;
 	}
@@ -1631,39 +1631,6 @@ static int operator_is_bounded(uint8_t op)
 	}
 }
 
-static inline bool
-project_trapezoid_onto_grid(const xTrapezoid *in,
-			    int dx, int dy,
-			    xTrapezoid *out)
-{
-	__DBG(("%s: in: L:(%d, %d), (%d, %d); R:(%d, %d), (%d, %d), [%d, %d]\n",
-	       __FUNCTION__,
-	       in->left.p1.x, in->left.p1.y, in->left.p2.x, in->left.p2.y,
-	       in->right.p1.x, in->right.p1.y, in->right.p2.x, in->right.p2.y,
-	       in->top, in->bottom));
-
-	out->left.p1.x = dx + pixman_fixed_to_fast(in->left.p1.x);
-	out->left.p1.y = dy + pixman_fixed_to_fast(in->left.p1.y);
-	out->left.p2.x = dx + pixman_fixed_to_fast(in->left.p2.x);
-	out->left.p2.y = dy + pixman_fixed_to_fast(in->left.p2.y);
-
-	out->right.p1.x = dx + pixman_fixed_to_fast(in->right.p1.x);
-	out->right.p1.y = dy + pixman_fixed_to_fast(in->right.p1.y);
-	out->right.p2.x = dx + pixman_fixed_to_fast(in->right.p2.x);
-	out->right.p2.y = dy + pixman_fixed_to_fast(in->right.p2.y);
-
-	out->top = dy + pixman_fixed_to_fast(in->top);
-	out->bottom = dy + pixman_fixed_to_fast(in->bottom);
-
-	__DBG(("%s: out: L:(%d, %d), (%d, %d); R:(%d, %d), (%d, %d), [%d, %d]\n",
-	       __FUNCTION__,
-	       out->left.p1.x, out->left.p1.y, out->left.p2.x, out->left.p2.y,
-	       out->right.p1.x, out->right.p1.y, out->right.p2.x, out->right.p2.y,
-	       out->top, out->bottom));
-
-	return xTrapezoidValid(out);
-}
-
 static span_func_t
 choose_span(struct sna_composite_spans_op *tmp,
 	    PicturePtr dst,
@@ -3255,22 +3222,6 @@ imprecise_trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
 	return true;
 }
 
-static inline bool
-project_trap_onto_grid(const xTrap *in,
-		       int dx, int dy,
-		       xTrap *out)
-{
-	out->top.l = dx + pixman_fixed_to_fast(in->top.l);
-	out->top.r = dx + pixman_fixed_to_fast(in->top.r);
-	out->top.y = dy + pixman_fixed_to_fast(in->top.y);
-
-	out->bot.l = dx + pixman_fixed_to_fast(in->bot.l);
-	out->bot.r = dx + pixman_fixed_to_fast(in->bot.r);
-	out->bot.y = dy + pixman_fixed_to_fast(in->bot.y);
-
-	return out->bot.y > out->top.y;
-}
-
 bool
 trap_span_converter(struct sna *sna,
 		    PicturePtr dst,
@@ -3490,33 +3441,6 @@ trap_mask_converter(struct sna *sna,
 	return true;
 }
 
-static inline void
-project_point_onto_grid(const xPointFixed *in,
-			int dx, int dy,
-			xPointFixed *out)
-{
-	out->x = dx + pixman_fixed_to_fast(in->x);
-	out->y = dy + pixman_fixed_to_fast(in->y);
-	__DBG(("%s: (%f, %f) -> (%d, %d)\n",
-	       __FUNCTION__,
-	       pixman_fixed_to_double(in->x),
-	       pixman_fixed_to_double(in->y),
-	       out->x, out->y));
-}
-
-#if HAS_PIXMAN_TRIANGLES
-static inline bool
-project_triangle_onto_grid(const xTriangle *in,
-			   int dx, int dy,
-			   xTriangle *out)
-{
-	project_point_onto_grid(&in->p1, dx, dy, &out->p1);
-	project_point_onto_grid(&in->p2, dx, dy, &out->p2);
-	project_point_onto_grid(&in->p3, dx, dy, &out->p3);
-
-	return xTriangleValid(out);
-}
-
 bool
 triangles_span_converter(struct sna *sna,
 			 CARD8 op, PicturePtr src, PicturePtr dst,
@@ -4001,5 +3925,3 @@ skip:
 	REGION_UNINIT(NULL, &clip);
 	return true;
 }
-
-#endif


More information about the xorg-commit mailing list