mesa: Simplify _mesa_primitive_restart_index().
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 4 May 2017 08:08:25 +0000 (01:08 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 6 May 2017 22:43:43 +0000 (15:43 -0700)
We can use a simple shift equation rather than a switch statement.

Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/main/varray.c

index eda86ec6a823065f4927b7b657106fc724829723..9497090e88a77f3bc5d3adb0709343a2dd00f1d4 100644 (file)
@@ -1959,16 +1959,8 @@ _mesa_primitive_restart_index(const struct gl_context *ctx,
     *  is used."
     */
    if (ctx->Array.PrimitiveRestartFixedIndex) {
-      switch (index_size) {
-      case 1:
-         return 0xff;
-      case 2:
-         return 0xffff;
-      case 4:
-         return 0xffffffff;
-      default:
-         assert(!"_mesa_primitive_restart_index: Invalid index size.");
-      }
+      /* 1 -> 0xff, 2 -> 0xffff, 4 -> 0xffffffff */
+      return 0xffffffffu >> 8 * (4 - index_size);
    }
 
    return ctx->Array.RestartIndex;