[Mesa-dev] [PATCH 2/9] mesa: Use gl_shader_program::_LinkedShaders instead of GeometryProgram

Ian Romanick idr at freedesktop.org
Tue Oct 4 13:44:05 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/context.c                    |    3 +--
 src/mesa/main/mtypes.h                     |    1 -
 src/mesa/main/shaderapi.c                  |    9 +++++----
 src/mesa/main/shaderobj.c                  |    1 -
 src/mesa/main/state.c                      |    6 ++++--
 src/mesa/main/uniforms.c                   |   12 +++++++-----
 src/mesa/program/ir_to_mesa.cpp            |    5 ++---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    4 ++--
 src/mesa/state_tracker/st_program.c        |    4 ++--
 9 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index b825a63..6ef394f 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1856,8 +1856,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
 	    break;
 
 	 case GL_GEOMETRY_SHADER_ARB:
-	    _mesa_append_uniforms_to_file(sh,
-					  &shProg[i]->GeometryProgram->Base);
+	    _mesa_append_uniforms_to_file(sh, sh->Program);
 	    break;
 
 	 case GL_FRAGMENT_SHADER:
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8df77f1..8f97373 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2174,7 +2174,6 @@ struct gl_shader_program
 
    /* post-link info: */
    struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
-   struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */
    struct gl_uniform_list *Uniforms;
    struct gl_program_parameter_list *Varying;
    GLboolean LinkStatus;   /**< GL_LINK_STATUS */
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index d9559ba..c70fda1 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -813,8 +813,9 @@ print_shader_info(const struct gl_shader_program *shProg)
 	     shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Id);
    if (shProg->FragmentProgram)
       printf("  frag prog %u\n", shProg->FragmentProgram->Base.Id);
-   if (shProg->GeometryProgram)
-      printf("  geom prog %u\n", shProg->GeometryProgram->Base.Id);
+   if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY])
+      printf("  geom prog %u\n",
+	     shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program->Id);
 }
 
 
@@ -965,7 +966,7 @@ validate_shader_program(const struct gl_shader_program *shProg,
                         char *errMsg)
 {
    const struct gl_shader *vs = shProg->_LinkedShaders[MESA_SHADER_VERTEX];
-   const struct gl_geometry_program *gp = shProg->GeometryProgram;
+   const struct gl_shader *gs = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY];
    const struct gl_fragment_program *fp = shProg->FragmentProgram;
 
    if (!shProg->LinkStatus) {
@@ -995,7 +996,7 @@ validate_shader_program(const struct gl_shader_program *shProg,
    if (vs && !validate_samplers(vs->Program, errMsg)) {
       return GL_FALSE;
    }
-   if (gp && !validate_samplers(&gp->Base, errMsg)) {
+   if (gs && !validate_samplers(gs->Program, errMsg)) {
       return GL_FALSE;
    }
    if (fp && !validate_samplers(&fp->Base, errMsg)) {
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index f5f5e70..bebf736 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -276,7 +276,6 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
                                 struct gl_shader_program *shProg)
 {
    _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
-   _mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL);
 
    if (shProg->Uniforms) {
       _mesa_free_uniform_list(shProg->Uniforms);
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index ab7250f..80502e5 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -268,10 +268,12 @@ update_program(struct gl_context *ctx)
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
    }
 
-   if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) {
+   if (gsProg && gsProg->LinkStatus
+       && gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
       /* Use GLSL geometry shader */
       _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current,
-                               gsProg->GeometryProgram);
+			       (struct gl_geometry_program *)
+			       gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program);
    } else {
       /* No geometry program */
       _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL);
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 28a3bee..1e395f7 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -190,7 +190,7 @@ find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index,
       else {
          pos = shProg->Uniforms->Uniforms[index].GeomPos;
          if (pos >= 0) {
-            prog = &shProg->GeometryProgram->Base;
+            prog = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
          }
       }
    }
@@ -930,11 +930,12 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
       }
    }
 
-   if (shProg->GeometryProgram) {
+   if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
       /* convert uniform location to program parameter index */
       GLint index = uniform->GeomPos;
       if (index >= 0) {
-         set_program_uniform(ctx, &shProg->GeometryProgram->Base,
+         set_program_uniform(ctx,
+			     shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program,
                              index, offset, type, count, elems, values);
       }
    }
@@ -1078,11 +1079,12 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
       }
    }
 
-   if (shProg->GeometryProgram) {
+   if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
       /* convert uniform location to program parameter index */
       GLint index = uniform->GeomPos;
       if (index >= 0) {
-         set_program_uniform_matrix(ctx, &shProg->GeometryProgram->Base,
+         set_program_uniform_matrix(ctx,
+                                    shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program,
                                     index, offset,
                                     count, rows, cols, transpose, values);
       }
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 652e706..ddc4ab8 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3306,8 +3306,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                                  linked_prog);
             break;
          case GL_GEOMETRY_SHADER:
-            _mesa_reference_geomprog(ctx, &prog->GeometryProgram,
-                                     (struct gl_geometry_program *)linked_prog);
+            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+				    linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
                                                  linked_prog);
             break;
@@ -3428,7 +3428,6 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
    }
 
    _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
-   _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
 
    if (prog->LinkStatus) {
       link_shaders(ctx, prog);
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 01e4d88..56bc7f8 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5202,8 +5202,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
             }
             break;
          case GL_GEOMETRY_SHADER:
-            _mesa_reference_geomprog(ctx, &prog->GeometryProgram,
-                                     (struct gl_geometry_program *)linked_prog);
+            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+				    linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
                                                  linked_prog);
             if (!ok) {
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 5211043..ba99808 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1157,8 +1157,8 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
                                   shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
          destroy_program_variants(st, (struct gl_program *)
                                   shProg->FragmentProgram);
-         destroy_program_variants(st, (struct gl_program *)
-                                  shProg->GeometryProgram);
+         destroy_program_variants(st,
+                                  shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program);
       }
       break;
    case GL_VERTEX_SHADER:
-- 
1.7.6



More information about the mesa-dev mailing list