svga: use switch statement in svga_shader_type()
authorBrian Paul <brianp@vmware.com>
Fri, 28 Jun 2013 14:08:38 +0000 (08:08 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 28 Jun 2013 14:37:59 +0000 (08:37 -0600)
Safer in case the PIPE_SHADER_x tokens get renumbered (as Marek
wanted to do).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_state_constants.c

index 77c93493a8df757474874b9f97c4810eff552a9c..1c0edb405107375152286c2cb4bb3def86609433 100644 (file)
 /**
  * Convert from PIPE_SHADER_* to SVGA3D_SHADERTYPE_*
  */
-static int
+static unsigned
 svga_shader_type(unsigned shader)
 {
-   assert(PIPE_SHADER_VERTEX + 1 == SVGA3D_SHADERTYPE_VS);
-   assert(PIPE_SHADER_FRAGMENT + 1 == SVGA3D_SHADERTYPE_PS);
-   assert(shader <= PIPE_SHADER_FRAGMENT);
-   return shader + 1;
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      return SVGA3D_SHADERTYPE_VS;
+   case PIPE_SHADER_FRAGMENT:
+      return SVGA3D_SHADERTYPE_PS;
+   default:
+      assert(!"Unexpected shader type");
+      return SVGA3D_SHADERTYPE_VS;
+   }
 }