mesa: Use gl_shader_program::_LinkedShaders instead of FragmentProgram
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 20 Aug 2011 22:00:36 +0000 (15:00 -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_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/main/context.c
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 e073eaaec2db8eb918bf7012f5b8b961cbe19d57..6d17839df95e2287afbba8489c0639238dd05e26 100644 (file)
@@ -1828,12 +1828,14 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_wm_prog_key key;
-   struct gl_fragment_program *fp = prog->FragmentProgram;
-   struct brw_fragment_program *bfp = brw_fragment_program(fp);
 
-   if (!fp)
+   if (!prog->_LinkedShaders[MESA_SHADER_FRAGMENT])
       return true;
 
+   struct gl_fragment_program *fp = (struct gl_fragment_program *)
+      prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+   struct brw_fragment_program *bfp = brw_fragment_program(fp);
+
    memset(&key, 0, sizeof(key));
 
    if (fp->UsesKill)
index 56181a37c9f20b82566e7a77e8cb7c73821b4ddc..4035186af0037cb4832d365f08be2dffe94bce06 100644 (file)
@@ -347,7 +347,8 @@ public:
       this->c = c;
       this->p = &c->func;
       this->brw = p->brw;
-      this->fp = prog->FragmentProgram;
+      this->fp = (struct gl_fragment_program *)
+        prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
       this->prog = prog;
       this->intel = &brw->intel;
       this->ctx = &intel->ctx;
index fdb2d15c60912bdff7e0561218363f2ed7a78a46..f6af7815bb721ddeeef8fc596c94ab6bfba454e0 100644 (file)
@@ -224,7 +224,7 @@ bool do_wm_prog(struct brw_context *brw,
 
    brw_init_compile(brw, &c->func, c);
 
-   if (prog && prog->FragmentProgram) {
+   if (prog && prog->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
       if (!brw_wm_fs_emit(brw, c, prog))
         return false;
    } else {
index 6ef394fe7300a1fd72c71be4bb912b97c3bd24ce..fc52e8c1562d08c656d26d0e56d62aef368c4fbb 100644 (file)
@@ -1860,8 +1860,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
            break;
 
         case GL_FRAGMENT_SHADER:
-           _mesa_append_uniforms_to_file(sh,
-                                         &shProg[i]->FragmentProgram->Base);
+           _mesa_append_uniforms_to_file(sh, sh->Program);
            break;
         }
       }
index c7183b39935a2323ccb61ca3fde853bcc2dc0122..749324d76292ceb2b35c53793bed05917aec605f 100644 (file)
@@ -2171,7 +2171,6 @@ struct gl_shader_program
    } Vert;
 
    /* post-link info: */
-   struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
    struct gl_uniform_list *Uniforms;
    struct gl_program_parameter_list *Varying;
    GLboolean LinkStatus;   /**< GL_LINK_STATUS */
index c70fda1e205fba51ef7b623f4e7a6efe39d0329d..1583520391dde93ad31f03c97c8eebed0ec34b0e 100644 (file)
@@ -811,8 +811,9 @@ print_shader_info(const struct gl_shader_program *shProg)
    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->_LinkedShaders[MESA_SHADER_FRAGMENT])
+      printf("  frag prog %u\n",
+            shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Id);
    if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY])
       printf("  geom prog %u\n",
             shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program->Id);
@@ -967,7 +968,7 @@ validate_shader_program(const struct gl_shader_program *shProg,
 {
    const struct gl_shader *vs = shProg->_LinkedShaders[MESA_SHADER_VERTEX];
    const struct gl_shader *gs = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY];
-   const struct gl_fragment_program *fp = shProg->FragmentProgram;
+   const struct gl_shader *fs = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
 
    if (!shProg->LinkStatus) {
       return GL_FALSE;
@@ -999,7 +1000,7 @@ validate_shader_program(const struct gl_shader_program *shProg,
    if (gs && !validate_samplers(gs->Program, errMsg)) {
       return GL_FALSE;
    }
-   if (fp && !validate_samplers(&fp->Base, errMsg)) {
+   if (fs && !validate_samplers(fs->Program, errMsg)) {
       return GL_FALSE;
    }
 
index bebf736911fde11a6584f720de07b213755f6fab..ccf7efddbdef49dca8805636b6e64853dcf951e1 100644 (file)
@@ -275,8 +275,6 @@ void
 _mesa_clear_shader_program_data(struct gl_context *ctx,
                                 struct gl_shader_program *shProg)
 {
-   _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
-
    if (shProg->Uniforms) {
       _mesa_free_uniform_list(shProg->Uniforms);
       shProg->Uniforms = NULL;
index 80502e59af79bba08d0c630b7ad3248febf6583e..bbe90a32e086e35e7ad46edb30650c9d78e9ed5f 100644 (file)
@@ -246,10 +246,12 @@ update_program(struct gl_context *ctx)
     * come up, or matter.
     */
 
-   if (fsProg && fsProg->LinkStatus && fsProg->FragmentProgram) {
+   if (fsProg && fsProg->LinkStatus
+       && fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
       /* Use GLSL fragment shader */
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
-                               fsProg->FragmentProgram);
+                              (struct gl_fragment_program *)
+                              fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
    }
    else if (ctx->FragmentProgram._Enabled) {
       /* Use user-defined fragment program */
index ee99e507c97f387abeba5126a1bab70ca2a18bc3..9f14d8a0d17a46f9d10a5b70838e336bd6b4f726 100644 (file)
@@ -489,7 +489,7 @@ static void
 update_texture_state( struct gl_context *ctx )
 {
    GLuint unit;
-   struct gl_fragment_program *fprog = NULL;
+   struct gl_program *fprog = NULL;
    struct gl_program *vprog = NULL;
    GLbitfield enabledFragUnits = 0x0;
 
@@ -505,10 +505,10 @@ update_texture_state( struct gl_context *ctx )
 
    if (ctx->Shader.CurrentFragmentProgram &&
        ctx->Shader.CurrentFragmentProgram->LinkStatus) {
-      fprog = ctx->Shader.CurrentFragmentProgram->FragmentProgram;
+      fprog = ctx->Shader.CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
    }
    else if (ctx->FragmentProgram._Enabled) {
-      fprog = ctx->FragmentProgram.Current;
+      fprog = &ctx->FragmentProgram.Current->Base;
    }
 
    /* FINISHME: Geometry shader texture accesses should also be considered
@@ -544,7 +544,7 @@ update_texture_state( struct gl_context *ctx )
       }
 
       if (fprog) {
-         enabledFragTargets |= fprog->Base.TexturesUsed[unit];
+         enabledFragTargets |= fprog->TexturesUsed[unit];
       }
       else {
          /* fixed-function fragment program */
@@ -611,7 +611,7 @@ update_texture_state( struct gl_context *ctx )
    if (fprog) {
       const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
       ctx->Texture._EnabledCoordUnits
-         = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask;
+         = (fprog->InputsRead >> FRAG_ATTRIB_TEX0) & coordMask;
    }
    else {
       ctx->Texture._EnabledCoordUnits = enabledFragUnits;
index 1e395f7bbed5bc53f9a21eb701888d6bbbc15ca0..7bdeec743d61ce6f2615aa07dbea5a2a1404deea 100644 (file)
@@ -185,7 +185,7 @@ find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index,
    else {
       pos = shProg->Uniforms->Uniforms[index].FragPos;
       if (pos >= 0) {
-         prog = &shProg->FragmentProgram->Base;
+         prog = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
       }
       else {
          pos = shProg->Uniforms->Uniforms[index].GeomPos;
@@ -921,11 +921,12 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
       }
    }
 
-   if (shProg->FragmentProgram) {
+   if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
       /* convert uniform location to program parameter index */
       GLint index = uniform->FragPos;
       if (index >= 0) {
-         set_program_uniform(ctx, &shProg->FragmentProgram->Base,
+         set_program_uniform(ctx,
+                            shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program,
                              index, offset, type, count, elems, values);
       }
    }
@@ -1069,11 +1070,12 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
       }
    }
 
-   if (shProg->FragmentProgram) {
+   if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
       /* convert uniform location to program parameter index */
       GLint index = uniform->FragPos;
       if (index >= 0) {
-         set_program_uniform_matrix(ctx, &shProg->FragmentProgram->Base,
+         set_program_uniform_matrix(ctx,
+                                   shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program,
                                     index, offset,
                                     count, rows, cols, transpose, values);
       }
index ddc4ab83364054cc929c28f0cff1da2640c4177f..b9b7b1adbe9ebf653459f481aed5c181f529ff52 100644 (file)
@@ -3300,8 +3300,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                                  linked_prog);
             break;
          case GL_FRAGMENT_SHADER:
-            _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
-                                     (struct gl_fragment_program *)linked_prog);
+            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+                                   linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
                                                  linked_prog);
             break;
@@ -3427,8 +3427,6 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       }
    }
 
-   _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
-
    if (prog->LinkStatus) {
       link_shaders(ctx, prog);
    }
index 56bc7f8fac5b654d834a333755b883303fa8997f..80a593071b44fdd100a1908aa8c1b2f65cc8d11d 100644 (file)
@@ -5193,8 +5193,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
             }
             break;
          case GL_FRAGMENT_SHADER:
-            _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
-                                     (struct gl_fragment_program *)linked_prog);
+            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+                                   linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
                                                  linked_prog);
             if (!ok) {
index ba9980854d0883d5861dcd3bb608b819909d2bd9..4162bb99abf75fb5dfadbd9a5e2bcc4b3ce399e1 100644 (file)
@@ -1155,8 +1155,8 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
 
          destroy_program_variants(st,
                                   shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
-         destroy_program_variants(st, (struct gl_program *)
-                                  shProg->FragmentProgram);
+         destroy_program_variants(st,
+                                  shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
          destroy_program_variants(st,
                                   shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program);
       }