mesa: Replace _mesa_program_index_to_target with _mesa_shader_stage_to_program.
authorPaul Berry <stereotype441@gmail.com>
Thu, 9 Jan 2014 21:42:05 +0000 (13:42 -0800)
committerPaul Berry <stereotype441@gmail.com>
Wed, 22 Jan 2014 04:24:43 +0000 (20:24 -0800)
In my recent zeal to refactor Mesa's handling of the gl_shader_stage
enum, I accidentally wound up with two functions that do the same
thing: _mesa_program_index_to_target(), and
_mesa_shader_stage_to_program().

This patch keeps _mesa_shader_stage_to_program(), since its name is
more consistent with other related functions.  However, it changes the
signature so that it accepts an unsigned integer instead of a
gl_shader_stage--this avoids awkward casts when the function is called
from C++ code.

Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/program/program.h
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 5752348be65f36e59080303fb84be4058c542fa6..446c917c08fa6f1935314a9368951ea13de625da 100644 (file)
@@ -127,7 +127,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
         continue;
 
       struct gl_program *prog =
-        ctx->Driver.NewProgram(ctx, _mesa_program_index_to_target(stage),
+        ctx->Driver.NewProgram(ctx, _mesa_shader_stage_to_program(stage),
                                 shader->base.Name);
       if (!prog)
        return false;
index 85d4142594c65f555f3590b783aaf10c5d4e0486..74c512b330f3850bd9c5a097bdc4db150d1c8f97 100644 (file)
@@ -3053,7 +3053,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
         _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
                                 linked_prog);
          if (!ctx->Driver.ProgramStringNotify(ctx,
-                                              _mesa_program_index_to_target(i),
+                                              _mesa_shader_stage_to_program(i),
                                               linked_prog)) {
             return GL_FALSE;
          }
index c47ac1cc7969e1b24cd31a61d9f6a30c3dd8dbc1..71b0a4af26d63d4dad90c98f3cbb50f417fbad74 100644 (file)
@@ -210,7 +210,7 @@ _mesa_program_enum_to_shader_stage(GLenum v)
 
 
 static inline GLenum
-_mesa_shader_stage_to_program(gl_shader_stage stage)
+_mesa_shader_stage_to_program(unsigned stage)
 {
    switch (stage) {
    case MESA_SHADER_VERTEX:
@@ -226,23 +226,6 @@ _mesa_shader_stage_to_program(gl_shader_stage stage)
 }
 
 
-static inline GLenum
-_mesa_program_index_to_target(GLuint i)
-{
-   static const GLenum enums[] = {
-      GL_VERTEX_PROGRAM_ARB,
-      GL_GEOMETRY_PROGRAM_NV,
-      GL_FRAGMENT_PROGRAM_ARB
-   };
-   STATIC_ASSERT(Elements(enums) == MESA_SHADER_STAGES);
-   if(i >= MESA_SHADER_STAGES) {
-      assert(!"Unexpected program index");
-      return 0;
-   } else
-      return enums[i];
-}
-
-
 /* Cast wrappers from gl_program to gl_vertex/geometry/fragment_program */
 
 static inline struct gl_fragment_program *
index f1b35442969e9ce801133dd28755039cebd46be9..0871dd06428eb6e3fedcd15453c262a09bb44655 100644 (file)
@@ -5312,7 +5312,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
         _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
                                 linked_prog);
          if (!ctx->Driver.ProgramStringNotify(ctx,
-                                              _mesa_program_index_to_target(i),
+                                              _mesa_shader_stage_to_program(i),
                                               linked_prog)) {
            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
                                    NULL);