From a0d154dc1385d92a31dca8e65e50d958bdf6d532 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 8 Apr 2011 19:31:26 +0200 Subject: u_vbuf_mgr: fix crash with unsupported vertex format in hw VBOs --- src/gallium/auxiliary/util/u_vbuf_mgr.c | 6 +++++- src/gallium/auxiliary/util/u_vbuf_mgr.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_vbuf_mgr.c b/src/gallium/auxiliary/util/u_vbuf_mgr.c index 521ac07747c..b2eaff851ac 100644 --- a/src/gallium/auxiliary/util/u_vbuf_mgr.c +++ b/src/gallium/auxiliary/util/u_vbuf_mgr.c @@ -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) { diff --git a/src/gallium/auxiliary/util/u_vbuf_mgr.h b/src/gallium/auxiliary/util/u_vbuf_mgr.h index 8b241854c83..9380dce4f72 100644 --- a/src/gallium/auxiliary/util/u_vbuf_mgr.h +++ b/src/gallium/auxiliary/util/u_vbuf_mgr.h @@ -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. * -- cgit v1.2.3