diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-02-01 17:37:42 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-02-01 17:46:14 +0000 |
commit | 2814748b91c80c8935ea2f366e954a80bef69bb0 (patch) | |
tree | 32c04f34f0b2e90e775e9d7b8f22f6eceddb59ab /src/sna | |
parent | 3e784832a52686cd29d62bdeac7b1c539c640c5b (diff) |
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>
Diffstat (limited to 'src/sna')
-rw-r--r-- | src/sna/sna.h | 10 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 19 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index ff8b27dc..78330953 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -637,6 +637,16 @@ region_subsumes_drawable(RegionPtr region, DrawablePtr drawable) } 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) { const BoxRec *re, *de; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 613b9c73..f91ca29a 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -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); |