From a2d92ade3911e62f950c85b5650fb13da1279ced Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 31 May 2012 17:49:01 +0100 Subject: [PATCH] sna: Prevent readback of 1x1 if it lies inside CPU damage If the pixel exists only in the CPU damage, attempting to read it back from the GPU only results in garbage. Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4511ec8a..4f4b7b3b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1528,7 +1528,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable, region->extents.x2 - region->extents.x1, region->extents.y2 - region->extents.y1)); - if ((flags & MOVE_WRITE) == 0 && + if ((flags & MOVE_WRITE) == 0 && priv->cpu_damage == NULL && region->extents.x2 - region->extents.x1 == 1 && region->extents.y2 - region->extents.y1 == 1) { /* Often associated with synchronisation, KISS */ @@ -1548,6 +1548,16 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable, region->extents.x2 - region->extents.x1, region->extents.y2 - region->extents.y1)); + if ((flags & MOVE_WRITE) == 0 && + region->extents.x2 - region->extents.x1 == 1 && + region->extents.y2 - region->extents.y1 == 1) { + sna_read_boxes(sna, + priv->gpu_bo, 0, 0, + pixmap, 0, 0, + ®ion->extents, 1); + goto done; + } + /* Expand the region to move 32x32 pixel blocks at a * time, as we assume that we will continue writing * afterwards and so aim to coallesce subsequent @@ -10079,8 +10089,11 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) goto fallback; } - if (!PM_IS_SOLID(draw, gc->planemask)) + if (!PM_IS_SOLID(draw, gc->planemask)) { + DBG(("%s: fallback -- planemask=%#lx (not-solid)\n", + __FUNCTION__, gc->planemask)); goto fallback; + } /* Clear the cpu damage so that we refresh the GPU status of the * pixmap upon a redraw after a period of inactivity.