From 55cef974a5dad3fda1922648fa27bcf5bb32ea03 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 5 Sep 2012 09:38:47 +0100 Subject: [PATCH] sna: Review validity of damage when discarding CPU bo Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 64 +++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 3c0736ee..41f53d43 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1452,12 +1452,11 @@ skip_inplace_map: priv->mapped = false; } - if (priv->clear) { - if (priv->cpu_bo && !priv->cpu_bo->flush && - __kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) { - assert(!priv->shm); - sna_pixmap_free_cpu(sna, priv); - } + if (priv->clear && priv->cpu_bo && !priv->cpu_bo->flush && + __kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) { + assert(!priv->shm); + assert(DAMAGE_IS_ALL(priv->gpu_damage)); + sna_pixmap_free_cpu(sna, priv); } if (pixmap->devPrivate.ptr == NULL && @@ -3462,36 +3461,33 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region, priv->gpu_bo = NULL; } - if (priv->cpu_bo) { - /* If the GPU is currently accessing the CPU pixmap, then - * we will need to wait for that to finish before we can - * modify the memory. - * - * However, we can queue some writes to the GPU bo to avoid - * the wait. Or we can try to replace the CPU bo. - */ - if (!priv->shm && __kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) { - assert(!priv->cpu_bo->flush); - DBG(("%s: cpu bo will stall, upload damage and discard\n", - __FUNCTION__)); - if (priv->cpu_damage) { - if (!region_subsumes_drawable(region, &pixmap->drawable)) { - sna_damage_subtract(&priv->cpu_damage, region); - if (!sna_pixmap_move_to_gpu(pixmap, - MOVE_WRITE)) - return false; - } else { - sna_damage_destroy(&priv->cpu_damage); - priv->undamaged = false; - } - assert(priv->cpu_damage == NULL); + /* If the GPU is currently accessing the CPU pixmap, then + * we will need to wait for that to finish before we can + * modify the memory. + * + * However, we can queue some writes to the GPU bo to avoid + * the wait. Or we can try to replace the CPU bo. + */ + if (!priv->shm && priv->cpu_bo && __kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) { + assert(!priv->cpu_bo->flush); + DBG(("%s: cpu bo will stall, upload damage and discard\n", + __FUNCTION__)); + if (priv->cpu_damage) { + if (!region_subsumes_drawable(region, &pixmap->drawable)) { + sna_damage_subtract(&priv->cpu_damage, region); + if (!sna_pixmap_move_to_gpu(pixmap, + MOVE_WRITE)) + return false; + } else { + sna_damage_destroy(&priv->cpu_damage); + priv->undamaged = false; } - if (!priv->undamaged) - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); - sna_pixmap_free_cpu(sna, priv); + assert(priv->cpu_damage == NULL); } + sna_damage_all(&priv->gpu_damage, + pixmap->drawable.width, + pixmap->drawable.height); + sna_pixmap_free_cpu(sna, priv); } if (priv->mapped) {