u_vbuf_mgr: fix uploading with a non-zero index bias
authorMarek Olšák <maraeo@gmail.com>
Mon, 26 Sep 2011 01:30:24 +0000 (03:30 +0200)
committerMarek Olšák <maraeo@gmail.com>
Mon, 26 Sep 2011 13:25:05 +0000 (15:25 +0200)
Also don't rely on pipe_draw_info being set correctly.

NOTE: This is a candidate for the 7.11 branch.

src/gallium/auxiliary/util/u_vbuf_mgr.c

index 282efdbfe9a8633408b3edaa91dd15ebaa6e2c4c..6c2d1ed64002b93014de08b891c112c279a0140a 100644 (file)
@@ -628,11 +628,18 @@ u_vbuf_draw_begin(struct u_vbuf_mgr *mgrb,
 
    u_vbuf_compute_max_index(mgr);
 
-   min_index = info->min_index - info->index_bias;
-   if (info->max_index == ~0) {
-      max_index = mgr->b.max_index;
+   if (info->indexed) {
+      min_index = info->min_index;
+      if (info->max_index == ~0) {
+         max_index = mgr->b.max_index;
+      } else {
+         max_index = MIN2(info->max_index, mgr->b.max_index);
+      }
+      min_index += info->index_bias;
+      max_index += info->index_bias;
    } else {
-      max_index = MIN2(info->max_index - info->index_bias, mgr->b.max_index);
+      min_index = info->start;
+      max_index = info->start + info->count - 1;
    }
 
    /* Translate vertices with non-native layouts or formats. */