From 42529336fd92d39a5a5eceb07f2838d4be50fa8e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 31 Jan 2013 00:58:51 +0000 Subject: [PATCH] sna: Prevent falling back to swrast if source is on the GPU Currently if the dst is wholly contained within the CPU, then we try to continue to operate on the GPU. However, if we have FORCE_GPU set, it means that one of the sources for the operation resides on the GPU, and that would require a readback in order to perform the operation on the CPU. Hence, if we try to use a CPU bo and fail, convert back to using the GPU bo if forced. Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index d34a4f92..e4065060 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2815,11 +2815,23 @@ use_gpu_bo: return priv->gpu_bo; use_cpu_bo: - if (!USE_CPU_BO) - return NULL; + if (!USE_CPU_BO || priv->cpu_bo == NULL) { +cpu_fail: + if ((flags & FORCE_GPU) && priv->gpu_bo) { + get_drawable_deltas(drawable, pixmap, &dx, &dy); + + region.extents = *box; + region.extents.x1 += dx; + region.extents.x2 += dx; + region.extents.y1 += dy; + region.extents.y2 += dy; + region.data = NULL; + + goto move_to_gpu; + } - if (priv->cpu_bo == NULL) return NULL; + } assert(priv->cpu_bo->refcnt); @@ -2858,12 +2870,12 @@ use_cpu_bo: } if (!sna->kgem.can_blt_cpu) - return NULL; + goto cpu_fail; if (!sna_drawable_move_region_to_cpu(&pixmap->drawable, ®ion, (flags & IGNORE_CPU ? MOVE_READ : 0) | MOVE_WRITE | MOVE_ASYNC_HINT)) { DBG(("%s: failed to move-to-cpu, fallback\n", __FUNCTION__)); - return NULL; + goto cpu_fail; } if (priv->shm) {