From 1ec6a0e27753027a68beeaff0276ae65c658d468 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 3 Oct 2011 16:14:18 +0100 Subject: [PATCH] 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 --- src/sna/sna_accel.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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(®ion); } +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, ®ion.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,