diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-10-03 16:14:18 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-10-04 12:23:26 +0100 |
commit | 1ec6a0e27753027a68beeaff0276ae65c658d468 (patch) | |
tree | fc25d93301d6dc7048f1f5b4306b71d18ecdc82b | |
parent | 413c9f7111c605a3842d4d0a85f8cf01470e5faa (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.c | 12 |
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(®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, |