From: Brian Paul Date: Fri, 28 Jun 2013 14:08:38 +0000 (-0600) Subject: svga: use switch statement in svga_shader_type() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=74e8a7d1ddafc8dd465795d1fcc85709c5c4c0ba;p=mesa.git svga: use switch statement in svga_shader_type() Safer in case the PIPE_SHADER_x tokens get renumbered (as Marek wanted to do). Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index 77c93493a8d..1c0edb40510 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -46,13 +46,18 @@ /** * 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; + } }