diff options
author | Icecream95 <[email protected]> | 2019-12-11 21:08:41 +1300 |
---|---|---|
committer | Marge Bot <[email protected]> | 2019-12-16 22:57:35 +0000 |
commit | 37bc02836706a946eb7854a11c624ce1689496ea (patch) | |
tree | f9eb8828b164224ef87cdcdaa7208ab9fcbbf2dc /src/gallium/auxiliary/util | |
parent | 80aca96803a37a7436ff96c0cec4a2643f11ed05 (diff) |
gallium/auxiliary: Handle count == 0 in u_vbuf_get_minmax_index_mapped
This makes u_vbuf_get_minmax_index_mapped return min = 0 / max = 0
when info->count == 0.
That should never happen anyway, but this commit makes it at least
return a sane value that callers expect, and also allows us - and
GCC - to assume count != 0 for optimization purposes.
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3050>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3050>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_vbuf.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 40bdf1ed830..7f4248fa49c 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -1030,6 +1030,12 @@ u_vbuf_get_minmax_index_mapped(const struct pipe_draw_info *info, const void *indices, unsigned *out_min_index, unsigned *out_max_index) { + if (!info->count) { + *out_min_index = 0; + *out_max_index = 0; + return; + } + switch (info->index_size) { case 4: { const unsigned *ui_indices = (const unsigned*)indices; |