xf86-video-intel: 3 commits - src/intel_uxa.c src/sna/sna_accel.c src/sna/sna_glyphs.c src/sna/sna_render.c src/sna/sna_tiling.c src/sna/sna_trapezoids.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Dec 14 17:09:20 PST 2011


 src/intel_uxa.c          |   43 ++++++++++++++++++++++++-------------------
 src/sna/sna_accel.c      |    1 -
 src/sna/sna_glyphs.c     |   16 ++++++++++------
 src/sna/sna_render.c     |    8 +++++---
 src/sna/sna_tiling.c     |   15 ++++++++++-----
 src/sna/sna_trapezoids.c |   24 +++++++++++++++---------
 6 files changed, 64 insertions(+), 43 deletions(-)

New commits:
commit 1cc43dc97bd6438d7fc808cb5ee449889a966bdf
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Dec 15 00:00:56 2011 +0000

    sna: More missing move-to-cpu allocation checks
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index c3864a1..e065c6a 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -1023,13 +1023,17 @@ glyphs_fallback(CARD8 op,
 	if (!RegionNotEmpty(&region))
 		return;
 
-	sna_drawable_move_region_to_cpu(dst->pDrawable, &region, true);
-	if (dst->alphaMap)
-		sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true);
+	if (!sna_drawable_move_region_to_cpu(dst->pDrawable, &region, true))
+		return;
+	if (dst->alphaMap &&
+	    !sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true))
+		return;
 	if (src->pDrawable) {
-		sna_drawable_move_to_cpu(src->pDrawable, false);
-		if (src->alphaMap)
-			sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false);
+		if (!sna_drawable_move_to_cpu(src->pDrawable, false))
+			return;
+		if (src->alphaMap &&
+		    !sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false))
+			return;
 	}
 	RegionTranslate(&region, -dst->pDrawable->x, -dst->pDrawable->y);
 
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index e10f484..19385af 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -954,8 +954,9 @@ sna_render_picture_fixup(struct sna *sna,
 		     __FUNCTION__, channel->pict_format, pitch, picture->format));
 	}
 
-	if (picture->pDrawable)
-		sna_drawable_move_to_cpu(picture->pDrawable, false);
+	if (picture->pDrawable &&
+	    !sna_drawable_move_to_cpu(picture->pDrawable, false))
+		return 0;
 
 	channel->bo = kgem_create_buffer(&sna->kgem,
 					 pitch*h, KGEM_BUFFER_WRITE,
@@ -1098,7 +1099,8 @@ sna_render_picture_convert(struct sna *sna,
 		return 0;
 	}
 
-	sna_pixmap_move_to_cpu(pixmap, false);
+	if (!sna_pixmap_move_to_cpu(pixmap, false))
+		return 0;
 
 	src = pixman_image_create_bits(picture->format,
 				       pixmap->drawable.width,
diff --git a/src/sna/sna_tiling.c b/src/sna/sna_tiling.c
index bab299e..83dbd8c 100644
--- a/src/sna/sna_tiling.c
+++ b/src/sna/sna_tiling.c
@@ -201,11 +201,16 @@ sna_tiling_composite_done(struct sna *sna,
 			} else {
 				DBG(("%s -- falback\n", __FUNCTION__));
 
-				sna_drawable_move_to_cpu(tile->dst->pDrawable, true);
-				if (tile->src->pDrawable)
-					sna_drawable_move_to_cpu(tile->src->pDrawable, false);
-				if (tile->mask && tile->mask->pDrawable)
-					sna_drawable_move_to_cpu(tile->mask->pDrawable, false);
+				if (!sna_drawable_move_to_cpu(tile->dst->pDrawable, true))
+					goto done;
+
+				if (tile->src->pDrawable &&
+				    !sna_drawable_move_to_cpu(tile->src->pDrawable, false))
+					goto done;
+
+				if (tile->mask && tile->mask->pDrawable &&
+				    !sna_drawable_move_to_cpu(tile->mask->pDrawable, false))
+					goto done;
 
 				fbComposite(tile->op,
 					    tile->src, tile->mask, tile->dst,
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index b8b7bb1..8899f38 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -3176,7 +3176,8 @@ trapezoid_span_inplace(CARD8 op, PicturePtr src, PicturePtr dst,
 	}
 
 	region.data = NULL;
-	sna_drawable_move_region_to_cpu(dst->pDrawable, &region, true);
+	if (!sna_drawable_move_region_to_cpu(dst->pDrawable, &region, true))
+		return true;
 
 	pixmap = get_drawable_pixmap(dst->pDrawable);
 	get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
@@ -3312,13 +3313,17 @@ trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
 		region.extents.y2 = dst_y + extents.y2;
 		region.data = NULL;
 
-		sna_drawable_move_region_to_cpu(dst->pDrawable, &region, true);
-		if (dst->alphaMap)
-			sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true);
+		if (!sna_drawable_move_region_to_cpu(dst->pDrawable, &region, true))
+			goto done;
+		if (dst->alphaMap  &&
+		    !sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true))
+			goto done;
 		if (src->pDrawable) {
-			sna_drawable_move_to_cpu(src->pDrawable, false);
-			if (src->alphaMap)
-				sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false);
+			if (!sna_drawable_move_to_cpu(src->pDrawable, false))
+				goto done;
+			if (src->alphaMap &&
+			    !sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false))
+				goto done;
 		}
 
 		fbComposite(op, src, mask, dst,
@@ -3327,6 +3332,7 @@ trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
 			    0, 0,
 			    dst_x, dst_y,
 			    extents.x2, extents.y2);
+done:
 		FreePicture(mask, 0);
 	}
 	tor_fini(&tor);
@@ -3881,8 +3887,8 @@ sna_add_traps(PicturePtr picture, INT16 x, INT16 y, int n, xTrap *t)
 	}
 
 	DBG(("%s -- fallback\n", __FUNCTION__));
-	sna_drawable_move_to_cpu(picture->pDrawable, true);
-	fbAddTraps(picture, x, y, n, t);
+	if (sna_drawable_move_to_cpu(picture->pDrawable, true))
+		fbAddTraps(picture, x, y, n, t);
 }
 
 static inline void
commit 12448b56060fb9c14da6b4ab02c95c7834fd3874
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Dec 15 00:01:37 2011 +0000

    sna: silence warning for unused 'priv'
    
    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 6789c34..da61d01 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -6560,7 +6560,6 @@ sna_poly_fill_rect_stippled_1_blt(DrawablePtr drawable,
 {
 	PixmapPtr pixmap = get_drawable_pixmap(drawable);
 	struct sna *sna = to_sna_from_pixmap(pixmap);
-	struct sna_pixmap *priv = sna_pixmap(pixmap);
 	PixmapPtr stipple = gc->stipple;
 	const DDXPointRec *origin = &gc->patOrg;
 	int16_t dx, dy;
commit eb8e979b4de5d854f15ae4c86d3db29371b386c1
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 14 23:02:28 2011 +0000

    uxa/glamor: Allocate a fbPixmap with storage for fallbacks
    
    When we try to create a glamor pixmap and fail we need to create a real
    pixmap along with its pixel allocation, instead of detaching ourselves
    and returning the fake pixmap header.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index f24f39f..292642e 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -1023,6 +1023,7 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 {
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
+	struct intel_pixmap *priv;
 	PixmapPtr pixmap;
 
 	if (w > 32767 || h > 32767)
@@ -1038,9 +1039,10 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		return fbCreatePixmap(screen, w, h, depth, usage);
 
 	pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
+	if (pixmap == NullPixmap)
+		return pixmap;
 
 	if (w && h) {
-		struct intel_pixmap *priv;
 		unsigned int size, tiling;
 		int stride;
 
@@ -1070,10 +1072,8 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		 * frequently, and also will tend to fail to successfully map when doing
 		 * SW fallbacks because we overcommit address space for BO access.
 		 */
-		if (size > intel->max_bo_size || stride >= KB(32)) {
-			fbDestroyPixmap(pixmap);
-			return fbCreatePixmap(screen, w, h, depth, usage);
-		}
+		if (size > intel->max_bo_size || stride >= KB(32))
+			goto fallback_pixmap;
 
 		/* Perform a preliminary search for an in-flight bo */
 		if (usage != UXA_CREATE_PIXMAP_FOR_MAP) {
@@ -1106,21 +1106,20 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 				}
 
 				list_del(&priv->in_flight);
-				screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
 				intel_set_pixmap_private(pixmap, priv);
 
+				screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
+
 				if (!intel_glamor_create_textured_pixmap(pixmap))
-					intel_set_pixmap_bo(pixmap, NULL);
+					goto fallback_bo;
 
 				return pixmap;
 			}
 		}
 
 		priv = calloc(1, sizeof (struct intel_pixmap));
-		if (priv == NULL) {
-			fbDestroyPixmap(pixmap);
-			return NullPixmap;
-		}
+		if (priv == NULL)
+			goto fallback_pixmap;
 
 		if (usage == UXA_CREATE_PIXMAP_FOR_MAP) {
 			priv->busy = 0;
@@ -1132,11 +1131,8 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 								 "pixmap",
 								 size, 0);
 		}
-		if (!priv->bo) {
-			free(priv);
-			fbDestroyPixmap(pixmap);
-			return NullPixmap;
-		}
+		if (!priv->bo)
+			goto fallback_priv;
 
 		if (tiling != I915_TILING_NONE)
 			drm_intel_bo_set_tiling(priv->bo, &tiling, stride);
@@ -1144,11 +1140,12 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		priv->tiling = tiling;
 		priv->offscreen = 1;
 
-		screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
-
 		list_init(&priv->batch);
 		list_init(&priv->flush);
 		intel_set_pixmap_private(pixmap, priv);
+
+		screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
+
 		/* Create textured pixmap failed means glamor fail to create
 		 * a texture from the BO for some reasons, and then glamor
 		 * create a new texture attached to the pixmap, and all the
@@ -1157,10 +1154,18 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		 * BO if it is the case.
 		 */
 		if (!intel_glamor_create_textured_pixmap(pixmap))
-			intel_set_pixmap_bo(pixmap, NULL);
+			goto fallback_bo;
 	}
 
 	return pixmap;
+
+fallback_bo:
+	dri_bo_unreference(priv->bo);
+fallback_priv:
+	free(priv);
+fallback_pixmap:
+	fbDestroyPixmap(pixmap);
+	return fbCreatePixmap(screen, w, h, depth, usage);
 }
 
 static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap)


More information about the xorg-commit mailing list