From c63147a3c33fd26f5c04a8648881659b4a90df06 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 10 Jan 2013 15:15:15 +0000 Subject: sna: Allow CPU bo to copy to GPU bo if the device is idle. Signed-off-by: Chris Wilson --- src/sna/kgem.h | 8 ++++++++ src/sna/sna_accel.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 4819dd6f..ac634887 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -297,6 +297,14 @@ static inline bool kgem_ring_is_idle(struct kgem *kgem, int ring) return __kgem_ring_is_idle(kgem, ring); } +static inline bool kgem_is_idle(struct kgem *kgem) +{ + if (!kgem->need_retire) + return true; + + return kgem_ring_is_idle(kgem, kgem->ring); +} + void _kgem_submit(struct kgem *kgem); static inline void kgem_submit(struct kgem *kgem) { diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 253ad873..e82fb20b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4345,7 +4345,7 @@ sna_pixmap_is_gpu(PixmapPtr pixmap) } static int -source_prefer_gpu(struct sna_pixmap *priv) +source_prefer_gpu(struct sna *sna, struct sna_pixmap *priv) { if (priv == NULL) { DBG(("%s: source unattached, use cpu\n", __FUNCTION__)); @@ -4368,7 +4368,7 @@ source_prefer_gpu(struct sna_pixmap *priv) } if (DAMAGE_IS_ALL(priv->cpu_damage)) - return 0; + return priv->cpu_bo && kgem_is_idle(&sna->kgem); DBG(("%s: source has GPU bo? %d\n", __FUNCTION__, priv->gpu_bo != NULL)); @@ -4466,7 +4466,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, if (dst_priv == NULL) goto fallback; - hint = source_prefer_gpu(src_priv) ?: + hint = source_prefer_gpu(sna, src_priv) ?: region_inplace(sna, dst_pixmap, region, dst_priv, alu_overwrites(alu)); if (dst_priv->cpu_damage && alu_overwrites(alu)) { -- cgit v1.2.3