diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-09-02 09:55:07 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-09-02 09:53:55 +0100 |
commit | 62e7e69d88f7e5c8b0f0931fe887ee0c3bddb43f (patch) | |
tree | c864ad418944184195575309bdf20e31e30f057a | |
parent | f837807cc257fbedd35fa6101dc0b4a57e5ad78d (diff) |
sna: Tweak placement rules if we already have a CPU bo
If we have a CPU bo, consider if it may be quicker to render to it then
create a GPU bo.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_accel.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 7c598f10..bb7cda25 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2427,23 +2427,43 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box, goto use_cpu_bo; } - if (priv->cpu_bo && kgem_bo_is_busy(priv->cpu_bo)) { - DBG(("%s: already using CPU bo, will not force allocation\n", - __FUNCTION__)); - goto use_cpu_bo; - } + if ((flags & IGNORE_CPU) == 0) { + if (priv->cpu_bo) { + if (to_sna_from_pixmap(pixmap)->kgem.can_blt_cpu) { + if (kgem_bo_is_busy(priv->cpu_bo)) { + DBG(("%s: already using CPU bo, will not force allocation\n", + __FUNCTION__)); + goto use_cpu_bo; + } - if (priv->cpu_damage && flags == 0) { - DBG(("%s: prefer cpu", __FUNCTION__)); - goto use_cpu_bo; - } + if ((flags & RENDER_GPU) == 0) { + DBG(("%s: prefer cpu", __FUNCTION__)); + goto use_cpu_bo; + } + } else { + if (kgem_bo_is_busy(priv->cpu_bo)) { + DBG(("%s: CPU bo active, must force allocation\n", + __FUNCTION__)); + goto create_gpu_bo; + } + } + } - if (priv->cpu_damage && !box_inplace(pixmap, box)) { - DBG(("%s: damaged with a small operation, will not force allocation\n", - __FUNCTION__)); - goto use_cpu_bo; + if (priv->cpu_damage) { + if ((flags & (PREFER_GPU | FORCE_GPU)) == 0) { + DBG(("%s: prefer cpu", __FUNCTION__)); + goto use_cpu_bo; + } + + if (!box_inplace(pixmap, box)) { + DBG(("%s: damaged with a small operation, will not force allocation\n", + __FUNCTION__)); + goto use_cpu_bo; + } + } } +create_gpu_bo: move = MOVE_WRITE | MOVE_READ; if (flags & FORCE_GPU) move |= __MOVE_FORCE; |