xf86-video-intel: src/sna/sna_accel.c src/sna/sna_glyphs.c src/sna/sna_render.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Jun 23 14:19:29 PDT 2014


 src/sna/sna_accel.c  |    4 ++--
 src/sna/sna_glyphs.c |    8 +++-----
 src/sna/sna_render.c |   45 +++++++++++++++++++++------------------------
 3 files changed, 26 insertions(+), 31 deletions(-)

New commits:
commit ded05e8abb248664124d2b86f77c27497a252c4e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 23 22:15:56 2014 +0100

    sna: Allow scratch pixmap to allocate linear GPU bo
    
    When allocating a scratch pixmap, we do so in the expectation that
    rendering on the GPU is always preferrable, so even allocate a small
    linear bo.
    
    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 defc89d..d729166 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1325,12 +1325,12 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 			goto fallback;
 
 	case SNA_CREATE_SCRATCH:
-		if (flags & KGEM_CAN_CREATE_GPU)
+		if (flags & (KGEM_CAN_CREATE_CPU | KGEM_CAN_CREATE_GPU))
 			return sna_pixmap_create_scratch(screen,
 							 width, height, depth,
 							 I915_TILING_Y);
 		else
-			goto fallback;
+			return NullPixmap;
 	}
 
 	if (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE)
diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index 5587fcc..96279e6 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -246,6 +246,7 @@ bool sna_glyphs_create(struct sna *sna)
 		priv = sna_pixmap(pixmap);
 		if (priv != NULL) {
 			/* Prevent the cache from ever being paged out */
+			assert(priv->gpu_bo);
 			priv->pinned = PIN_SCANOUT;
 
 			component_alpha = NeedsComponent(pPictFormat->format);
@@ -1339,12 +1340,9 @@ next_image:
 					      width, height, format->depth,
 					      SNA_CREATE_SCRATCH);
 		if (!pixmap)
-			return false;
-
-		if (sna_pixmap(pixmap) == NULL) {
-			sna_pixmap_destroy(pixmap);
 			goto use_small_mask;
-		}
+
+		assert(__sna_pixmap_get_bo(pixmap));
 
 		mask = CreatePicture(0, &pixmap->drawable,
 				     format, CPComponentAlpha,
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index 5c07a2b..3b8a54a 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -771,11 +771,7 @@ static int sna_render_picture_downsample(struct sna *sna,
 	if (tmp == NULL)
 		goto fixup;
 
-	priv = sna_pixmap(tmp);
-	if (priv == NULL) {
-		screen->DestroyPixmap(tmp);
-		goto fixup;
-	}
+	assert(__sna_pixmap_get_bo(tmp));
 
 	if (!sna_pixmap_move_to_gpu(pixmap, MOVE_SOURCE_HINT | MOVE_READ)) {
 fixup:
@@ -1352,22 +1348,20 @@ sna_render_picture_convolve(struct sna *sna,
 		DBG(("%s: pixmap allocation failed\n", __FUNCTION__));
 		return -1;
 	}
+	assert(__sna_pixmap_get_bo(tmp));
 
-	tmp = CreatePicture(0, &pixmap->drawable,
-			    PictureMatchFormat(screen, depth, channel->pict_format),
-			    0, NULL, serverClient, &error);
+	tmp = NULL;
+	bo = __sna_pixmap_get_bo(pixmap);
+	if (sna->render.clear(sna, pixmap, bo))
+		tmp = CreatePicture(0, &pixmap->drawable,
+				PictureMatchFormat(screen, depth, channel->pict_format),
+				0, NULL, serverClient, &error);
 	screen->DestroyPixmap(pixmap);
 	if (tmp == NULL)
 		return -1;
 
 	ValidatePicture(tmp);
 
-	bo = __sna_pixmap_get_bo(pixmap);
-	if (!sna->render.clear(sna, pixmap, bo)) {
-		FreePicture(tmp, 0);
-		return 0;
-	}
-
 	picture->filter = PictFilterBilinear;
 	params += 2;
 	for (j = 0; j < ch; j++) {
@@ -1412,7 +1406,7 @@ sna_render_picture_convolve(struct sna *sna,
 	return 1;
 }
 
-static int
+static bool
 sna_render_picture_flatten(struct sna *sna,
 			   PicturePtr picture,
 			   struct sna_composite_channel *channel,
@@ -1435,15 +1429,17 @@ sna_render_picture_flatten(struct sna *sna,
 	pixmap = screen->CreatePixmap(screen, w, h, 32, SNA_CREATE_SCRATCH);
 	if (pixmap == NullPixmap) {
 		DBG(("%s: pixmap allocation failed\n", __FUNCTION__));
-		return -1;
+		return false;
 	}
 
+	assert(__sna_pixmap_get_bo(pixmap));
+
 	tmp = CreatePicture(0, &pixmap->drawable,
 			    PictureMatchFormat(screen, 32, PICT_a8r8g8b8),
 			    0, NULL, serverClient, &error);
 	screen->DestroyPixmap(pixmap);
 	if (tmp == NULL)
-		return -1;
+		return false;
 
 	ValidatePicture(tmp);
 
@@ -1481,7 +1477,7 @@ sna_render_picture_flatten(struct sna *sna,
 	channel->bo = kgem_bo_reference(__sna_pixmap_get_bo(pixmap));
 	FreePicture(tmp, 0);
 
-	return 1;
+	return true;
 }
 
 int
@@ -1624,8 +1620,9 @@ sna_render_picture_fixup(struct sna *sna,
 		DBG(("%s: alphamap\n", __FUNCTION__));
 		if (is_gpu(sna, picture->pDrawable, PREFER_GPU_RENDER) ||
 		    is_gpu(sna, picture->alphaMap->pDrawable, PREFER_GPU_RENDER)) {
-			return sna_render_picture_flatten(sna, picture, channel,
-							  x, y, w, h, dst_x, dst_y);
+			if (sna_render_picture_flatten(sna, picture, channel,
+							  x, y, w, h, dst_x, dst_y))
+				return 1;
 		}
 
 		goto do_fixup;
@@ -1810,10 +1807,12 @@ sna_render_picture_convert(struct sna *sna,
 		     (unsigned)channel->pict_format,
 		     (unsigned)picture->format));
 
-		tmp = screen->CreatePixmap(screen, w, h, pixmap->drawable.bitsPerPixel, 0);
+		tmp = screen->CreatePixmap(screen, w, h, pixmap->drawable.bitsPerPixel, SNA_CREATE_SCRATCH);
 		if (tmp == NULL)
 			return -1;
 
+		assert(__sna_pixmap_get_bo(tmp));
+
 		dst = CreatePicture(0, &tmp->drawable,
 				    PictureMatchFormat(screen,
 						       pixmap->drawable.bitsPerPixel,
@@ -2144,8 +2143,7 @@ sna_render_copy_boxes__overlap(struct sna *sna, uint8_t alu,
 		return false;
 
 	bo = __sna_pixmap_get_bo(tmp);
-	if (bo == NULL)
-		goto out;
+	assert(bo);
 
 	ret = (sna->render.copy_boxes(sna, GXcopy,
 				      src, src_bo, src_dx, src_dy,
@@ -2156,7 +2154,6 @@ sna_render_copy_boxes__overlap(struct sna *sna, uint8_t alu,
 				      dst, dst_bo, dst_dx, dst_dy,
 				      box, n , 0));
 
-out:
 	screen->DestroyPixmap(tmp);
 	return ret;
 }


More information about the xorg-commit mailing list