sna: Only discard CPU damage for an replacing region

When considering move-region-to-cpu, we need to take into account that
the region may not replace the whole drawable, in which case we cannot
simply dispose of an active CPU bo.

Reported-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reported-by: Conley Moorhous <conleymoorhous@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74327
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-02-01 17:37:42 +00:00
parent 3e784832a5
commit 2814748b91
2 changed files with 24 additions and 5 deletions

View File

@ -636,6 +636,16 @@ region_subsumes_drawable(RegionPtr region, DrawablePtr drawable)
extents->y2 >= drawable->height;
}
static inline bool
region_subsumes_pixmap(RegionPtr region, PixmapPtr pixmap)
{
if (region->data)
return false;
return (region->extents.x2 - region->extents.x1 >= pixmap->drawable.width &&
region->extents.y2 - region->extents.y1 >= pixmap->drawable.height);
}
static inline bool
region_subsumes_damage(const RegionRec *region, struct sna_damage *damage)
{

View File

@ -546,9 +546,6 @@ static void __sna_pixmap_free_cpu(struct sna *sna, struct sna_pixmap *priv)
static void sna_pixmap_free_cpu(struct sna *sna, struct sna_pixmap *priv, bool active)
{
assert(priv->cpu_damage == NULL);
assert(list_is_empty(&priv->flush_list));
if (active)
return;
@ -2426,8 +2423,20 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
if ((flags & MOVE_READ) == 0 &&
priv->cpu_bo && !priv->cpu_bo->flush &&
__kgem_bo_is_busy(&sna->kgem, priv->cpu_bo))
sna_pixmap_free_cpu(sna, priv, false);
__kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) {
bool free_cpu = false;
if (!region_subsumes_pixmap(region, pixmap)) {
if (priv->gpu_bo) {
sna_damage_subtract(&priv->cpu_damage, region);
free_cpu = sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_ASYNC_HINT);
}
} else
free_cpu = true;
if (free_cpu)
sna_pixmap_free_cpu(sna, priv, false);
}
sna_pixmap_unmap(pixmap, priv);
assert(priv->mapped == MAPPED_NONE);