summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-07-13 10:57:13 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-07-13 17:43:13 +0100
commit7a695c9f6b919eba8785d62094526762ba2a0449 (patch)
treeb9d7baf0957f1be0652387f0f2ef315d155a0e58 /src
parent0190964906ad878d469d6021c10cde4e7f5799c3 (diff)
sna: Fast-path single span boxes
These are very common when compositing unclipped trapezoids, and the majority of the overhead is in handling the arbitrary number of boxes and misses out on the constant folding the compiler can do if it is known we have just one box. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/sna/gen2_render.c23
-rw-r--r--src/sna/gen3_render.c23
-rw-r--r--src/sna/sna_render.h2
-rw-r--r--src/sna/sna_trapezoids.c2
4 files changed, 49 insertions, 1 deletions
diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c
index e6d6fe3f..021ce79c 100644
--- a/src/sna/gen2_render.c
+++ b/src/sna/gen2_render.c
@@ -1560,6 +1560,28 @@ static void gen2_emit_composite_spans_state(struct sna *sna,
}
static void
+gen2_render_composite_spans_box(struct sna *sna,
+ const struct sna_composite_spans_op *op,
+ const BoxRec *box, float opacity)
+{
+ DBG(("%s: nbox=%d, src=+(%d, %d), opacity=%f, dst=+(%d, %d), box=(%d, %d) x (%d, %d)\n",
+ __FUNCTION__,
+ op->base.src.offset[0], op->base.src.offset[1],
+ opacity,
+ op->base.dst.x, op->base.dst.y,
+ box->x1, box->y1,
+ box->x2 - box->x1,
+ box->y2 - box->y1));
+
+ if (gen2_get_rectangles(sna, &op->base, 1) == 0) {
+ gen2_emit_composite_spans_state(sna, op);
+ gen2_get_rectangles(sna, &op->base, 1);
+ }
+
+ op->prim_emit(sna, op, box, opacity);
+}
+
+static void
gen2_render_composite_spans_boxes(struct sna *sna,
const struct sna_composite_spans_op *op,
const BoxRec *box, int nbox,
@@ -1689,6 +1711,7 @@ gen2_render_composite_spans(struct sna *sna,
}
}
+ tmp->box = gen2_render_composite_spans_box;
tmp->boxes = gen2_render_composite_spans_boxes;
tmp->done = gen2_render_composite_spans_done;
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index fa72b91a..916f7d80 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -2561,6 +2561,28 @@ gen3_emit_composite_spans_primitive(struct sna *sna,
}
static void
+gen3_render_composite_spans_box(struct sna *sna,
+ const struct sna_composite_spans_op *op,
+ const BoxRec *box, float opacity)
+{
+ DBG(("%s: src=+(%d, %d), opacity=%f, dst=+(%d, %d), box=(%d, %d) x (%d, %d)\n",
+ __FUNCTION__,
+ op->base.src.offset[0], op->base.src.offset[1],
+ opacity,
+ op->base.dst.x, op->base.dst.y,
+ box->x1, box->y1,
+ box->x2 - box->x1,
+ box->y2 - box->y1));
+
+ if (gen3_get_rectangles(sna, &op->base, 1) == 0) {
+ gen3_emit_composite_state(sna, &op->base);
+ gen3_get_rectangles(sna, &op->base, 1);
+ }
+
+ op->prim_emit(sna, op, box, opacity);
+}
+
+static void
gen3_render_composite_spans_boxes(struct sna *sna,
const struct sna_composite_spans_op *op,
const BoxRec *box, int nbox,
@@ -2707,6 +2729,7 @@ gen3_render_composite_spans(struct sna *sna,
tmp->base.floats_per_vertex +=
tmp->base.mask.u.gen3.type == SHADER_OPACITY;
+ tmp->box = gen3_render_composite_spans_box;
tmp->boxes = gen3_render_composite_spans_boxes;
tmp->done = gen3_render_composite_spans_done;
diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h
index 8330395f..61881688 100644
--- a/src/sna/sna_render.h
+++ b/src/sna/sna_render.h
@@ -127,6 +127,8 @@ struct sna_composite_op {
struct sna_composite_spans_op {
struct sna_composite_op base;
+ void (*box)(struct sna *sna, const struct sna_composite_spans_op *op,
+ const BoxRec *box, float opacity);
void (*boxes)(struct sna *sna, const struct sna_composite_spans_op *op,
const BoxRec *box, int nbox,
float opacity);
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index c6645aa6..67cb3534 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -1253,7 +1253,7 @@ tor_blt_span(struct sna *sna,
{
DBG(("%s: %d -> %d @ %d\n", __FUNCTION__, box->x1, box->x2, coverage));
- op->boxes(sna, op, box, 1, AREA_TO_ALPHA(coverage));
+ op->box(sna, op, box, AREA_TO_ALPHA(coverage));
apply_damage_box(&op->base, box);
}