util/prim_restart: assert the index size at the start of the function
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 21 May 2021 09:49:30 +0000 (05:49 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 9 Jun 2021 14:17:38 +0000 (14:17 +0000)
this lets it be removed from the macro loop

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10966>

src/gallium/auxiliary/util/u_prim_restart.c

index f4f989a..514d33f 100644 (file)
@@ -241,6 +241,16 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context,
    assert(info->index_size);
    assert(info->primitive_restart);
 
+   switch (info->index_size) {
+   case 1:
+   case 2:
+   case 4:
+      break;
+   default:
+      assert(!"Bad index size");
+      return PIPE_ERROR_BAD_INPUT;
+   }
+
    if (indirect_info && indirect_info->buffer) {
       indirect = read_indirect_elements(context, indirect_info);
       info_count = indirect.count;