diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-23 10:14:09 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-23 10:14:09 +0100 |
commit | e1e853edee67c3ced43d5e4b1fbd52ca4c92966d (patch) | |
tree | 273fdb7795b1c666c883f5af4dd99a506dc6944d | |
parent | 978790dc52fa9551b3bccbd91988b93988e937df (diff) |
sna/gen4+: Add some more asserts around recreating vertex buffers
References: https://bugs.freedesktop.org/show_bug.cgi?id=70461#c46
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/gen4_vertex.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/sna/gen4_vertex.c b/src/sna/gen4_vertex.c index aaecb78b..31044d69 100644 --- a/src/sna/gen4_vertex.c +++ b/src/sna/gen4_vertex.c @@ -42,7 +42,9 @@ void gen4_vertex_align(struct sna *sna, const struct sna_composite_op *op) { int vertex_index; + assert(op->floats_per_vertex); assert(op->floats_per_rect == 3*op->floats_per_vertex); + assert(sna->render.vertex_used <= sna->render.vertex_size); 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) { @@ -52,6 +54,7 @@ void gen4_vertex_align(struct sna *sna, const struct sna_composite_op *op) kgem_submit(&sna->kgem); _kgem_set_mode(&sna->kgem, KGEM_RENDER); } + assert(sna->render.vertex_used < sna->render.vertex_size); 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); @@ -118,18 +121,17 @@ int gen4_vertex_finish(struct sna *sna) kgem_bo_destroy(&sna->kgem, bo); hint |= CREATE_CACHED | CREATE_NO_THROTTLE; } else { - if (kgem_is_idle(&sna->kgem)) { - sna->render.vertices = sna->render.vertex_data; - sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data); + assert(sna->render.vertex_size == ARRAY_SIZE(sna->render.vertex_data)); + assert(sna->render.vertices == sna->render.vertex_data); + if (kgem_is_idle(&sna->kgem)) return 0; - } } size = 256*1024; assert(!sna->render.active); sna->render.vertices = NULL; sna->render.vbo = kgem_create_linear(&sna->kgem, size, hint); - while (sna->render.vbo == NULL && size > 16*1024) { + while (sna->render.vbo == NULL && size > sizeof(sna->render.vertex_data)) { size /= 2; sna->render.vbo = kgem_create_linear(&sna->kgem, size, hint); } @@ -165,11 +167,12 @@ int gen4_vertex_finish(struct sna *sna) if (size >= UINT16_MAX) size = UINT16_MAX - 1; - DBG(("%s: create vbo handle=%d, size=%d\n", - __FUNCTION__, sna->render.vbo->handle, size)); + DBG(("%s: create vbo handle=%d, size=%d floats [%d bytes]\n", + __FUNCTION__, sna->render.vbo->handle, size, __kgem_bo_size(sna->render.vbo))); + assert(size > sna->render.vertex_used); sna->render.vertex_size = size; - return sna->render.vertex_size - sna->render.vertex_used; + return size - sna->render.vertex_used; } void gen4_vertex_close(struct sna *sna) |