diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-10-17 12:53:19 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-10-17 12:53:19 +0100 |
commit | 71bf291e563ec5224777b4907a5347a3fbfe64c5 (patch) | |
tree | 5ca35d0e95140532a6fd9818a232030d1828afb3 | |
parent | a032feb2531439b9945d7ae1e0c2e3ab95a960e1 (diff) |
sna/gen3: Micro-optimise gen3_rectangle_begin()
We only need to emit the vbo description either at the beginning of a
new op (when the state may have changed) or after finishing a full vbo.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/gen3_render.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 50883a58..0a51e64d 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -1457,21 +1457,16 @@ static void gen3_vertex_finish(struct sna *sna, Bool last) static bool gen3_rectangle_begin(struct sna *sna, const struct sna_composite_op *op) { - int ndwords, i1_cmd = 0, i1_len = 0; struct gen3_render_state *state = &sna->render_state.gen3; + int ndwords, i1_cmd = 0, i1_len = 0; - ndwords = 0; - if (state->vertex_offset == 0) { - ndwords += 2; - if (op->need_magic_ca_pass) - ndwords += 100; - } + ndwords = 2; + if (op->need_magic_ca_pass) + ndwords += 100; if (sna->render.vertex_reloc[0] == 0) i1_len++, i1_cmd |= I1_LOAD_S(0), ndwords++; if (state->floats_per_vertex != op->floats_per_vertex) i1_len++, i1_cmd |= I1_LOAD_S(1), ndwords++; - if (ndwords == 0) - return true; if (!kgem_check_batch(&sna->kgem, ndwords+1)) return false; @@ -1487,16 +1482,14 @@ static bool gen3_rectangle_begin(struct sna *sna, } } - if (state->vertex_offset == 0) { - if (sna->kgem.nbatch == 2 + state->last_vertex_offset) { - state->vertex_offset = state->last_vertex_offset; - } else { - state->vertex_offset = sna->kgem.nbatch; - OUT_BATCH(MI_NOOP); /* to be filled later */ - OUT_BATCH(MI_NOOP); - sna->render.vertex_start = sna->render.vertex_index; - state->last_vertex_offset = state->vertex_offset; - } + if (sna->kgem.nbatch == 2 + state->last_vertex_offset) { + state->vertex_offset = state->last_vertex_offset; + } else { + state->vertex_offset = sna->kgem.nbatch; + OUT_BATCH(MI_NOOP); /* to be filled later */ + OUT_BATCH(MI_NOOP); + sna->render.vertex_start = sna->render.vertex_index; + state->last_vertex_offset = state->vertex_offset; } return true; @@ -1535,7 +1528,8 @@ inline static int gen3_get_rectangles(struct sna *sna, return 0; } - if (!gen3_rectangle_begin(sna, op)) { + if (sna->render_state.gen3.vertex_offset == 0 && + !gen3_rectangle_begin(sna, op)) { DBG(("%s: flushing batch\n", __FUNCTION__)); return 0; } |