[Mesa-dev] [PATCH 2/2] i965: fix the wrong min/max_index for nr_prims > 1

Yuanhan Liu yuanhan.liu at linux.intel.com
Tue Dec 27 21:54:43 PST 2011


The current code would just calculate min/max_index for the first prim
unconditionally, which is wrong if nr_prims > 1.

This would some cases like that the index is stored in element array
buffer object and drawing by glMultiDrawEelements. Thus it fixes some
intel oglc primbuff test cases.

Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 src/mesa/drivers/dri/i965/brw_draw.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 621195d..3d0cc7c 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -585,8 +585,22 @@ void brw_draw_prims( struct gl_context *ctx,
       return;
 
    if (!vbo_all_varyings_in_vbos(arrays)) {
-      if (!index_bounds_valid)
-	 vbo_get_minmax_index(ctx, prim, ib, &min_index, &max_index);
+      if (!index_bounds_valid) {
+         struct _mesa_index_buffer tmp_ib;
+         GLuint tmp_min, tmp_max;
+         int i;
+
+         min_index = ~0;
+         max_index = 0;
+         tmp_ib = *ib;
+
+         for (i = 0; i < nr_prims; i++) {
+             tmp_ib.ptr = ib->ptr + prim[i].start * vbo_sizeof_ib_type(ib->type);
+             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);
+         }
+      }
 
       /* Decide if we want to rebase.  If so we end up recursing once
        * only into this function.
-- 
1.7.4.4



More information about the mesa-dev mailing list