Mesa (master): mesa: Replace _mesa_program_index_to_target with _mesa_shader_stage_to_program.

Paul Berry stereotype441 at kemper.freedesktop.org
Wed Jan 22 04:58:56 UTC 2014


Module: Mesa
Branch: master
Commit: 46d210d38fc472d5454cef864c4299c52bb46c86
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=46d210d38fc472d5454cef864c4299c52bb46c86

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Thu Jan  9 13:42:05 2014 -0800

mesa: Replace _mesa_program_index_to_target with _mesa_shader_stage_to_program.

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 at ijw.co.nz>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/drivers/dri/i965/brw_shader.cpp   |    2 +-
 src/mesa/program/ir_to_mesa.cpp            |    2 +-
 src/mesa/program/program.h                 |   19 +------------------
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    2 +-
 4 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 5752348..446c917 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -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;
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 85d4142..74c512b 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -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;
          }
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index c47ac1c..71b0a4a 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -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 *
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f1b3544..0871dd0 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -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);




More information about the mesa-commit mailing list