From d1a19907f9b36d64c936e3d03b444848e7eef74b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 1 Nov 2020 14:46:53 -0500 Subject: [PATCH] vbo: change the parameters of vbo_get_minmax_index to get rid of _mesa_prim This will be used by a new Draw interface. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/vbo/vbo_minmax_index.c | 51 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c index dfd8f49..88a71b3 100644 --- a/src/mesa/vbo/vbo_minmax_index.c +++ b/src/mesa/vbo/vbo_minmax_index.c @@ -320,38 +320,35 @@ vbo_get_minmax_index_mapped(unsigned count, unsigned index_size, * indexes when computing min/max. */ static void -vbo_get_minmax_index(struct gl_context *ctx, - const struct _mesa_prim *prim, - const struct _mesa_index_buffer *ib, - GLuint *min_index, GLuint *max_index, - const GLuint count, - bool primitive_restart, - unsigned restart_index) +vbo_get_minmax_index(struct gl_context *ctx, struct gl_buffer_object *obj, + const void *ptr, GLintptr offset, unsigned count, + unsigned index_size, bool primitive_restart, + unsigned restart_index, GLuint *min_index, + GLuint *max_index) { const char *indices; - GLintptr offset = 0; - indices = (char *) ib->ptr + (prim->start << ib->index_size_shift); - if (ib->obj) { - GLsizeiptr size = MIN2(count << ib->index_size_shift, ib->obj->Size); + if (!obj) { + indices = (const char *)ptr + offset; + } else { + GLsizeiptr size = MIN2((GLsizeiptr)count * index_size, obj->Size); - if (vbo_get_minmax_cached(ib->obj, 1 << ib->index_size_shift, (GLintptr) indices, - count, min_index, max_index)) + if (vbo_get_minmax_cached(obj, index_size, offset, count, min_index, + max_index)) return; - offset = (GLintptr) indices; - indices = ctx->Driver.MapBufferRange(ctx, offset, size, - GL_MAP_READ_BIT, ib->obj, - MAP_INTERNAL); + indices = ctx->Driver.MapBufferRange(ctx, offset, size, GL_MAP_READ_BIT, + obj, MAP_INTERNAL); } - vbo_get_minmax_index_mapped(count, 1 << ib->index_size_shift, restart_index, - primitive_restart, indices, min_index, max_index); + vbo_get_minmax_index_mapped(count, index_size, restart_index, + primitive_restart, indices, + min_index, max_index); - if (ib->obj) { - vbo_minmax_cache_store(ctx, ib->obj, 1 << ib->index_size_shift, offset, - count, *min_index, *max_index); - ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL); + if (obj) { + vbo_minmax_cache_store(ctx, obj, index_size, offset, count, *min_index, + *max_index); + ctx->Driver.UnmapBuffer(ctx, obj, MAP_INTERNAL); } } @@ -386,8 +383,12 @@ vbo_get_minmax_indices(struct gl_context *ctx, count += prims[i+1].count; i++; } - vbo_get_minmax_index(ctx, start_prim, ib, &tmp_min, &tmp_max, count, - primitive_restart, restart_index); + vbo_get_minmax_index(ctx, ib->obj, ib->ptr, + (ib->obj ? (GLintptr)ib->ptr : 0) + + (start_prim->start << ib->index_size_shift), + count, 1 << ib->index_size_shift, + primitive_restart, restart_index, + &tmp_min, &tmp_max); *min_index = MIN2(*min_index, tmp_min); *max_index = MAX2(*max_index, tmp_max); } -- 2.7.4