u_vbuf_mgr: fix crash with unsupported vertex format in hw VBOs
authorMarek Olšák <maraeo@gmail.com>
Fri, 8 Apr 2011 17:31:26 +0000 (19:31 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 8 Apr 2011 17:31:26 +0000 (19:31 +0200)
src/gallium/auxiliary/util/u_vbuf_mgr.c
src/gallium/auxiliary/util/u_vbuf_mgr.h

index 521ac07747cee92d07e6512aa2d0f56d4d3a25d6..b2eaff851ac005772b738c5bf7cf8182231322ce 100644 (file)
@@ -572,7 +572,11 @@ void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
    int min_index, max_index;
 
    min_index = info->min_index - info->index_bias;
-   max_index = info->max_index - info->index_bias;
+   if (info->max_index == ~0) {
+      max_index = mgr->b.max_index;
+   } else {
+      max_index = MIN2(info->max_index - info->index_bias, mgr->b.max_index);
+   }
 
    /* Translate vertices with non-native layouts or formats. */
    if (mgr->incompatible_vb_layout || mgr->ve->incompatible_layout) {
index 8b241854c83b97d579c6bc6b87de3e77c4218a27..9380dce4f7284aed1923fca3e64ca41670e8c063 100644 (file)
@@ -53,7 +53,7 @@ struct u_vbuf_mgr {
    int nr_real_vertex_buffers;
 
    /* Precomputed max_index for hardware vertex buffers. */
-   int max_index;
+   unsigned max_index;
 
    /* This uploader can optionally be used by the driver.
     *