[Mesa-dev] [PATCH] vbo: count min/max_index before vbo->draw_prims

Yuanhan Liu yuanhan.liu at linux.intel.com
Thu Dec 22 02:55:50 PST 2011


For the case that index data is stored in element array buffer object,
and user called glMultiDrawElements, count the min/max_index before
calling vbo->draw_prims. vbo_get_minmax_index() isn't friendly to this
case. So do it while building the prim info.

Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 src/mesa/vbo/vbo_exec_array.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index a6e41e9..70efd3f 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -1147,11 +1147,18 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
       fallback = GL_TRUE;
 
    if (!fallback) {
+      struct _mesa_index_buffer tmp_ib;
+      GLuint min_index = ~0;
+      GLuint max_index = 0;
+      GLuint tmp_min, tmp_max;
+
       ib.count = (max_index_ptr - min_index_ptr) / index_type_size;
       ib.type = type;
       ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
       ib.ptr = (void *)min_index_ptr;
 
+      tmp_ib = ib;
+
       for (i = 0; i < primcount; i++) {
 	 prim[i].begin = (i == 0);
 	 prim[i].end = (i == primcount - 1);
@@ -1166,11 +1173,16 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
 	    prim[i].basevertex = basevertex[i];
 	 else
 	    prim[i].basevertex = 0;
+
+         tmp_ib.ptr = indices[i];
+         vbo_get_minmax_index(ctx, &prim[i], &tmp_ib, &tmp_min, &tmp_max);
+         min_index = MIN2(min_index, tmp_min);
+         max_index = MAX2(max_index, tmp_max);
       }
 
       check_buffers_are_unmapped(exec->array.inputs);
       vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib,
-		      GL_FALSE, ~0, ~0, NULL);
+                      GL_TRUE, min_index, max_index, NULL);
    } else {
       /* render one prim at a time */
       for (i = 0; i < primcount; i++) {
-- 
1.7.4.4



More information about the mesa-dev mailing list