mesa: Index into ctx->Const.Program[] rather than using ad-hoc code.
authorPaul Berry <stereotype441@gmail.com>
Wed, 8 Jan 2014 18:17:01 +0000 (10:17 -0800)
committerPaul Berry <stereotype441@gmail.com>
Thu, 9 Jan 2014 17:31:16 +0000 (09:31 -0800)
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/program/program.c

index df4d75fddbd74fc52daee73743bdc2f2b5ea11fd..3c19e8c60f08457668a23548f2398652d0747b8b 100644 (file)
@@ -896,21 +896,8 @@ _mesa_valid_register_index(const struct gl_context *ctx,
 {
    const struct gl_program_constants *c;
 
-   switch (shaderType) {
-   case MESA_SHADER_VERTEX:
-      c = &ctx->Const.Program[MESA_SHADER_VERTEX];
-      break;
-   case MESA_SHADER_FRAGMENT:
-      c = &ctx->Const.Program[MESA_SHADER_FRAGMENT];
-      break;
-   case MESA_SHADER_GEOMETRY:
-      c = &ctx->Const.Program[MESA_SHADER_GEOMETRY];
-      break;
-   default:
-      _mesa_problem(ctx,
-                    "unexpected shader type in _mesa_valid_register_index()");
-      return GL_FALSE;
-   }
+   assert(0 <= shaderType && shaderType < MESA_SHADER_STAGES);
+   c = &ctx->Const.Program[shaderType];
 
    switch (file) {
    case PROGRAM_UNDEFINED: