sna: Avoid promoting region-to-whole migration and discarding damage
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 27 Feb 2014 08:33:52 +0000 (08:33 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 27 Feb 2014 08:33:52 +0000 (08:33 +0000)
Fixes regression from
commit 1de1104064b5898cbed37e836901694a381c1266
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Feb 21 22:43:04 2014 +0000

    sna: Use a hint to do whole image uploads inplace

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75549
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/sna/sna_accel.c

index abc3b85..9ead602 100644 (file)
@@ -2495,10 +2495,10 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
                flags |= MOVE_INPLACE_HINT;
        }
 
-       if (flags & MOVE_WHOLE_HINT)
+       if (flags & MOVE_WHOLE_HINT && priv->gpu_damage == NULL)
                return _sna_pixmap_move_to_cpu(pixmap, flags);
 
-       if (priv->gpu_bo == NULL &&
+       if (priv->gpu_damage == NULL &&
            (priv->create & KGEM_CAN_CREATE_GPU) == 0 &&
            flags & MOVE_WRITE)
                return _sna_pixmap_move_to_cpu(pixmap, flags);
@@ -2522,6 +2522,24 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
                return _sna_pixmap_move_to_cpu(pixmap, flags);
        }
 
+       if ((flags & MOVE_READ) == 0 &&
+           priv->gpu_damage &&
+           region_subsumes_damage(region, priv->gpu_damage)) {
+               DBG(("%s: region [(%d, %d), (%d, %d)] subsumes damage [(%d,%d), (%d, %d)]\n",
+                      __FUNCTION__,
+                      region->extents.x1,
+                      region->extents.y1,
+                      region->extents.x2,
+                      region->extents.y2,
+                      priv->gpu_damage->extents.x1,
+                      priv->gpu_damage->extents.y1,
+                      priv->gpu_damage->extents.x2,
+                      priv->gpu_damage->extents.y2));
+               if (dx | dy)
+                       RegionTranslate(region, -dx, -dy);
+               return _sna_pixmap_move_to_cpu(pixmap, flags);
+       }
+
        if (priv->move_to_gpu && !priv->move_to_gpu(sna, priv, MOVE_READ)) {
                DBG(("%s: move-to-gpu override failed\n", __FUNCTION__));
                if (dx | dy)