summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-10-03 16:14:18 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-10-04 12:23:26 +0100
commit1ec6a0e27753027a68beeaff0276ae65c658d468 (patch)
treefc25d93301d6dc7048f1f5b4306b71d18ecdc82b
parent413c9f7111c605a3842d4d0a85f8cf01470e5faa (diff)
sna: Move the source to the GPU if it is reused
We attempt to skip upload a source pixmap to the GPU in the event it is used only once (for example during image upload by firefox). However, if we continue to use the CPU source pixmap then it obviously was worth uploading to the GPU. So if we use the CPU pixmap a second time, do the upload and then blit. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_accel.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index a6e639ba..5a94fbda 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1142,6 +1142,15 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth,
RegionUninit(&region);
}
+static Bool
+move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv, const BoxRec *box)
+{
+ int w = box->x2 - box->x1;
+ int h = box->y2 - box->y1;
+
+ return ++priv->source_count * w*h >= 2 * pixmap->drawable.width * pixmap->drawable.height;
+}
+
static void
sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
BoxPtr box, int n,
@@ -1233,7 +1242,8 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
goto fallback;
}
- if (src_priv && src_priv->gpu_bo &&
+ if (src_priv &&
+ move_to_gpu(src_pixmap, src_priv, &region.extents) &&
sna_pixmap_move_to_gpu(src_pixmap)) {
if (!sna->render.copy_boxes(sna, alu,
src_pixmap, src_priv->gpu_bo, src_dx, src_dy,