xf86-video-intel: 5 commits - src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/sna_render.h src/sna/sna_tiling.c
Chris Wilson
ickle at kemper.freedesktop.org
Thu Feb 23 10:19:40 PST 2012
src/sna/gen3_render.c | 8 +--
src/sna/gen4_render.c | 54 ++++++++---------------
src/sna/gen5_render.c | 115 ++++++++++++++++++--------------------------------
src/sna/gen6_render.c | 112 ++++++++++++++++--------------------------------
src/sna/gen7_render.c | 113 ++++++++++++++++++-------------------------------
src/sna/sna_render.h | 4 -
src/sna/sna_tiling.c | 10 ++--
7 files changed, 154 insertions(+), 262 deletions(-)
New commits:
commit a647aff5124674b638ef52152a5c16c27466eed7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Feb 23 12:04:09 2012 +0000
sna/gen3: Silence the compiler complaining with DBG enabled
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index 6828a16..b50d067 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -1732,7 +1732,7 @@ inline static int gen3_get_rectangles(struct sna *sna,
int rem;
DBG(("%s: want=%d, rem=%d\n",
- __FUNCTION__, want*op->floats_per_rect, rem));
+ __FUNCTION__, want*op->floats_per_rect, vertex_space(sna)));
assert(sna->render.vertex_index * op->floats_per_vertex == sna->render.vertex_used);
@@ -1742,12 +1742,12 @@ start:
DBG(("flushing vbo for %s: %d < %d\n",
__FUNCTION__, rem, op->floats_per_rect));
rem = gen3_get_rectangles__flush(sna, op);
- if (rem == 0)
+ if (unlikely(rem == 0))
goto flush;
}
- if (sna->render_state.gen3.vertex_offset == 0 &&
- !gen3_rectangle_begin(sna, op))
+ if (unlikely(sna->render_state.gen3.vertex_offset == 0 &&
+ !gen3_rectangle_begin(sna, op)))
goto flush;
if (want > 1 && want * op->floats_per_rect > rem)
commit cd3a618f583a546bafbe0c171a267774adc4d72b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Feb 23 10:40:57 2012 +0000
sna/gen4 Refactor get_rectangles() to re-emit state after a flush
Condense the work performed by each caller into the callee.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index cccdf4c..6ba59ee 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1116,19 +1116,12 @@ static bool gen4_rectangle_begin(struct sna *sna,
int id = op->u.gen4.ve_id;
int ndwords;
- ndwords = 0;
+ /* 7xpipelined pointers + 6xprimitive + 1xflush */
+ ndwords = op->need_magic_ca_pass? 20 : 6;
if (FLUSH_EVERY_VERTEX)
ndwords += 1;
if ((sna->render_state.gen4.vb_id & (1 << id)) == 0)
ndwords += 5;
- if (sna->render_state.gen4.vertex_offset == 0)
- ndwords += 6;
- if (ndwords == 0)
- return true;
-
- if (op->need_magic_ca_pass)
- /* 7xpipelined pointers + 6xprimitive + 1xflush */
- ndwords += 14;
if (!kgem_check_batch(&sna->kgem, ndwords))
return false;
@@ -1159,19 +1152,23 @@ static int gen4_get_rectangles__flush(struct sna *sna,
inline static int gen4_get_rectangles(struct sna *sna,
const struct sna_composite_op *op,
- int want)
+ int want,
+ void (*emit_state)(struct sna *sna, const struct sna_composite_op *op))
{
- int rem = vertex_space(sna);
+ int rem;
+start:
+ rem = vertex_space(sna);
if (rem < 3*op->floats_per_vertex) {
DBG(("flushing vbo for %s: %d < %d\n",
__FUNCTION__, rem, 3*op->floats_per_vertex));
rem = gen4_get_rectangles__flush(sna, op);
- if (rem == 0)
+ if (unlikely(rem == 0))
goto flush;
}
- if (!gen4_rectangle_begin(sna, op))
+ if (unlikely(sna->render_state.gen4.vertex_offset == 0 &&
+ !gen4_rectangle_begin(sna, op)))
goto flush;
if (want > 1 && want * op->floats_per_vertex*3 > rem)
@@ -1186,7 +1183,8 @@ flush:
gen4_magic_ca_pass(sna, op);
}
_kgem_submit(&sna->kgem);
- return 0;
+ emit_state(sna, op);
+ goto start;
}
static uint32_t *gen4_composite_get_binding_table(struct sna *sna,
@@ -1541,11 +1539,7 @@ gen4_render_composite_blt(struct sna *sna,
gen4_bind_surfaces(sna, op);
}
- if (!gen4_get_rectangles(sna, op, 1)) {
- gen4_bind_surfaces(sna, op);
- gen4_get_rectangles(sna, op, 1);
- }
-
+ gen4_get_rectangles(sna, op, 1, gen4_bind_surfaces);
op->prim_emit(sna, op, r);
/* XXX are the shaders fubar? */
@@ -1629,9 +1623,9 @@ static uint32_t gen4_bind_video_source(struct sna *sna,
}
static void gen4_video_bind_surfaces(struct sna *sna,
- const struct sna_composite_op *op,
- struct sna_video_frame *frame)
+ const struct sna_composite_op *op)
{
+ struct sna_video_frame *frame = op->priv;
uint32_t src_surf_format;
uint32_t src_surf_base[6];
int src_width[6];
@@ -1732,13 +1726,14 @@ gen4_render_video(struct sna *sna,
tmp.is_affine = TRUE;
tmp.floats_per_vertex = 3;
tmp.u.gen4.ve_id = 1;
+ tmp.priv = frame;
if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)) {
kgem_submit(&sna->kgem);
assert(kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL));
}
- gen4_video_bind_surfaces(sna, &tmp, frame);
+ gen4_video_bind_surfaces(sna, &tmp);
gen4_align_vertex(sna, &tmp);
/* Set up the offset for translating from the given region (in screen
@@ -1769,10 +1764,7 @@ gen4_render_video(struct sna *sna,
r.y1 = box->y1 + pix_yoff;
r.y2 = box->y2 + pix_yoff;
- if (!gen4_get_rectangles(sna, &tmp, 1)) {
- gen4_video_bind_surfaces(sna, &tmp, frame);
- gen4_get_rectangles(sna, &tmp, 1);
- }
+ gen4_get_rectangles(sna, &tmp, 1, gen4_video_bind_surfaces);
OUT_VERTEX(r.x2, r.y2);
OUT_VERTEX_F((box->x2 - dxo) * src_scale_x);
@@ -2393,10 +2385,7 @@ gen4_render_copy_one(struct sna *sna,
int w, int h,
int dx, int dy)
{
- if (!gen4_get_rectangles(sna, op, 1)) {
- gen4_copy_bind_surfaces(sna, op);
- gen4_get_rectangles(sna, op, 1);
- }
+ gen4_get_rectangles(sna, op, 1, gen4_copy_bind_surfaces);
OUT_VERTEX(dx+w, dy+h);
OUT_VERTEX_F((sx+w)*op->src.scale[0]);
@@ -2725,10 +2714,7 @@ gen4_render_fill_rectangle(struct sna *sna,
const struct sna_composite_op *op,
int x, int y, int w, int h)
{
- if (!gen4_get_rectangles(sna, op, 1)) {
- gen4_fill_bind_surfaces(sna, op);
- gen4_get_rectangles(sna, op, 1);
- }
+ gen4_get_rectangles(sna, op, 1, gen4_fill_bind_surfaces);
OUT_VERTEX(x+w, y+h);
OUT_VERTEX_F(1);
commit 6a3fa4d1b6849b666a9232b017ce82329494621b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Feb 23 10:40:57 2012 +0000
sna/gen7 Refactor get_rectangles() to re-emit state after a flush
Condense the work performed by each caller into the callee.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index d039a48..0d913f6 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -1664,20 +1664,23 @@ static int gen7_get_rectangles__flush(struct sna *sna,
inline static int gen7_get_rectangles(struct sna *sna,
const struct sna_composite_op *op,
- int want)
+ int want,
+ void (*emit_state)(struct sna *sna, const struct sna_composite_op *op))
{
int rem = vertex_space(sna);
+start:
+ rem = vertex_space(sna);
if (rem < op->floats_per_rect) {
DBG(("flushing vbo for %s: %d < %d\n",
__FUNCTION__, rem, op->floats_per_rect));
rem = gen7_get_rectangles__flush(sna, op);
- if (rem == 0)
+ if (unlikely(rem == 0))
goto flush;
}
- if (sna->render_state.gen7.vertex_offset == 0 &&
- !gen7_rectangle_begin(sna, op))
+ if (unlikely(sna->render_state.gen7.vertex_offset == 0 &&
+ !gen7_rectangle_begin(sna, op)))
goto flush;
if (want > 1 && want * op->floats_per_rect > rem)
@@ -1692,7 +1695,8 @@ flush:
gen7_magic_ca_pass(sna, op);
}
_kgem_submit(&sna->kgem);
- return 0;
+ emit_state(sna, op);
+ goto start;
}
inline static uint32_t *gen7_composite_get_binding_table(struct sna *sna,
@@ -1801,11 +1805,7 @@ gen7_render_composite_blt(struct sna *sna,
const struct sna_composite_op *op,
const struct sna_composite_rectangles *r)
{
- if (unlikely(!gen7_get_rectangles(sna, op, 1))) {
- gen7_emit_composite_state(sna, op);
- gen7_get_rectangles(sna, op, 1);
- }
-
+ gen7_get_rectangles(sna, op, 1, gen7_emit_composite_state);
op->prim_emit(sna, op, r);
}
@@ -1816,10 +1816,7 @@ gen7_render_composite_box(struct sna *sna,
{
struct sna_composite_rectangles r;
- if (unlikely(!gen7_get_rectangles(sna, op, 1))) {
- gen7_emit_composite_state(sna, op);
- gen7_get_rectangles(sna, op, 1);
- }
+ gen7_get_rectangles(sna, op, 1, gen7_emit_composite_state);
DBG((" %s: (%d, %d), (%d, %d)\n",
__FUNCTION__,
@@ -1842,12 +1839,12 @@ gen7_render_composite_boxes(struct sna *sna,
DBG(("composite_boxes(%d)\n", nbox));
do {
- int nbox_this_time = gen7_get_rectangles(sna, op, nbox);
- if (unlikely(nbox_this_time == 0)) {
- gen7_emit_composite_state(sna, op);
- nbox_this_time = gen7_get_rectangles(sna, op, nbox);
- }
+ int nbox_this_time;
+
+ nbox_this_time = gen7_get_rectangles(sna, op, nbox,
+ gen7_emit_composite_state);
nbox -= nbox_this_time;
+
do {
struct sna_composite_rectangles r;
@@ -1934,9 +1931,9 @@ static uint32_t gen7_bind_video_source(struct sna *sna,
}
static void gen7_emit_video_state(struct sna *sna,
- struct sna_composite_op *op,
- struct sna_video_frame *frame)
+ const struct sna_composite_op *op)
{
+ struct sna_video_frame *frame = op->priv;
uint32_t src_surf_format;
uint32_t src_surf_base[6];
int src_width[6];
@@ -2055,6 +2052,7 @@ gen7_render_video(struct sna *sna,
}
tmp.u.gen7.nr_inputs = 1;
tmp.u.gen7.ve_id = 1;
+ tmp.priv = frame;
kgem_set_mode(&sna->kgem, KGEM_RENDER);
if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)) {
@@ -2063,7 +2061,7 @@ gen7_render_video(struct sna *sna,
_kgem_set_mode(&sna->kgem, KGEM_RENDER);
}
- gen7_emit_video_state(sna, &tmp, frame);
+ gen7_emit_video_state(sna, &tmp);
gen7_align_vertex(sna, &tmp);
/* Set up the offset for translating from the given region (in screen
@@ -2094,10 +2092,7 @@ gen7_render_video(struct sna *sna,
r.y1 = box->y1 + pix_yoff;
r.y2 = box->y2 + pix_yoff;
- if (unlikely(!gen7_get_rectangles(sna, &tmp, 1))) {
- gen7_emit_video_state(sna, &tmp, frame);
- gen7_get_rectangles(sna, &tmp, 1);
- }
+ gen7_get_rectangles(sna, &tmp, 1, gen7_emit_video_state);
OUT_VERTEX(r.x2, r.y2);
OUT_VERTEX_F((box->x2 - dxo) * src_scale_x);
@@ -2941,11 +2936,7 @@ gen7_render_composite_spans_box(struct sna *sna,
box->x2 - box->x1,
box->y2 - box->y1));
- if (unlikely(gen7_get_rectangles(sna, &op->base, 1) == 0)) {
- gen7_emit_composite_state(sna, &op->base);
- gen7_get_rectangles(sna, &op->base, 1);
- }
-
+ gen7_get_rectangles(sna, &op->base, 1, gen7_emit_composite_state);
op->prim_emit(sna, op, box, opacity);
}
@@ -2964,11 +2955,8 @@ gen7_render_composite_spans_boxes(struct sna *sna,
do {
int nbox_this_time;
- nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox);
- if (unlikely(nbox_this_time == 0)) {
- gen7_emit_composite_state(sna, &op->base);
- nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox);
- }
+ nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox,
+ gen7_emit_composite_state);
nbox -= nbox_this_time;
do {
@@ -3356,11 +3344,10 @@ fallback_blt:
do {
float *v;
- int n_this_time = gen7_get_rectangles(sna, &tmp, n);
- if (unlikely(n_this_time == 0)) {
- gen7_emit_copy_state(sna, &tmp);
- n_this_time = gen7_get_rectangles(sna, &tmp, n);
- }
+ int n_this_time;
+
+ n_this_time = gen7_get_rectangles(sna, &tmp, n,
+ gen7_emit_copy_state);
n -= n_this_time;
v = sna->render.vertices + sna->render.vertex_used;
@@ -3410,10 +3397,7 @@ gen7_render_copy_blt(struct sna *sna,
int16_t w, int16_t h,
int16_t dx, int16_t dy)
{
- if (unlikely(!gen7_get_rectangles(sna, &op->base, 1))) {
- gen7_emit_copy_state(sna, &op->base);
- gen7_get_rectangles(sna, &op->base, 1);
- }
+ gen7_get_rectangles(sna, &op->base, 1, gen7_emit_copy_state);
OUT_VERTEX(dx+w, dy+h);
OUT_VERTEX_F((sx+w)*op->base.src.scale[0]);
@@ -3680,12 +3664,12 @@ gen7_render_fill_boxes(struct sna *sna,
gen7_align_vertex(sna, &tmp);
do {
- int n_this_time = gen7_get_rectangles(sna, &tmp, n);
- if (unlikely(n_this_time == 0)) {
- gen7_emit_fill_state(sna, &tmp);
- n_this_time = gen7_get_rectangles(sna, &tmp, n);
- }
+ int n_this_time;
+
+ n_this_time = gen7_get_rectangles(sna, &tmp, n,
+ gen7_emit_fill_state);
n -= n_this_time;
+
do {
DBG((" (%d, %d), (%d, %d)\n",
box->x1, box->y1, box->x2, box->y2));
@@ -3717,10 +3701,7 @@ gen7_render_fill_op_blt(struct sna *sna,
{
DBG(("%s: (%d, %d)x(%d, %d)\n", __FUNCTION__, x, y, w, h));
- if (unlikely(!gen7_get_rectangles(sna, &op->base, 1))) {
- gen7_emit_fill_state(sna, &op->base);
- gen7_get_rectangles(sna, &op->base, 1);
- }
+ gen7_get_rectangles(sna, &op->base, 1, gen7_emit_fill_state);
OUT_VERTEX(x+w, y+h);
OUT_VERTEX_F(1);
@@ -3743,10 +3724,7 @@ gen7_render_fill_op_box(struct sna *sna,
DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__,
box->x1, box->y1, box->x2, box->y2));
- if (unlikely(!gen7_get_rectangles(sna, &op->base, 1))) {
- gen7_emit_fill_state(sna, &op->base);
- gen7_get_rectangles(sna, &op->base, 1);
- }
+ gen7_get_rectangles(sna, &op->base, 1, gen7_emit_fill_state);
OUT_VERTEX(box->x2, box->y2);
OUT_VERTEX_F(1);
@@ -3771,11 +3749,10 @@ gen7_render_fill_op_boxes(struct sna *sna,
box->x1, box->y1, box->x2, box->y2, nbox));
do {
- int nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox);
- if (unlikely(nbox_this_time == 0)) {
- gen7_emit_fill_state(sna, &op->base);
- nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox);
- }
+ int nbox_this_time;
+
+ nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox,
+ gen7_emit_fill_state);
nbox -= nbox_this_time;
do {
@@ -3967,10 +3944,7 @@ gen7_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
gen7_emit_fill_state(sna, &tmp);
gen7_align_vertex(sna, &tmp);
- if (unlikely(!gen7_get_rectangles(sna, &tmp, 1))) {
- gen7_emit_fill_state(sna, &tmp);
- gen7_get_rectangles(sna, &tmp, 1);
- }
+ gen7_get_rectangles(sna, &tmp, 1, gen7_emit_fill_state);
DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2));
OUT_VERTEX(x2, y2);
@@ -4065,10 +4039,7 @@ gen7_render_clear(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo)
gen7_emit_fill_state(sna, &tmp);
gen7_align_vertex(sna, &tmp);
- if (unlikely(!gen7_get_rectangles(sna, &tmp, 1))) {
- gen7_emit_fill_state(sna, &tmp);
- gen7_get_rectangles(sna, &tmp, 1);
- }
+ gen7_get_rectangles(sna, &tmp, 1, gen7_emit_fill_state);
OUT_VERTEX(dst->drawable.width, dst->drawable.height);
OUT_VERTEX_F(1);
commit fe914eaca4b9178ab3d14053a703772f93295895
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Feb 23 10:40:57 2012 +0000
sna/gen5 Refactor get_rectangles() to re-emit state after a flush
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 8d6a3e9..a80ce0a 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1130,13 +1130,9 @@ static bool gen5_rectangle_begin(struct sna *sna,
assert((unsigned)id <= 3);
- ndwords = 0;
+ ndwords = op->need_magic_ca_pass ? 20 : 6;
if ((sna->render_state.gen5.vb_id & (1 << id)) == 0)
ndwords += 5;
- if (sna->render_state.gen5.vertex_offset == 0)
- ndwords += op->need_magic_ca_pass ? 20 : 6;
- if (ndwords == 0)
- return true;
if (!kgem_check_batch(&sna->kgem, ndwords))
return false;
@@ -1167,19 +1163,24 @@ static int gen5_get_rectangles__flush(struct sna *sna,
inline static int gen5_get_rectangles(struct sna *sna,
const struct sna_composite_op *op,
- int want)
+ int want,
+ void (*emit_state)(struct sna *sna,
+ const struct sna_composite_op *op))
{
- int rem = vertex_space(sna);
+ int rem;
+start:
+ rem = vertex_space(sna);
if (rem < op->floats_per_rect) {
DBG(("flushing vbo for %s: %d < %d\n",
__FUNCTION__, rem, op->floats_per_rect));
rem = gen5_get_rectangles__flush(sna, op);
- if (rem == 0)
+ if (unlikely (rem == 0))
goto flush;
}
- if (!gen5_rectangle_begin(sna, op))
+ if (unlikely(sna->render_state.gen5.vertex_offset == 0 &&
+ !gen5_rectangle_begin(sna, op)))
goto flush;
if (want * op->floats_per_rect > rem)
@@ -1194,7 +1195,8 @@ flush:
gen5_magic_ca_pass(sna, op);
}
_kgem_submit(&sna->kgem);
- return 0;
+ emit_state(sna, op);
+ goto start;
}
static uint32_t *
@@ -1562,11 +1564,7 @@ gen5_render_composite_blt(struct sna *sna,
r->dst.x, r->dst.y, op->dst.x, op->dst.y,
r->width, r->height));
- if (!gen5_get_rectangles(sna, op, 1)) {
- gen5_bind_surfaces(sna, op);
- gen5_get_rectangles(sna, op, 1);
- }
-
+ gen5_get_rectangles(sna, op, 1, gen5_bind_surfaces);
op->prim_emit(sna, op, r);
}
@@ -1581,10 +1579,7 @@ gen5_render_composite_box(struct sna *sna,
__FUNCTION__,
box->x1, box->y1, box->x2, box->y2));
- if (!gen5_get_rectangles(sna, op, 1)) {
- gen5_bind_surfaces(sna, op);
- gen5_get_rectangles(sna, op, 1);
- }
+ gen5_get_rectangles(sna, op, 1, gen5_bind_surfaces);
r.dst.x = box->x1;
r.dst.y = box->y1;
@@ -1608,11 +1603,10 @@ gen5_render_composite_boxes(struct sna *sna,
op->mask.width, op->mask.height));
do {
- int nbox_this_time = gen5_get_rectangles(sna, op, nbox);
- if (nbox_this_time == 0) {
- gen5_bind_surfaces(sna, op);
- nbox_this_time = gen5_get_rectangles(sna, op, nbox);
- }
+ int nbox_this_time;
+
+ nbox_this_time = gen5_get_rectangles(sna, op, nbox,
+ gen5_bind_surfaces);
nbox -= nbox_this_time;
do {
@@ -1669,9 +1663,9 @@ static uint32_t gen5_bind_video_source(struct sna *sna,
}
static void gen5_video_bind_surfaces(struct sna *sna,
- struct sna_composite_op *op,
- struct sna_video_frame *frame)
+ const struct sna_composite_op *op)
{
+ struct sna_video_frame *frame = op->priv;
uint32_t src_surf_format;
uint32_t src_surf_base[6];
int src_width[6];
@@ -1775,13 +1769,14 @@ gen5_render_video(struct sna *sna,
tmp.is_affine = TRUE;
tmp.floats_per_vertex = 3;
tmp.floats_per_rect = 9;
+ tmp.priv = frame;
if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)) {
kgem_submit(&sna->kgem);
assert(kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL));
}
- gen5_video_bind_surfaces(sna, &tmp, frame);
+ gen5_video_bind_surfaces(sna, &tmp);
gen5_align_vertex(sna, &tmp);
/* Set up the offset for translating from the given region (in screen
@@ -1812,10 +1807,7 @@ gen5_render_video(struct sna *sna,
r.y1 = box->y1 + pix_yoff;
r.y2 = box->y2 + pix_yoff;
- if (!gen5_get_rectangles(sna, &tmp, 1)) {
- gen5_video_bind_surfaces(sna, &tmp, frame);
- gen5_get_rectangles(sna, &tmp, 1);
- }
+ gen5_get_rectangles(sna, &tmp, 1, gen5_video_bind_surfaces);
OUT_VERTEX(r.x2, r.y2);
OUT_VERTEX_F((box->x2 - dxo) * src_scale_x);
@@ -2549,11 +2541,7 @@ gen5_render_composite_spans_box(struct sna *sna,
box->x2 - box->x1,
box->y2 - box->y1));
- if (gen5_get_rectangles(sna, &op->base, 1) == 0) {
- gen5_bind_surfaces(sna, &op->base);
- gen5_get_rectangles(sna, &op->base, 1);
- }
-
+ gen5_get_rectangles(sna, &op->base, 1, gen5_bind_surfaces);
op->prim_emit(sna, op, box, opacity);
}
@@ -2572,11 +2560,8 @@ gen5_render_composite_spans_boxes(struct sna *sna,
do {
int nbox_this_time;
- nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox);
- if (nbox_this_time == 0) {
- gen5_bind_surfaces(sna, &op->base);
- nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox);
- }
+ nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox,
+ gen5_bind_surfaces);
nbox -= nbox_this_time;
do {
@@ -2871,11 +2856,10 @@ fallback_blt:
gen5_align_vertex(sna, &tmp);
do {
- int n_this_time = gen5_get_rectangles(sna, &tmp, n);
- if (n_this_time == 0) {
- gen5_copy_bind_surfaces(sna, &tmp);
- n_this_time = gen5_get_rectangles(sna, &tmp, n);
- }
+ int n_this_time;
+
+ n_this_time = gen5_get_rectangles(sna, &tmp, n,
+ gen5_copy_bind_surfaces);
n -= n_this_time;
do {
@@ -2926,10 +2910,7 @@ gen5_render_copy_blt(struct sna *sna,
DBG(("%s: src=(%d, %d), dst=(%d, %d), size=(%d, %d)\n", __FUNCTION__,
sx, sy, dx, dy, w, h));
- if (!gen5_get_rectangles(sna, &op->base, 1)) {
- gen5_copy_bind_surfaces(sna, &op->base);
- gen5_get_rectangles(sna, &op->base, 1);
- }
+ gen5_get_rectangles(sna, &op->base, 1, gen5_copy_bind_surfaces);
OUT_VERTEX(dx+w, dy+h);
OUT_VERTEX_F((sx+w)*op->base.src.scale[0]);
@@ -3173,12 +3154,12 @@ gen5_render_fill_boxes(struct sna *sna,
gen5_align_vertex(sna, &tmp);
do {
- int n_this_time = gen5_get_rectangles(sna, &tmp, n);
- if (n_this_time == 0) {
- gen5_fill_bind_surfaces(sna, &tmp);
- n_this_time = gen5_get_rectangles(sna, &tmp, n);
- }
+ int n_this_time;
+
+ n_this_time = gen5_get_rectangles(sna, &tmp, n,
+ gen5_fill_bind_surfaces);
n -= n_this_time;
+
do {
DBG((" (%d, %d), (%d, %d)\n",
box->x1, box->y1, box->x2, box->y2));
@@ -3210,10 +3191,7 @@ gen5_render_fill_op_blt(struct sna *sna,
{
DBG(("%s (%d, %d)x(%d, %d)\n", __FUNCTION__, x,y,w,h));
- if (!gen5_get_rectangles(sna, &op->base, 1)) {
- gen5_fill_bind_surfaces(sna, &op->base);
- gen5_get_rectangles(sna, &op->base, 1);
- }
+ gen5_get_rectangles(sna, &op->base, 1, gen5_fill_bind_surfaces);
OUT_VERTEX(x+w, y+h);
OUT_VERTEX_F(1);
@@ -3236,10 +3214,7 @@ gen5_render_fill_op_box(struct sna *sna,
DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__,
box->x1, box->y1, box->x2, box->y2));
- if (!gen5_get_rectangles(sna, &op->base, 1)) {
- gen5_fill_bind_surfaces(sna, &op->base);
- gen5_get_rectangles(sna, &op->base, 1);
- }
+ gen5_get_rectangles(sna, &op->base, 1, gen5_fill_bind_surfaces);
OUT_VERTEX(box->x2, box->y2);
OUT_VERTEX_F(1);
@@ -3264,11 +3239,10 @@ gen5_render_fill_op_boxes(struct sna *sna,
box->x1, box->y1, box->x2, box->y2, nbox));
do {
- int nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox);
- if (nbox_this_time == 0) {
- gen5_fill_bind_surfaces(sna, &op->base);
- nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox);
- }
+ int nbox_this_time;
+
+ nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox,
+ gen5_fill_bind_surfaces);
nbox -= nbox_this_time;
do {
@@ -3452,10 +3426,7 @@ gen5_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
gen5_fill_bind_surfaces(sna, &tmp);
gen5_align_vertex(sna, &tmp);
- if (!gen5_get_rectangles(sna, &tmp, 1)) {
- gen5_fill_bind_surfaces(sna, &tmp);
- gen5_get_rectangles(sna, &tmp, 1);
- }
+ gen5_get_rectangles(sna, &tmp, 1, gen5_fill_bind_surfaces);
DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2));
OUT_VERTEX(x2, y2);
commit 4ecf882c838c1f044b4ed3add486b6579ea2c431
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Feb 23 10:40:57 2012 +0000
sna/gen6: Refactor get_rectangles() to re-emit state after a flush
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index e975328..b69b3a2 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1630,20 +1630,23 @@ static int gen6_get_rectangles__flush(struct sna *sna,
inline static int gen6_get_rectangles(struct sna *sna,
const struct sna_composite_op *op,
- int want)
+ int want,
+ void (*emit_state)(struct sna *, const struct sna_composite_op *op))
{
- int rem = vertex_space(sna);
+ int rem;
+start:
+ rem = vertex_space(sna);
if (rem < op->floats_per_rect) {
DBG(("flushing vbo for %s: %d < %d\n",
__FUNCTION__, rem, op->floats_per_rect));
rem = gen6_get_rectangles__flush(sna, op);
- if (rem == 0)
+ if (unlikely(rem == 0))
goto flush;
}
- if (sna->render_state.gen6.vertex_offset == 0 &&
- !gen6_rectangle_begin(sna, op))
+ if (unlikely(sna->render_state.gen6.vertex_offset == 0 &&
+ !gen6_rectangle_begin(sna, op)))
goto flush;
if (want > 1 && want * op->floats_per_rect > rem)
@@ -1659,7 +1662,8 @@ flush:
gen6_magic_ca_pass(sna, op);
}
_kgem_submit(&sna->kgem);
- return 0;
+ emit_state(sna, op);
+ goto start;
}
inline static uint32_t *gen6_composite_get_binding_table(struct sna *sna,
@@ -1772,11 +1776,7 @@ gen6_render_composite_blt(struct sna *sna,
const struct sna_composite_op *op,
const struct sna_composite_rectangles *r)
{
- if (unlikely(!gen6_get_rectangles(sna, op, 1))) {
- gen6_emit_composite_state(sna, op);
- gen6_get_rectangles(sna, op, 1);
- }
-
+ gen6_get_rectangles(sna, op, 1, gen6_emit_composite_state);
op->prim_emit(sna, op, r);
}
@@ -1787,10 +1787,7 @@ gen6_render_composite_box(struct sna *sna,
{
struct sna_composite_rectangles r;
- if (unlikely(!gen6_get_rectangles(sna, op, 1))) {
- gen6_emit_composite_state(sna, op);
- gen6_get_rectangles(sna, op, 1);
- }
+ gen6_get_rectangles(sna, op, 1, gen6_emit_composite_state);
DBG((" %s: (%d, %d), (%d, %d)\n",
__FUNCTION__,
@@ -1813,13 +1810,12 @@ gen6_render_composite_boxes(struct sna *sna,
DBG(("composite_boxes(%d)\n", nbox));
do {
- int nbox_this_time = gen6_get_rectangles(sna, op, nbox);
- if (unlikely(nbox_this_time == 0)) {
- gen6_emit_composite_state(sna, op);
- nbox_this_time = gen6_get_rectangles(sna, op, nbox);
- assert(nbox_this_time);
- }
+ int nbox_this_time;
+
+ nbox_this_time = gen6_get_rectangles(sna, op, nbox,
+ gen6_emit_composite_state);
nbox -= nbox_this_time;
+
do {
struct sna_composite_rectangles r;
@@ -1906,9 +1902,9 @@ static uint32_t gen6_bind_video_source(struct sna *sna,
}
static void gen6_emit_video_state(struct sna *sna,
- struct sna_composite_op *op,
- struct sna_video_frame *frame)
+ const struct sna_composite_op *op)
{
+ struct sna_video_frame *frame = op->priv;
uint32_t src_surf_format;
uint32_t src_surf_base[6];
int src_width[6];
@@ -2029,6 +2025,7 @@ gen6_render_video(struct sna *sna,
}
tmp.u.gen6.nr_inputs = 1;
tmp.u.gen6.ve_id = 1;
+ tmp.priv = frame;
kgem_set_mode(&sna->kgem, KGEM_RENDER);
if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)) {
@@ -2037,7 +2034,7 @@ gen6_render_video(struct sna *sna,
_kgem_set_mode(&sna->kgem, KGEM_RENDER);
}
- gen6_emit_video_state(sna, &tmp, frame);
+ gen6_emit_video_state(sna, &tmp);
gen6_align_vertex(sna, &tmp);
/* Set up the offset for translating from the given region (in screen
@@ -2068,10 +2065,7 @@ gen6_render_video(struct sna *sna,
r.y1 = box->y1 + pix_yoff;
r.y2 = box->y2 + pix_yoff;
- if (unlikely(!gen6_get_rectangles(sna, &tmp, 1))) {
- gen6_emit_video_state(sna, &tmp, frame);
- gen6_get_rectangles(sna, &tmp, 1);
- }
+ gen6_get_rectangles(sna, &tmp, 1, gen6_emit_video_state);
OUT_VERTEX(r.x2, r.y2);
OUT_VERTEX_F((box->x2 - dxo) * src_scale_x);
@@ -2949,11 +2943,7 @@ gen6_render_composite_spans_box(struct sna *sna,
box->x2 - box->x1,
box->y2 - box->y1));
- if (unlikely(gen6_get_rectangles(sna, &op->base, 1) == 0)) {
- gen6_emit_composite_state(sna, &op->base);
- gen6_get_rectangles(sna, &op->base, 1);
- }
-
+ gen6_get_rectangles(sna, &op->base, 1, gen6_emit_composite_state);
op->prim_emit(sna, op, box, opacity);
}
@@ -2972,12 +2962,8 @@ gen6_render_composite_spans_boxes(struct sna *sna,
do {
int nbox_this_time;
- nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox);
- if (unlikely(nbox_this_time == 0)) {
- gen6_emit_composite_state(sna, &op->base);
- nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox);
- assert(nbox_this_time);
- }
+ nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox,
+ gen6_emit_composite_state);
nbox -= nbox_this_time;
do {
@@ -3371,11 +3357,8 @@ fallback_blt:
do {
float *v;
- int n_this_time = gen6_get_rectangles(sna, &tmp, n);
- if (unlikely(n_this_time == 0)) {
- gen6_emit_copy_state(sna, &tmp);
- n_this_time = gen6_get_rectangles(sna, &tmp, n);
- }
+ int n_this_time = gen6_get_rectangles(sna, &tmp, n,
+ gen6_emit_copy_state);
n -= n_this_time;
v = sna->render.vertices + sna->render.vertex_used;
@@ -3425,10 +3408,7 @@ gen6_render_copy_blt(struct sna *sna,
int16_t w, int16_t h,
int16_t dx, int16_t dy)
{
- if (unlikely(!gen6_get_rectangles(sna, &op->base, 1))) {
- gen6_emit_copy_state(sna, &op->base);
- gen6_get_rectangles(sna, &op->base, 1);
- }
+ gen6_get_rectangles(sna, &op->base, 1, gen6_emit_copy_state);
OUT_VERTEX(dx+w, dy+h);
OUT_VERTEX_F((sx+w)*op->base.src.scale[0]);
@@ -3698,11 +3678,8 @@ gen6_render_fill_boxes(struct sna *sna,
gen6_align_vertex(sna, &tmp);
do {
- int n_this_time = gen6_get_rectangles(sna, &tmp, n);
- if (unlikely(n_this_time == 0)) {
- gen6_emit_fill_state(sna, &tmp);
- n_this_time = gen6_get_rectangles(sna, &tmp, n);
- }
+ int n_this_time = gen6_get_rectangles(sna, &tmp, n,
+ gen6_emit_fill_state);
n -= n_this_time;
do {
DBG((" (%d, %d), (%d, %d)\n",
@@ -3735,10 +3712,7 @@ gen6_render_op_fill_blt(struct sna *sna,
{
DBG(("%s: (%d, %d)x(%d, %d)\n", __FUNCTION__, x, y, w, h));
- if (unlikely(!gen6_get_rectangles(sna, &op->base, 1))) {
- gen6_emit_fill_state(sna, &op->base);
- gen6_get_rectangles(sna, &op->base, 1);
- }
+ gen6_get_rectangles(sna, &op->base, 1, gen6_emit_fill_state);
OUT_VERTEX(x+w, y+h);
OUT_VERTEX_F(1);
@@ -3761,10 +3735,7 @@ gen6_render_op_fill_box(struct sna *sna,
DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__,
box->x1, box->y1, box->x2, box->y2));
- if (unlikely(!gen6_get_rectangles(sna, &op->base, 1))) {
- gen6_emit_fill_state(sna, &op->base);
- gen6_get_rectangles(sna, &op->base, 1);
- }
+ gen6_get_rectangles(sna, &op->base, 1, gen6_emit_fill_state);
OUT_VERTEX(box->x2, box->y2);
OUT_VERTEX_F(1);
@@ -3789,11 +3760,10 @@ gen6_render_op_fill_boxes(struct sna *sna,
box->x1, box->y1, box->x2, box->y2, nbox));
do {
- int nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox);
- if (unlikely(nbox_this_time == 0)) {
- gen6_emit_fill_state(sna, &op->base);
- nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox);
- }
+ int nbox_this_time;
+
+ nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox,
+ gen6_emit_fill_state);
nbox -= nbox_this_time;
do {
@@ -3987,10 +3957,7 @@ gen6_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
gen6_emit_fill_state(sna, &tmp);
gen6_align_vertex(sna, &tmp);
- if (unlikely(!gen6_get_rectangles(sna, &tmp, 1))) {
- gen6_emit_fill_state(sna, &tmp);
- gen6_get_rectangles(sna, &tmp, 1);
- }
+ gen6_get_rectangles(sna, &tmp, 1, gen6_emit_fill_state);
DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2));
OUT_VERTEX(x2, y2);
@@ -4085,10 +4052,7 @@ gen6_render_clear(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo)
gen6_emit_fill_state(sna, &tmp);
gen6_align_vertex(sna, &tmp);
- if (unlikely(!gen6_get_rectangles(sna, &tmp, 1))) {
- gen6_emit_fill_state(sna, &tmp);
- gen6_get_rectangles(sna, &tmp, 1);
- }
+ gen6_get_rectangles(sna, &tmp, 1, gen6_emit_fill_state);
OUT_VERTEX(dst->drawable.width, dst->drawable.height);
OUT_VERTEX_F(1);
diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h
index 7243042..71a6fc5 100644
--- a/src/sna/sna_render.h
+++ b/src/sna/sna_render.h
@@ -134,9 +134,9 @@ struct sna_composite_op {
int nr_inputs;
int ve_id;
} gen7;
-
- void *priv;
} u;
+
+ void *priv;
};
struct sna_composite_spans_op {
diff --git a/src/sna/sna_tiling.c b/src/sna/sna_tiling.c
index 17ecaea..493e313 100644
--- a/src/sna/sna_tiling.c
+++ b/src/sna/sna_tiling.c
@@ -89,7 +89,7 @@ sna_tiling_composite_blt(struct sna *sna,
const struct sna_composite_op *op,
const struct sna_composite_rectangles *r)
{
- sna_tiling_composite_add_rect(op->u.priv, r);
+ sna_tiling_composite_add_rect(op->priv, r);
(void)sna;
}
@@ -107,7 +107,7 @@ sna_tiling_composite_box(struct sna *sna,
r.width = box->x2 - box->x1;
r.height = box->y2 - box->y1;
- sna_tiling_composite_add_rect(op->u.priv, &r);
+ sna_tiling_composite_add_rect(op->priv, &r);
(void)sna;
}
@@ -126,7 +126,7 @@ sna_tiling_composite_boxes(struct sna *sna,
r.width = box->x2 - box->x1;
r.height = box->y2 - box->y1;
- sna_tiling_composite_add_rect(op->u.priv, &r);
+ sna_tiling_composite_add_rect(op->priv, &r);
box++;
}
(void)sna;
@@ -136,7 +136,7 @@ static void
sna_tiling_composite_done(struct sna *sna,
const struct sna_composite_op *op)
{
- struct sna_tile_state *tile = op->u.priv;
+ struct sna_tile_state *tile = op->priv;
struct sna_composite_op tmp;
int x, y, n, step;
@@ -312,7 +312,7 @@ sna_tiling_composite(uint32_t op,
tmp->boxes = sna_tiling_composite_boxes;
tmp->done = sna_tiling_composite_done;
- tmp->u.priv = tile;
+ tmp->priv = tile;
return TRUE;
}
More information about the xorg-commit
mailing list