u_prim_restart: add inline function for getting restart index based on index size
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 31 Jul 2020 15:08:04 +0000 (11:08 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 3 Aug 2020 16:58:48 +0000 (16:58 +0000)
handy to have this available for drivers to reuse

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

src/gallium/auxiliary/util/u_prim_restart.h

index 0e17ce5eb1a9f5632431cc1aa1b15b282435a64f..de4fcca497cb6d969b7d3caf09083057a4a5519a 100644 (file)
@@ -51,6 +51,18 @@ enum pipe_error
 util_draw_vbo_without_prim_restart(struct pipe_context *context,
                                    const struct pipe_draw_info *info);
 
+static inline unsigned
+util_prim_restart_index_from_size(unsigned index_size)
+{
+   if (index_size == 1)
+      return 0xff;
+   if (index_size == 2)
+      return 0xffff;
+   if (index_size == 4)
+      return 0xffffffff;
+   unreachable("unknown index size passed");
+   return 0;
+}
 
 #ifdef __cplusplus
 }