summaryrefslogtreecommitdiff
path: root/src/sna/gen3_render.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sna/gen3_render.c')
-rw-r--r--src/sna/gen3_render.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index ebe108de..2445b91a 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -3123,20 +3123,29 @@ static void
gen3_align_vertex(struct sna *sna,
const struct sna_composite_op *op)
{
- if (op->floats_per_vertex != sna->render_state.gen3.last_floats_per_vertex) {
- if (sna->render.vertex_size - sna->render.vertex_used < 2*op->floats_per_rect)
- gen3_vertex_finish(sna);
-
- DBG(("aligning vertex: was %d, now %d floats per vertex, %d->%d\n",
- sna->render_state.gen3.last_floats_per_vertex,
- op->floats_per_vertex,
- sna->render.vertex_index,
- (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex));
- sna->render.vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex;
- sna->render.vertex_used = sna->render.vertex_index * op->floats_per_vertex;
- assert(sna->render.vertex_used < sna->render.vertex_size - op->floats_per_rect);
- sna->render_state.gen3.last_floats_per_vertex = op->floats_per_vertex;
+ int vertex_index;
+
+ if (op->floats_per_vertex == sna->render_state.gen3.last_floats_per_vertex)
+ return;
+
+ DBG(("aligning vertex: was %d, now %d floats per vertex\n",
+ sna->render_state.gen3.last_floats_per_vertex,
+ op->floats_per_vertex));
+
+ assert(op->floats_per_rect == 3*op->floats_per_vertex);
+
+ vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex;
+ if ((int)sna->render.vertex_size - vertex_index * op->floats_per_vertex < 2*op->floats_per_rect) {
+ DBG(("%s: flushing vertex buffer: new index=%d, max=%d\n",
+ __FUNCTION__, vertex_index, sna->render.vertex_size / op->floats_per_vertex));
+ if (gen3_vertex_finish(sna) < op->floats_per_vertex)
+ kgem_submit(&sna->kgem);
+
+ vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex;
}
+
+ sna->render.vertex_index = vertex_index;
+ sna->render.vertex_used = vertex_index * op->floats_per_vertex;
}
static bool
@@ -3806,8 +3815,8 @@ gen3_render_composite(struct sna *sna,
goto cleanup_mask;
}
- gen3_emit_composite_state(sna, tmp);
gen3_align_vertex(sna, tmp);
+ gen3_emit_composite_state(sna, tmp);
return true;
cleanup_mask:
@@ -5021,8 +5030,8 @@ gen3_render_composite_spans(struct sna *sna,
goto cleanup_src;
}
- gen3_emit_composite_state(sna, &tmp->base);
gen3_align_vertex(sna, &tmp->base);
+ gen3_emit_composite_state(sna, &tmp->base);
return true;
cleanup_src:
@@ -5665,8 +5674,8 @@ fallback_blt:
dst_dy += tmp.dst.y;
tmp.dst.x = tmp.dst.y = 0;
- gen3_emit_composite_state(sna, &tmp);
gen3_align_vertex(sna, &tmp);
+ gen3_emit_composite_state(sna, &tmp);
do {
int n_this_time;
@@ -5803,8 +5812,8 @@ fallback:
tmp->blt = gen3_render_copy_blt;
tmp->done = gen3_render_copy_done;
- gen3_emit_composite_state(sna, &tmp->base);
gen3_align_vertex(sna, &tmp->base);
+ gen3_emit_composite_state(sna, &tmp->base);
return true;
}
@@ -5943,8 +5952,8 @@ gen3_render_fill_boxes(struct sna *sna,
assert(kgem_check_bo(&sna->kgem, dst_bo, NULL));
}
- gen3_emit_composite_state(sna, &tmp);
gen3_align_vertex(sna, &tmp);
+ gen3_emit_composite_state(sna, &tmp);
do {
int n_this_time;
@@ -6094,8 +6103,8 @@ gen3_render_fill(struct sna *sna, uint8_t alu,
tmp->boxes = gen3_render_fill_op_boxes;
tmp->done = gen3_render_fill_op_done;
- gen3_emit_composite_state(sna, &tmp->base);
gen3_align_vertex(sna, &tmp->base);
+ gen3_emit_composite_state(sna, &tmp->base);
return true;
}
@@ -6172,8 +6181,8 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
return true;
}
- gen3_emit_composite_state(sna, &tmp);
gen3_align_vertex(sna, &tmp);
+ gen3_emit_composite_state(sna, &tmp);
gen3_get_rectangles(sna, &tmp, 1);
DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, color));
OUT_VERTEX(x2);