diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-01-10 15:15:15 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-01-10 15:19:36 +0000 |
commit | c63147a3c33fd26f5c04a8648881659b4a90df06 (patch) | |
tree | 092b7ddef1a6a5be80dc0808d3b451e38aae769d | |
parent | 2933e7595838c28081810d4959ca1e005a0419e1 (diff) |
sna: Allow CPU bo to copy to GPU bo if the device is idle.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/kgem.h | 8 | ||||
-rw-r--r-- | 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)) { |