mesa: Use gl_shader_program::_LinkedShaders instead of VertexProgram
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 20 Aug 2011 20:51:36 +0000 (13:51 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 7 Oct 2011 23:39:50 +0000 (16:39 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 files changed:
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/main/context.c
src/mesa/main/ff_fragment_shader.cpp
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c
src/mesa/main/shaderobj.c
src/mesa/main/state.c
src/mesa/main/texstate.c
src/mesa/main/uniforms.c
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp
src/mesa/state_tracker/st_program.c

index b26700f7494f2499579187f176343694327fea4f..e0e4781fecd0d9f9f0f9947ebfb5b7b637fb325b 100644 (file)
@@ -2347,7 +2347,8 @@ vec4_visitor::vec4_visitor(struct brw_vs_compile *c,
    this->current_annotation = NULL;
 
    this->c = c;
-   this->vp = prog->VertexProgram;
+   this->vp = (struct gl_vertex_program *)
+     prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
    this->prog_data = &c->prog_data;
 
    this->variable_ht = hash_table_ctor(0,
index f671223b8c2f06efd9daf7d64c01dd3d0221098b..310a022d652bab5bd2d87a3e2361ad0621859f6b 100644 (file)
@@ -354,15 +354,17 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_vs_prog_key key;
-   struct gl_vertex_program *vp = prog->VertexProgram;
-   struct brw_vertex_program *bvp = brw_vertex_program(vp);
    uint32_t old_prog_offset = brw->vs.prog_offset;
    struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data;
    bool success;
 
-   if (!vp)
+   if (!prog->_LinkedShaders[MESA_SHADER_VERTEX])
       return true;
 
+   struct gl_vertex_program *vp = (struct gl_vertex_program *)
+      prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+   struct brw_vertex_program *bvp = brw_vertex_program(vp);
+
    memset(&key, 0, sizeof(key));
 
    key.program_string_id = bvp->id;
index 2532c47de15bae4aa64975eb2ecd4ac9862a9dae..b825a63feeffc42af3afff7c456a64855ca2356f 100644 (file)
@@ -1852,7 +1852,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
         sh = shProg[i]->_LinkedShaders[i];
         switch (sh->Type) {
         case GL_VERTEX_SHADER:
-           _mesa_append_uniforms_to_file(sh, &shProg[i]->VertexProgram->Base);
+           _mesa_append_uniforms_to_file(sh, sh->Program);
            break;
 
         case GL_GEOMETRY_SHADER_ARB:
index 7cc1721688441f4e226443966c08142c4241bcd0..e6451c98b2118d9d017644afc954f62270332a57 100644 (file)
@@ -315,7 +315,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
    const GLboolean vertexShader =
       (ctx->Shader.CurrentVertexProgram &&
        ctx->Shader.CurrentVertexProgram->LinkStatus &&
-       ctx->Shader.CurrentVertexProgram->VertexProgram);
+       ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]);
    const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
    GLbitfield fp_inputs = 0x0;
 
@@ -371,7 +371,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
    }
    else {
       /* calculate from vp->outputs */
-      struct gl_vertex_program *vprog;
+      struct gl_program *vprog;
       GLbitfield64 vp_outputs;
 
       /* Choose GLSL vertex shader over ARB vertex program.  Need this
@@ -379,11 +379,11 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
        * validation (see additional comments in state.c).
        */
       if (vertexShader)
-         vprog = ctx->Shader.CurrentVertexProgram->VertexProgram;
+         vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
       else
-         vprog = ctx->VertexProgram.Current;
+         vprog = &ctx->VertexProgram.Current->Base;
 
-      vp_outputs = vprog->Base.OutputsWritten;
+      vp_outputs = vprog->OutputsWritten;
 
       /* These get generated in the setup routine regardless of the
        * vertex program:
index d329bee80069efac4a4329d1e83eaa779c37aa39..71236f9d67c4c5807c685a03fdb75dab9e00f5ee 100644 (file)
@@ -2171,7 +2171,6 @@ struct gl_shader_program
    } Vert;
 
    /* post-link info: */
-   struct gl_vertex_program *VertexProgram;     /**< Linked vertex program */
    struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
    struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */
    struct gl_uniform_list *Uniforms;
index 9e0ed9c69772e9d02bdd61ca94beadcc0a3b5577..d9559baeff7974ced9b11a7dcc4d1c8bb03d0984 100644 (file)
@@ -808,8 +808,9 @@ print_shader_info(const struct gl_shader_program *shProg)
             shProg->Shaders[i]->Name,
             shProg->Shaders[i]->SourceChecksum);
    }
-   if (shProg->VertexProgram)
-      printf("  vert prog %u\n", shProg->VertexProgram->Base.Id);
+   if (shProg->_LinkedShaders[MESA_SHADER_VERTEX])
+      printf("  vert prog %u\n",
+            shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Id);
    if (shProg->FragmentProgram)
       printf("  frag prog %u\n", shProg->FragmentProgram->Base.Id);
    if (shProg->GeometryProgram)
@@ -963,7 +964,7 @@ static GLboolean
 validate_shader_program(const struct gl_shader_program *shProg,
                         char *errMsg)
 {
-   const struct gl_vertex_program *vp = shProg->VertexProgram;
+   const struct gl_shader *vs = shProg->_LinkedShaders[MESA_SHADER_VERTEX];
    const struct gl_geometry_program *gp = shProg->GeometryProgram;
    const struct gl_fragment_program *fp = shProg->FragmentProgram;
 
@@ -991,7 +992,7 @@ validate_shader_program(const struct gl_shader_program *shProg,
     * Check: any two active samplers in the current program object are of
     * different types, but refer to the same texture image unit,
     */
-   if (vp && !validate_samplers(&vp->Base, errMsg)) {
+   if (vs && !validate_samplers(vs->Program, errMsg)) {
       return GL_FALSE;
    }
    if (gp && !validate_samplers(&gp->Base, errMsg)) {
index 1eba75697f7070c1ad42d592a27a4c102b240044..f5f5e701a4113ccd64d8725c6c9a04be73970675 100644 (file)
@@ -275,7 +275,6 @@ void
 _mesa_clear_shader_program_data(struct gl_context *ctx,
                                 struct gl_shader_program *shProg)
 {
-   _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL);
    _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
    _mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL);
 
index fc25515a00c860119d247f348d35ca4866164ff0..ab7250f3fc193b0c0fb2aca33ed69bf8aeeecc26 100644 (file)
@@ -281,10 +281,12 @@ update_program(struct gl_context *ctx)
     * _mesa_get_fixed_func_vertex_program() needs to know active
     * fragprog inputs.
     */
-   if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) {
+   if (vsProg && vsProg->LinkStatus
+       && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
       /* Use GLSL vertex shader */
       _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
-                               vsProg->VertexProgram);
+                              (struct gl_vertex_program *)
+                              vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
    }
    else if (ctx->VertexProgram._Enabled) {
       /* Use user-defined vertex program */
index e02f16240fd779c7d6ce68d9f6ac62466f3ecbf7..ee99e507c97f387abeba5126a1bab70ca2a18bc3 100644 (file)
@@ -490,16 +490,16 @@ update_texture_state( struct gl_context *ctx )
 {
    GLuint unit;
    struct gl_fragment_program *fprog = NULL;
-   struct gl_vertex_program *vprog = NULL;
+   struct gl_program *vprog = NULL;
    GLbitfield enabledFragUnits = 0x0;
 
    if (ctx->Shader.CurrentVertexProgram &&
        ctx->Shader.CurrentVertexProgram->LinkStatus) {
-      vprog = ctx->Shader.CurrentVertexProgram->VertexProgram;
+      vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
    } else if (ctx->VertexProgram._Enabled) {
       /* XXX enable this if/when non-shader vertex programs get
        * texture fetches:
-       vprog = ctx->VertexProgram.Current;
+       vprog = &ctx->VertexProgram.Current->Base;
        */
    }
 
@@ -540,7 +540,7 @@ update_texture_state( struct gl_context *ctx )
        * settle on the one with highest priority (see below).
        */
       if (vprog) {
-         enabledVertTargets |= vprog->Base.TexturesUsed[unit];
+         enabledVertTargets |= vprog->TexturesUsed[unit];
       }
 
       if (fprog) {
index 2323819aa43373c2bc70ee9cc91ae68ae227c2e8..28a3beef596fd64f05dfda89fb59a5c66b7803b0 100644 (file)
@@ -180,7 +180,7 @@ find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index,
 
    pos = shProg->Uniforms->Uniforms[index].VertPos;
    if (pos >= 0) {
-      prog = &shProg->VertexProgram->Base;
+      prog = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
    }
    else {
       pos = shProg->Uniforms->Uniforms[index].FragPos;
@@ -911,11 +911,12 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
    /* A uniform var may be used by both a vertex shader and a fragment
     * shader.  We may need to update one or both shader's uniform here:
     */
-   if (shProg->VertexProgram) {
+   if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
       /* convert uniform location to program parameter index */
       GLint index = uniform->VertPos;
       if (index >= 0) {
-         set_program_uniform(ctx, &shProg->VertexProgram->Base,
+         set_program_uniform(ctx,
+                             shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
                              index, offset, type, count, elems, values);
       }
    }
@@ -1056,11 +1057,12 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
 
    uniform = &shProg->Uniforms->Uniforms[location];
 
-   if (shProg->VertexProgram) {
+   if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
       /* convert uniform location to program parameter index */
       GLint index = uniform->VertPos;
       if (index >= 0) {
-         set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base,
+         set_program_uniform_matrix(ctx,
+                                   shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
                                     index, offset,
                                     count, rows, cols, transpose, values);
       }
index 2e1b8fba30680fa4c9f8f480df7912a1d42d61b5..652e7067d57d695e5bcbef615dad1373440343fb 100644 (file)
@@ -3294,8 +3294,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
          case GL_VERTEX_SHADER:
             ((struct gl_vertex_program *)linked_prog)->UsesClipDistance
                = prog->Vert.UsesClipDistance;
-            _mesa_reference_vertprog(ctx, &prog->VertexProgram,
-                                     (struct gl_vertex_program *)linked_prog);
+            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+                                   linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
                                                  linked_prog);
             break;
@@ -3427,7 +3427,6 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       }
    }
 
-   _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
    _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
    _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
 
index d8ef8a3ce1988233d09a00296c1ac6fe72f84ca3..01e4d88baf78654d1595e560eee5c85734b8ce26 100644 (file)
@@ -5184,8 +5184,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 
          switch (prog->_LinkedShaders[i]->Type) {
          case GL_VERTEX_SHADER:
-            _mesa_reference_vertprog(ctx, &prog->VertexProgram,
-                                     (struct gl_vertex_program *)linked_prog);
+            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+                                    linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
                                                  linked_prog);
             if (!ok) {
index a4f47edfcd3ac2439af79872f8dc0181d927d198..5211043de0415c1207cac034e9b48896fd0c8c02 100644 (file)
@@ -1153,8 +1153,8 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
             destroy_program_variants(st, shProg->Shaders[i]->Program);
          }
 
-         destroy_program_variants(st, (struct gl_program *)
-                                  shProg->VertexProgram);
+         destroy_program_variants(st,
+                                  shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
          destroy_program_variants(st, (struct gl_program *)
                                   shProg->FragmentProgram);
          destroy_program_variants(st, (struct gl_program *)