Mesa (master): u_prim_restart: add inline function for getting restart index based on index size

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 3 17:48:36 UTC 2020


Module: Mesa
Branch: master
Commit: 070fd2b66f99464d3bc14f5e0e98c9313770c87c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=070fd2b66f99464d3bc14f5e0e98c9313770c87c

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Jul 31 11:08:04 2020 -0400

u_prim_restart: add inline function for getting restart index based on index size

handy to have this available for drivers to reuse

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

---

 src/gallium/auxiliary/util/u_prim_restart.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_prim_restart.h b/src/gallium/auxiliary/util/u_prim_restart.h
index 0e17ce5eb1a..de4fcca497c 100644
--- a/src/gallium/auxiliary/util/u_prim_restart.h
+++ b/src/gallium/auxiliary/util/u_prim_restart.h
@@ -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
 }



More information about the mesa-commit mailing list