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>
This commit is contained in:
Chris Wilson 2011-10-03 16:14:18 +01:00
parent 413c9f7111
commit 1ec6a0e277
1 changed files with 11 additions and 1 deletions

View File

@ -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,