sna: Ensure we flush SHM pixmaps if rendering to a GPU shadow
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 14 Mar 2014 11:32:38 +0000 (11:32 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 14 Mar 2014 11:38:19 +0000 (11:38 +0000)
Normally, we try to render into the CPU bo of a SHM pixmap. However, under
the right circumstances we may try to do a series of rendering into the
GPU bo and then copy it back to the CPU bo. In that case, we need to be
sure to mark the pixmap as requiring the flush.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/sna/sna_accel.c

index 716a9fe..4f08e99 100644 (file)
@@ -3438,7 +3438,7 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box,
                flags &= ~PREFER_GPU;
 
        if ((flags & (PREFER_GPU | IGNORE_CPU)) == IGNORE_CPU) {
-               if (box_inplace(pixmap, box))
+               if (priv->gpu_bo && box_inplace(pixmap, box))
                        flags |= PREFER_GPU;
        }
 
@@ -3618,6 +3618,7 @@ move_to_gpu:
        }
 
 done:
+       assert(priv->move_to_gpu == NULL);
        assert(priv->gpu_bo != NULL);
        assert(priv->gpu_bo->refcnt);
        if (sna_damage_is_all(&priv->gpu_damage,
@@ -3635,6 +3636,7 @@ done:
        assert(priv->gpu_bo->proxy == NULL);
        assert(priv->clear == false);
        assert(priv->cpu == false);
+       assert(!priv->shm);
        return priv->gpu_bo;
 
 use_gpu_bo:
@@ -3654,6 +3656,11 @@ use_gpu_bo:
                }
        }
 
+       if (priv->shm) {
+               assert(!priv->flush);
+               list_move(&priv->flush_list, &sna->flush_pixmaps);
+       }
+
        DBG(("%s: using whole GPU bo\n", __FUNCTION__));
        assert(priv->gpu_bo != NULL);
        assert(priv->gpu_bo->refcnt);