summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-08-14 12:03:24 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-08-14 12:03:24 +0100
commit9f07d1fc0181f22da36837337241f228626e0d88 (patch)
tree460fd227e3489a16cdb7503ab635f3d23503cc96
parent9b016d2e466f342cc6649504fa48ab6a810c7e94 (diff)
sna: Enable use of shm pixmap for readback
A little too overzealous in the degradation of writing to the CPU bo if we need to read from a GPU bo. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_accel.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 136aceb7..bd076627 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2341,6 +2341,8 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box,
}
if (priv->gpu_bo && priv->gpu_bo->proxy) {
+ DBG(("%s: cached upload proxy, discard and revert to GPU\n",
+ __FUNCTION__));
kgem_bo_destroy(&to_sna_from_pixmap(pixmap)->kgem,
priv->gpu_bo);
priv->gpu_bo = NULL;
@@ -2350,19 +2352,32 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box,
if (priv->flush)
flags |= PREFER_GPU;
if (priv->shm)
- flags = 0;
+ flags &= ~PREFER_GPU;
if (priv->cpu && (flags & FORCE_GPU) == 0)
- flags = 0;
+ flags &= ~PREFER_GPU;
+
+ DBG(("%s: flush=%d, shm=%d, cpu=%d => flags=%x\n",
+ __FUNCTION__, priv->flush, priv->shm, priv->cpu, flags));
- if (!flags && (!priv->gpu_damage || !kgem_bo_is_busy(priv->gpu_bo)))
+ if ((flags & PREFER_GPU) == 0 &&
+ (!priv->gpu_damage || !kgem_bo_is_busy(priv->gpu_bo))) {
+ DBG(("%s: try cpu as GPU bo is idle\n", __FUNCTION__));
goto use_cpu_bo;
+ }
- if (DAMAGE_IS_ALL(priv->gpu_damage))
+ if (DAMAGE_IS_ALL(priv->gpu_damage)) {
+ DBG(("%s: use GPU fast path (all-damaged)\n", __FUNCTION__));
goto use_gpu_bo;
+ }
- if (DAMAGE_IS_ALL(priv->cpu_damage))
+ if (DAMAGE_IS_ALL(priv->cpu_damage)) {
+ DBG(("%s: use CPU fast path (all-damaged)\n", __FUNCTION__));
goto use_cpu_bo;
+ }
+ DBG(("%s: gpu? %d, damaged? %d; cpu? %d, damaged? %d\n", __FUNCTION__,
+ priv->gpu_bo ? priv->gpu_bo->handle : 0, priv->gpu_damage != NULL,
+ priv->cpu_bo ? priv->cpu_bo->handle : 0, priv->cpu_damage != NULL));
if (priv->gpu_bo == NULL) {
unsigned int move;
@@ -2502,7 +2517,7 @@ use_cpu_bo:
if (!to_sna_from_pixmap(pixmap)->kgem.can_blt_cpu)
return NULL;
- if (flags == 0 && !kgem_bo_is_busy(priv->cpu_bo))
+ if ((flags & FORCE_GPU) == 0 && !kgem_bo_is_busy(priv->cpu_bo))
return NULL;
get_drawable_deltas(drawable, pixmap, &dx, &dy);
@@ -4008,6 +4023,9 @@ source_prefer_gpu(struct sna_pixmap *priv)
return PREFER_GPU | FORCE_GPU;
}
+ if (DAMAGE_IS_ALL(priv->cpu_damage))
+ return 0;
+
DBG(("%s: source has GPU bo? %d\n",
__FUNCTION__, priv->gpu_bo != NULL));
return priv->gpu_bo != NULL;