i965: use _Current pointer instead of Current pointer.
authorXiang, Haihao <haihao.xiang@intel.com>
Fri, 29 Feb 2008 03:15:02 +0000 (11:15 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 29 Feb 2008 03:16:21 +0000 (11:16 +0800)
fix double free issue(bug#14710). It also corrects glsl/bitmap demo behavior.

src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_metaops.c
src/mesa/drivers/dri/i965/brw_vs_tnl.c
src/mesa/main/texenvprogram.c

index 349b8be49bd78bf502419a9ab95dd7a15259766a..1601f6dd248054d67f332e5cb99d77ff253b710a 100644 (file)
 
 static void brwUseProgram(GLcontext *ctx, GLuint program)
 {
-        struct brw_context *brw = brw_context(ctx);
-        struct gl_shader_program *sh_prog;
-        _mesa_use_program(ctx, program);
-        sh_prog = ctx->Shader.CurrentProgram;
-        if (sh_prog) {
-           if (sh_prog->VertexProgram) {
-               brw->attribs.VertexProgram->Current = sh_prog->VertexProgram;
-               sh_prog->VertexProgram->Base.RefCount++;
-               ctx->VertexProgram.Enabled = GL_TRUE;
-           }else
-               ctx->VertexProgram.Enabled = GL_FALSE;
-               
-           if (sh_prog->FragmentProgram) {
-               brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram;
-               sh_prog->FragmentProgram->Base.RefCount++;
-               ctx->FragmentProgram.Enabled = GL_TRUE;
-           } else
-               ctx->FragmentProgram.Enabled = GL_FALSE;
-       }
+   _mesa_use_program(ctx, program);
 }
 
 static void brwInitProgFuncs( struct dd_function_table *functions )
index 3f5df27b887353720d3cf4e53212ade1af45f626..dd62be34f4a3dfbbdb05e3262b571403a53c2862 100644 (file)
@@ -196,7 +196,7 @@ static void init_metaops_state( struct brw_context *brw )
                                  vp_prog, strlen(vp_prog),
                                  brw->metaops.vp);
 
-   brw->metaops.attribs.VertexProgram->Current = brw->metaops.vp;
+   brw->metaops.attribs.VertexProgram->_Current = brw->metaops.vp;
    brw->metaops.attribs.VertexProgram->_Enabled = GL_TRUE;
 
    brw->metaops.attribs.FragmentProgram->_Current = brw->metaops.fp;
index d58fd4c0da29f6abc868e49278c029d9bb7acb01..160fc34cb5e58b4eb6370478e421f9f03c99e182 100644 (file)
@@ -1589,7 +1589,7 @@ static void update_tnl_program( struct brw_context *brw )
    struct gl_vertex_program *old = brw->tnl_program;
 
    /* _NEW_PROGRAM */
-   if (brw->attribs.VertexProgram->_Enabled
+   if (brw->attribs.VertexProgram->_Current
       return;
       
    /* Grab all the relevent state and put it in a single structure:
@@ -1653,8 +1653,8 @@ static void update_active_vertprog( struct brw_context *brw )
    const struct gl_vertex_program *prev = brw->vertex_program;
 
    /* NEW_PROGRAM */
-   if (brw->attribs.VertexProgram->_Enabled) {
-      brw->vertex_program = brw->attribs.VertexProgram->Current;
+   if (brw->attribs.VertexProgram->_Current) {
+      brw->vertex_program = brw->attribs.VertexProgram->_Current;
    }
    else {
       /* BRW_NEW_TNL_PROGRAM */
index de7d070b32c8de3c11303e8bf6276b279e75bc28..b1c00a36ac6ab745c71392bb191eca6e5fbf023b 100644 (file)
@@ -1271,7 +1271,8 @@ _mesa_UpdateTexEnvProgram( GLcontext *ctx )
       }
    } 
    else {
-      ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
+      /* _Current pointer has been updated in update_program */
+      // ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
    }
 
    /* Tell the driver about the change.  Could define a new target for