diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-09 10:32:02 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-09 11:15:24 +0100 |
commit | d1cb39d0a86390b7ef704422a5b91f9a012d24a5 (patch) | |
tree | a61508cbaedb2bf9bb0320f72086bcec9f9c005d /src/sna/gen4_vertex.c | |
parent | 38333443b804b9ac6517a7998551b229dc4d5c6c (diff) |
sna/gen3+: Flush vertex buffer after computing resize
Upon aligning the buffer, we may enlarge the vbo to accomodate the
vertex alignment and push the current index past the end of the buffer.
Move the space check from before the alignment computation to
afterwards.
Reported-by: Jiri Slaby <jirislaby@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=47597
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/gen4_vertex.c')
-rw-r--r-- | src/sna/gen4_vertex.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sna/gen4_vertex.c b/src/sna/gen4_vertex.c index e2a48083..0585c4ce 100644 --- a/src/sna/gen4_vertex.c +++ b/src/sna/gen4_vertex.c @@ -38,6 +38,29 @@ #define sse2 #endif +void gen4_vertex_align(struct sna *sna, const struct sna_composite_op *op) +{ + int vertex_index; + + 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 (gen4_vertex_finish(sna) < op->floats_per_rect) { + kgem_submit(&sna->kgem); + _kgem_set_mode(&sna->kgem, KGEM_RENDER); + } + + vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex; + assert(vertex_index * op->floats_per_vertex <= sna->render.vertex_size); + } + + sna->render.vertex_index = vertex_index; + sna->render.vertex_used = vertex_index * op->floats_per_vertex; +} + void gen4_vertex_flush(struct sna *sna) { DBG(("%s[%x] = %d\n", __FUNCTION__, |