summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-18 14:33:44 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-18 14:45:39 +0100
commited40a7c3de3bbb178278c05907e59239712b98b6 (patch)
treead52b3bfc1e624debfa2cfe9972ce47a0ad19874
parent4486ae2d829781e32652bce84c08e63ee1960bf0 (diff)
sna/gen6+: Tweak semaphore avoidance for composite operations
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen6_render.c43
-rw-r--r--src/sna/gen7_render.c37
-rw-r--r--src/sna/kgem.h8
-rw-r--r--src/sna/sna.h5
4 files changed, 72 insertions, 21 deletions
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 200406f5..4829f034 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1841,9 +1841,9 @@ gen6_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo (dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable,
+ PREFER_GPU | FORCE_GPU | RENDER_GPU,
+ &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -1896,8 +1896,8 @@ static inline bool untiled_tlb_miss(struct kgem_bo *bo)
static int prefer_blt_bo(struct sna *sna, struct kgem_bo *bo)
{
- if (bo->rq)
- return RQ_IS_BLT(bo->rq) ? 1 : -1;
+ if (RQ_IS_BLT(bo->rq))
+ return true;
return bo->tiling == I915_TILING_NONE || bo->scanout;
}
@@ -1914,6 +1914,15 @@ try_blt(struct sna *sna,
PicturePtr dst, PicturePtr src,
int width, int height)
{
+ struct kgem_bo *bo;
+
+ bo = __sna_drawable_peek_bo(dst->pDrawable);
+ if (bo == NULL)
+ return true;
+
+ if (bo->rq)
+ return RQ_IS_BLT(bo->rq);
+
if (sna->kgem.ring == KGEM_BLT) {
DBG(("%s: already performing BLT\n", __FUNCTION__));
return true;
@@ -2141,17 +2150,18 @@ reuse_source(struct sna *sna,
static bool
prefer_blt_composite(struct sna *sna, struct sna_composite_op *tmp)
{
- if (sna->kgem.ring == KGEM_BLT)
- return true;
-
if (untiled_tlb_miss(tmp->dst.bo) ||
untiled_tlb_miss(tmp->src.bo))
return true;
+ if (kgem_bo_is_render(tmp->dst.bo) ||
+ kgem_bo_is_render(tmp->src.bo))
+ return false;
+
if (!prefer_blt_ring(sna, tmp->dst.bo, 0))
return false;
- return (prefer_blt_bo(sna, tmp->dst.bo) | prefer_blt_bo(sna, tmp->src.bo)) > 0;
+ return prefer_blt_bo(sna, tmp->dst.bo) || prefer_blt_bo(sna, tmp->src.bo);
}
static bool
@@ -2609,11 +2619,14 @@ static inline bool prefer_blt_copy(struct sna *sna,
untiled_tlb_miss(dst_bo))
return true;
+ if (kgem_bo_is_render(dst_bo) ||
+ kgem_bo_is_render(src_bo))
+ return false;
+
if (!prefer_blt_ring(sna, dst_bo, flags))
return false;
- return (prefer_blt_bo(sna, src_bo) >= 0 &&
- prefer_blt_bo(sna, dst_bo) > 0);
+ return prefer_blt_bo(sna, src_bo) || prefer_blt_bo(sna, dst_bo);
}
inline static void boxes_extents(const BoxRec *box, int n, BoxRec *extents)
@@ -3021,10 +3034,16 @@ static inline bool prefer_blt_fill(struct sna *sna,
if (PREFER_RENDER)
return PREFER_RENDER < 0;
+ if (kgem_bo_is_render(bo))
+ return false;
+
if (untiled_tlb_miss(bo))
return true;
- return prefer_blt_ring(sna, bo, 0) || prefer_blt_bo(sna, bo) >= 0;
+ if (!prefer_blt_ring(sna, bo, 0))
+ return false;
+
+ return prefer_blt_bo(sna, bo);
}
static bool
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 5888a048..cd851f00 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -2130,8 +2130,8 @@ static inline bool untiled_tlb_miss(struct kgem_bo *bo)
static int prefer_blt_bo(struct sna *sna, struct kgem_bo *bo)
{
- if (bo->rq)
- return RQ_IS_BLT(bo->rq) ? 1 : -1;
+ if (RQ_IS_BLT(bo->rq))
+ return true;
return bo->tiling == I915_TILING_NONE || (bo->scanout && !sna->kgem.has_wt);
}
@@ -2148,6 +2148,15 @@ try_blt(struct sna *sna,
PicturePtr dst, PicturePtr src,
int width, int height)
{
+ struct kgem_bo *bo;
+
+ bo = __sna_drawable_peek_bo(dst->pDrawable);
+ if (bo == NULL)
+ return true;
+
+ if (bo->rq)
+ return RQ_IS_BLT(bo->rq);
+
if (sna->kgem.ring == KGEM_BLT) {
DBG(("%s: already performing BLT\n", __FUNCTION__));
return true;
@@ -2375,17 +2384,18 @@ reuse_source(struct sna *sna,
static bool
prefer_blt_composite(struct sna *sna, struct sna_composite_op *tmp)
{
- if (sna->kgem.mode == KGEM_BLT)
- return true;
-
if (untiled_tlb_miss(tmp->dst.bo) ||
untiled_tlb_miss(tmp->src.bo))
return true;
+ if (kgem_bo_is_render(tmp->dst.bo) ||
+ kgem_bo_is_render(tmp->src.bo))
+ return false;
+
if (!prefer_blt_ring(sna, tmp->dst.bo, 0))
return false;
- return (prefer_blt_bo(sna, tmp->dst.bo) | prefer_blt_bo(sna, tmp->src.bo)) > 0;
+ return prefer_blt_bo(sna, tmp->dst.bo) || prefer_blt_bo(sna, tmp->src.bo);
}
static bool
@@ -2819,11 +2829,14 @@ static inline bool prefer_blt_copy(struct sna *sna,
untiled_tlb_miss(dst_bo))
return true;
+ if (kgem_bo_is_render(dst_bo) ||
+ kgem_bo_is_render(src_bo))
+ return false;
+
if (!prefer_blt_ring(sna, dst_bo, flags))
return false;
- return (prefer_blt_bo(sna, src_bo) >= 0 &&
- prefer_blt_bo(sna, dst_bo) > 0);
+ return prefer_blt_bo(sna, src_bo) || prefer_blt_bo(sna, dst_bo);
}
inline static void boxes_extents(const BoxRec *box, int n, BoxRec *extents)
@@ -3219,10 +3232,16 @@ gen7_emit_fill_state(struct sna *sna, const struct sna_composite_op *op)
static inline bool prefer_blt_fill(struct sna *sna,
struct kgem_bo *bo)
{
+ if (kgem_bo_is_render(bo))
+ return false;
+
if (untiled_tlb_miss(bo))
return true;
- return prefer_blt_ring(sna, bo, 0) || prefer_blt_bo(sna, bo) >= 0;
+ if (!prefer_blt_ring(sna, bo, 0))
+ return false;
+
+ return prefer_blt_bo(sna, bo);
}
static bool
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 63bba4cb..49f0eecf 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -645,6 +645,14 @@ static inline bool __kgem_bo_is_busy(struct kgem *kgem, struct kgem_bo *bo)
return kgem_bo_is_busy(bo);
}
+static inline bool kgem_bo_is_render(struct kgem_bo *bo)
+{
+ DBG(("%s: handle=%d, rq? %d [%d]\n", __FUNCTION__,
+ bo->handle, bo->rq != NULL, RQ_RING(bo->rq)));
+ assert(bo->refcnt);
+ return bo->rq && RQ_RING(bo->rq) == I915_EXEC_RENDER;
+}
+
static inline void kgem_bo_mark_unreusable(struct kgem_bo *bo)
{
while (bo->proxy) {
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 14b3c145..f4722d17 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -617,6 +617,11 @@ static inline struct kgem_bo *__sna_pixmap_get_bo(PixmapPtr pixmap)
return sna_pixmap(pixmap)->gpu_bo;
}
+static inline struct kgem_bo *__sna_drawable_peek_bo(DrawablePtr d)
+{
+ return sna_pixmap(get_drawable_pixmap(d))->gpu_bo;
+}
+
static inline struct kgem_bo *sna_pixmap_pin(PixmapPtr pixmap, unsigned flags)
{
struct sna_pixmap *priv;