diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-07-17 15:33:19 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-07-17 17:29:21 +0100 |
commit | 067aeaddb8047f01ae3a20b26ba0acf5ba2d035f (patch) | |
tree | 98fc946c79739b32454af0edb10e38846ce12f90 | |
parent | 7ebeea3f5c71959773478de44b08a967fe5acc8b (diff) |
sna: Rebalance choice of GPU vs CPU bo
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_render.c | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index ae958782..cb40cd3e 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -301,6 +301,12 @@ use_cpu_bo(struct sna *sna, PixmapPtr pixmap, const BoxRec *box, bool blt) return NULL; } + if (priv->cpu_bo->vmap && priv->source_count > SOURCE_BIAS) { + DBG(("%s: promoting snooped CPU bo due to reuse\n", + __FUNCTION__)); + return NULL; + } + if (priv->gpu_bo) { switch (sna_damage_contains_box(priv->cpu_damage, box)) { case PIXMAN_REGION_OUT: @@ -321,54 +327,43 @@ use_cpu_bo(struct sna *sna, PixmapPtr pixmap, const BoxRec *box, bool blt) } break; } - - if (!blt && - priv->gpu_bo->tiling != I915_TILING_NONE && - (priv->cpu_bo->vmap || priv->cpu_bo->pitch >= 4096)) { - DBG(("%s: GPU bo exists and is tiled [%d], upload\n", - __FUNCTION__, priv->gpu_bo->tiling)); - return NULL; - } } - if (blt) { - if (priv->cpu_bo->vmap && priv->source_count++ > SOURCE_BIAS) { - DBG(("%s: promoting snooped CPU bo due to BLT reuse\n", - __FUNCTION__)); - return NULL; - } - } else { + if (!blt) { int w = box->x2 - box->x1; int h = box->y2 - box->y1; - if (priv->cpu_bo->pitch >= 4096) { - DBG(("%s: promoting snooped CPU bo due to TLB miss\n", - __FUNCTION__)); - return NULL; - } + if (w < pixmap->drawable.width || + h < pixmap->drawable.height || + priv->source_count != SOURCE_BIAS) { + bool want_tiling; - if (priv->cpu_bo->vmap && priv->source_count > SOURCE_BIAS) { - DBG(("%s: promoting snooped CPU bo due to reuse\n", - __FUNCTION__)); - return NULL; - } + if (priv->cpu_bo->pitch >= 4096) { + DBG(("%s: promoting snooped CPU bo due to TLB miss\n", + __FUNCTION__)); + return NULL; + } - if (priv->source_count*w*h >= (int)pixmap->drawable.width * pixmap->drawable.height && - I915_TILING_NONE != kgem_choose_tiling(&sna->kgem, - blt ? I915_TILING_X : I915_TILING_Y, - pixmap->drawable.width, - pixmap->drawable.height, - pixmap->drawable.bitsPerPixel)) { - DBG(("%s: pitch (%d) requires tiling\n", - __FUNCTION__, priv->cpu_bo->pitch)); - return NULL; + if (priv->gpu_bo) + want_tiling = priv->gpu_bo->tiling != I915_TILING_NONE; + else + want_tiling = kgem_choose_tiling(&sna->kgem, + I915_TILING_Y, + pixmap->drawable.width, + pixmap->drawable.height, + pixmap->drawable.bitsPerPixel) != I915_TILING_NONE; + if (want_tiling && + priv->source_count*w*h >= (int)pixmap->drawable.width * pixmap->drawable.height) { + DBG(("%s: pitch (%d) requires tiling\n", + __FUNCTION__, priv->cpu_bo->pitch)); + return NULL; + } } - - ++priv->source_count; } DBG(("%s for box=(%d, %d), (%d, %d)\n", __FUNCTION__, box->x1, box->y1, box->x2, box->y2)); + ++priv->source_count; return priv->cpu_bo; } |