From 3efe143e367acfa2ff38c63388d24a8d06331944 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 17 May 2013 10:30:51 +0100 Subject: [PATCH] sna: Clear mapped hints upon cloning a pair of pixmaps Once cloned, we do not want to use inplace operations and instead force a copy. However, if we do not relinquish the hints when copying across the bo, then those hints become stale and lead to corruption. Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index f6246a3e..81254554 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1536,14 +1536,15 @@ static inline bool use_cpu_bo_for_upload(struct sna *sna, static bool sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags) { - assert(priv->gpu_bo == priv->cow->bo); - DBG(("%s: pixmap=%ld, handle=%ld, flags=%x\n", __FUNCTION__, priv->pixmap->drawable.serialNumber, priv->gpu_bo->handle, flags)); + assert(priv->gpu_bo == priv->cow->bo); + assert(!priv->mapped); + if (!--priv->cow->refcnt) { free(priv->cow); } else { @@ -1612,6 +1613,7 @@ sna_pixmap_make_cow(struct sna *sna, return false; } + assert(!src_priv->flush); assert(!dst_priv->flush); cow = src_priv->cow; @@ -1624,7 +1626,13 @@ sna_pixmap_make_cow(struct sna *sna, cow->refcnt = 1; src_priv->cow = cow; + + if (src_priv->mapped) { + src_priv->pixmap->devPrivate.ptr = NULL; + src_priv->mapped = false; + } } + assert(!src_priv->mapped); if (cow == dst_priv->cow) return true; @@ -1638,6 +1646,11 @@ sna_pixmap_make_cow(struct sna *sna, dst_priv->cow = cow; cow->refcnt++; + if (dst_priv->mapped) { + dst_priv->pixmap->devPrivate.ptr = NULL; + dst_priv->mapped = false; + } + return true; }