Merge commit 'origin/gallium-master-merge'
authorBrian Paul <brianp@vmware.com>
Tue, 10 Feb 2009 23:44:02 +0000 (16:44 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 10 Feb 2009 23:44:02 +0000 (16:44 -0700)
This is the big merge of the gallium-0.2 branch into master.
gallium-master-merge was just the staging area for it.
Both gallium-0.2 and gallium-master-merge are considered closed now.

Conflicts:

progs/demos/Makefile
src/mesa/main/state.c
src/mesa/main/texenvprogram.c

1  2 
progs/demos/Makefile
src/mesa/main/context.c
src/mesa/main/fbobject.c
src/mesa/main/mtypes.h
src/mesa/main/state.c
src/mesa/main/texenvprogram.c
src/mesa/main/teximage.c

diff --combined progs/demos/Makefile
index 4396c36a1924e30524e2d2664d5b77c3f3882971,e636cbd9ad9eefda31c2247ce19970724467e599..32c607212321af94b57c8096b4b54ace495be498
@@@ -5,10 -5,16 +5,10 @@@ include $(TOP)/configs/curren
  
  INCDIR = $(TOP)/include
  
 -OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa -lGLU -lGL $(APP_LIB_DEPS)
 -
 -OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
 -
 -OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
 -
  LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
        $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
  
- LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
+ LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
        $(APP_LIB_DEPS)
  
  PROGS = \
@@@ -60,6 -66,7 +60,7 @@@
        texdown \
        texenv \
        texobj \
+       textures \
        trispd \
        tunnel \
        tunnel2 \
@@@ -75,7 -82,7 +76,7 @@@
  
  # make executable from .c file:
  .c: $(LIB_DEP) readtex.o
-       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@
  
  
  ##### TARGETS #####
@@@ -91,7 -98,7 +92,7 @@@ readtex.h: $(TOP)/progs/util/readtex.
        cp $< .
  
  readtex.o: readtex.c readtex.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
  
  
  showbuffer.c: $(TOP)/progs/util/showbuffer.c
@@@ -101,7 -108,7 +102,7 @@@ showbuffer.h: $(TOP)/progs/util/showbuf
        cp $< .
  
  showbuffer.o: showbuffer.c showbuffer.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c
  
  
  trackball.c: $(TOP)/progs/util/trackball.c
@@@ -111,7 -118,7 +112,7 @@@ trackball.h: $(TOP)/progs/util/trackbal
        cp $< .
  
  trackball.o: trackball.c trackball.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) trackball.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trackball.c
  
  
  extfuncs.h:  $(TOP)/progs/util/extfuncs.h
  
  
  reflect: reflect.o showbuffer.o readtex.o
-       $(CC) $(CFLAGS) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(LIBS) -o $@
  
  reflect.o: reflect.c showbuffer.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
  
  
  shadowtex: shadowtex.o showbuffer.o
-       $(CC) $(CFLAGS) $(LDFLAGS) shadowtex.o showbuffer.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) shadowtex.o showbuffer.o $(LIBS) -o $@
  
  shadowtex.o: shadowtex.c showbuffer.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
  
  
  gloss: gloss.o trackball.o readtex.o
-       $(CC) $(CFLAGS) $(LDFLAGS) gloss.o trackball.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) gloss.o trackball.o readtex.o $(LIBS) -o $@
  
  gloss.o: gloss.c trackball.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) gloss.c
  
  
  engine: engine.o trackball.o readtex.o
-       $(CC) $(CFLAGS) $(LDFLAGS) engine.o trackball.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) engine.o trackball.o readtex.o $(LIBS) -o $@
  
  engine.o: engine.c trackball.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) engine.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c
  
  
  fslight: fslight.o
-       $(CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@
  
  fslight.o: fslight.c extfuncs.h
-       $(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) fslight.c
  
  rain: particles.o rain.o readtex.o
        $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
diff --combined src/mesa/main/context.c
index 62c44733564eabc428de92e46940edffd6f80175,a315091a20d0ce8471122c9cfc8e66a449f7d1f0..39c7fa037e014ed48c69cb7150b1b8d5fe4ade58
  #include "glapi/glthread.h"
  #include "glapi/glapioffsets.h"
  #include "glapi/glapitable.h"
- #if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
  #include "shader/program.h"
- #endif
  #include "shader/shader_api.h"
  #if FEATURE_ATI_fragment_shader
  #include "shader/atifragshader.h"
@@@ -186,9 -184,11 +184,11 @@@ GLfloat _mesa_ubyte_to_float_color_tab[
   * We have to finish any pending rendering.
   */
  void
- _mesa_notifySwapBuffers(__GLcontext *gc)
+ _mesa_notifySwapBuffers(__GLcontext *ctx)
  {
-    FLUSH_VERTICES( gc, 0 );
+    if (ctx->Driver.Flush) {
+       ctx->Driver.Flush(ctx);
+    }
  }
  
  
@@@ -611,6 -611,7 +611,7 @@@ delete_program_cb(GLuint id, void *data
     ctx->Driver.DeleteProgram(ctx, prog);
  }
  
+ #if FEATURE_ATI_fragment_shader
  /**
   * Callback for deleting an ATI fragment shader object.
   * Called by _mesa_HashDeleteAll().
@@@ -622,6 -623,7 +623,7 @@@ delete_fragshader_cb(GLuint id, void *d
     GLcontext *ctx = (GLcontext *) userData;
     _mesa_delete_ati_fragment_shader(ctx, shader);
  }
+ #endif
  
  /**
   * Callback for deleting a buffer object.  Called by _mesa_HashDeleteAll().
@@@ -712,7 -714,6 +714,6 @@@ delete_renderbuffer_cb(GLuint id, void 
  }
  
  
  /**
   * Deallocate a shared state object and all children structures.
   *
@@@ -818,11 -819,33 +819,33 @@@ _mesa_init_current(GLcontext *ctx
  
  
  /**
-  * Init vertex/fragment program native limits from logical limits.
+  * Init vertex/fragment program limits.
+  * Important: drivers should override these with actual limits.
   */
  static void
- init_natives(struct gl_program_constants *prog)
+ init_program_limits(GLenum type, struct gl_program_constants *prog)
  {
+    prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS;
+    prog->MaxAluInstructions = MAX_PROGRAM_INSTRUCTIONS;
+    prog->MaxTexInstructions = MAX_PROGRAM_INSTRUCTIONS;
+    prog->MaxTexIndirections = MAX_PROGRAM_INSTRUCTIONS;
+    prog->MaxTemps = MAX_PROGRAM_TEMPS;
+    prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
+    prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
+    prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
+    if (type == GL_VERTEX_PROGRAM_ARB) {
+       prog->MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS;
+       prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
+       prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
+    }
+    else {
+       prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+       prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
+       prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
+    }
+    /* copy the above limits to init native limits */
     prog->MaxNativeInstructions = prog->MaxInstructions;
     prog->MaxNativeAluInstructions = prog->MaxAluInstructions;
     prog->MaxNativeTexInstructions = prog->MaxTexInstructions;
@@@ -881,33 -904,10 +904,10 @@@ _mesa_init_constants(GLcontext *ctx
     ctx->Const.MaxViewportWidth = MAX_WIDTH;
     ctx->Const.MaxViewportHeight = MAX_HEIGHT;
  #if FEATURE_ARB_vertex_program
-    ctx->Const.VertexProgram.MaxInstructions = MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS;
-    ctx->Const.VertexProgram.MaxAluInstructions = 0;
-    ctx->Const.VertexProgram.MaxTexInstructions = 0;
-    ctx->Const.VertexProgram.MaxTexIndirections = 0;
-    ctx->Const.VertexProgram.MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
-    ctx->Const.VertexProgram.MaxTemps = MAX_PROGRAM_TEMPS;
-    ctx->Const.VertexProgram.MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS;
-    ctx->Const.VertexProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
-    ctx->Const.VertexProgram.MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
-    ctx->Const.VertexProgram.MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
-    ctx->Const.VertexProgram.MaxUniformComponents = 4 * MAX_UNIFORMS;
-    init_natives(&ctx->Const.VertexProgram);
+    init_program_limits(GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram);
  #endif
  #if FEATURE_ARB_fragment_program
-    ctx->Const.FragmentProgram.MaxInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS;
-    ctx->Const.FragmentProgram.MaxAluInstructions = MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS;
-    ctx->Const.FragmentProgram.MaxTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS;
-    ctx->Const.FragmentProgram.MaxTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS;
-    ctx->Const.FragmentProgram.MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
-    ctx->Const.FragmentProgram.MaxTemps = MAX_PROGRAM_TEMPS;
-    ctx->Const.FragmentProgram.MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
-    ctx->Const.FragmentProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
-    ctx->Const.FragmentProgram.MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
-    ctx->Const.FragmentProgram.MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
-    ctx->Const.FragmentProgram.MaxUniformComponents = 4 * MAX_UNIFORMS;
-    init_natives(&ctx->Const.FragmentProgram);
+    init_program_limits(GL_FRAGMENT_PROGRAM_ARB, &ctx->Const.FragmentProgram);
  #endif
     ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
     ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
@@@ -1066,6 -1066,7 +1066,7 @@@ init_attrib_groups(GLcontext *ctx
     /* Miscellaneous */
     ctx->NewState = _NEW_ALL;
     ctx->ErrorValue = (GLenum) GL_NO_ERROR;
+    ctx->varying_vp_inputs = ~0;
  
     return GL_TRUE;
  }
@@@ -1165,7 -1166,7 +1166,7 @@@ _mesa_initialize_context(GLcontext *ctx
                           const struct dd_function_table *driverFunctions,
                           void *driverContext)
  {
-    ASSERT(driverContext);
+    /*ASSERT(driverContext);*/
     assert(driverFunctions->NewTextureObject);
     assert(driverFunctions->FreeTexImageData);
  
@@@ -1269,7 -1270,7 +1270,7 @@@ _mesa_create_context(const GLvisual *vi
     GLcontext *ctx;
  
     ASSERT(visual);
-    ASSERT(driverContext);
+    /*ASSERT(driverContext);*/
  
     ctx = (GLcontext *) _mesa_calloc(sizeof(GLcontext));
     if (!ctx)
@@@ -1304,10 -1305,10 +1305,10 @@@ _mesa_free_context_data( GLcontext *ct
     }
  
     /* unreference WinSysDraw/Read buffers */
 -   _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
 -   _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
 -   _mesa_unreference_framebuffer(&ctx->DrawBuffer);
 -   _mesa_unreference_framebuffer(&ctx->ReadBuffer);
 +   _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL);
 +   _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL);
 +   _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL);
 +   _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL);
  
     _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
     _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
     _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
     _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL);
  
+ #if FEATURE_attrib_stack
     _mesa_free_attrib_data(ctx);
+ #endif
     _mesa_free_lighting_data( ctx );
  #if FEATURE_evaluators
     _mesa_free_eval_data( ctx );
@@@ -1634,7 -1637,22 +1637,22 @@@ _mesa_make_current( GLcontext *newCtx, 
            * or not bound to a user-created FBO.
            */
           if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
+             /* KW: merge conflict here, revisit. 
+              */
+             /* fix up the fb fields - these will end up wrong otherwise
+              * if the DRIdrawable changes, and everything relies on them.
+              * This is a bit messy (same as needed in _mesa_BindFramebufferEXT)
+              */
+             unsigned int i;
+             GLenum buffers[MAX_DRAW_BUFFERS];
              _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
+             for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) {
+                buffers[i] = newCtx->Color.DrawBuffer[i];
+             }
+             _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL);
           }
           if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
              _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
diff --combined src/mesa/main/fbobject.c
index f5e17c76750b5a78f5b353f3a5a35dd7252a8d0f,ae823262a28343524d638885585a0a0595147a68..c3cdc110379c5a882a03b7d34f1c45fcc31ff454
@@@ -193,7 -193,7 +193,7 @@@ _mesa_remove_attachment(GLcontext *ctx
     if (att->Type == GL_TEXTURE) {
        ASSERT(att->Texture);
        if (ctx->Driver.FinishRenderTexture) {
-          /* tell driver we're done rendering to this texobj */
+          /* tell driver that we're done rendering to this texture. */
           ctx->Driver.FinishRenderTexture(ctx, att);
        }
        _mesa_reference_texobj(&att->Texture, NULL); /* unbind */
@@@ -1268,7 -1268,7 +1268,7 @@@ _mesa_DeleteFramebuffersEXT(GLsizei n, 
                 /* But the object will not be freed until it's no longer
                  * bound in any context.
                  */
 -               _mesa_unreference_framebuffer(&fb);
 +               _mesa_reference_framebuffer(&fb, NULL);
            }
         }
        }
diff --combined src/mesa/main/mtypes.h
index 92bce76ad512ce5121dd5a295161ec5120c6d083,67f7d463098a41a7d540b5d60a1acc167579d5f2..be982afe39ce17a77d798c313ec65c3ccffbdc4d
@@@ -125,6 -125,8 +125,8 @@@ struct gl_program_cache
  struct gl_texture_format;
  struct gl_texture_image;
  struct gl_texture_object;
+ struct st_context;
+ struct pipe_surface;
  typedef struct __GLcontextRec GLcontext;
  typedef struct __GLcontextModesRec GLvisual;
  typedef struct gl_framebuffer GLframebuffer;
@@@ -1579,7 -1581,6 +1581,6 @@@ struct gl_texture_attri
  
     struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
  
-    /** Proxy texture objects */
     struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
  
     /** GL_EXT_shared_texture_palette */
@@@ -2003,6 -2004,8 +2004,8 @@@ struct gl_vertex_program_stat
     GLboolean CallbackEnabled;
     GLuint CurrentPosition;
  #endif
+    GLboolean _Overriden;
  };
  
  
@@@ -2760,6 -2763,7 +2763,7 @@@ struct gl_matrix_stac
  #define _NEW_MULTISAMPLE        0x2000000  /**< __GLcontextRec::Multisample */
  #define _NEW_TRACK_MATRIX       0x4000000  /**< __GLcontextRec::VertexProgram */
  #define _NEW_PROGRAM            0x8000000  /**< __GLcontextRec::VertexProgram */
+ #define _NEW_CURRENT_ATTRIB     0x10000000  /**< __GLcontextRec::Current */
  #define _NEW_ALL ~0
  /*@}*/
  
  /*@}*/
  
  
 +/**
 + * Composite state flags
 + */
 +/*@{*/
  #define _MESA_NEW_NEED_EYE_COORDS         (_NEW_LIGHT |               \
                                             _NEW_TEXTURE |     \
                                             _NEW_POINT |               \
  #define _MESA_NEW_NEED_NORMALS            (_NEW_LIGHT |               \
                                             _NEW_TEXTURE)
  
 -#define _IMAGE_NEW_TRANSFER_STATE         (_NEW_PIXEL | _NEW_COLOR_MATRIX)
 +#define _MESA_NEW_TRANSFER_STATE          (_NEW_PIXEL |               \
 +                                           _NEW_COLOR_MATRIX)
 +/*@}*/
  
  
  
@@@ -3094,6 -3092,8 +3098,8 @@@ struct __GLcontextRe
     GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
     GLbitfield NewState;      /**< bitwise-or of _NEW_* flags */
  
+    GLbitfield varying_vp_inputs;  /**< mask of VERT_BIT_* flags */
     /** \name Derived state */
     /*@{*/
     /** Bitwise-or of DD_* flags.  Note that this bitfield may be used before
     void *swsetup_context;
     void *swtnl_context;
     void *swtnl_im;
-    void *acache_context;
+    struct st_context *st;
     void *aelt_context;
     /*@}*/
  };
diff --combined src/mesa/main/state.c
index 3cf70d6a3ca60d66c5d6c89c06ae07c5bd062964,718cd9984767653dbc657df3c628a00f45a64122..0a39279bff326bffa116e60bfcfad99273ff33f5
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Mesa 3-D graphics library
-  * Version:  7.1
+  * Version:  7.3
   *
   * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
   *
@@@ -173,16 -173,13 +173,16 @@@ update_arrays( GLcontext *ctx 
  }
  
  
 +/**
 + * Update the following fields:
 + *   ctx->VertexProgram._Enabled
 + *   ctx->FragmentProgram._Enabled
 + *   ctx->ATIFragmentShader._Enabled
 + * This needs to be done before texture state validation.
 + */
  static void
 -update_program(GLcontext *ctx)
 +update_program_enables(GLcontext *ctx)
  {
 -   const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
 -   const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
 -   const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
 -
     /* These _Enabled flags indicate if the program is enabled AND valid. */
     ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
        && ctx->VertexProgram.Current->Base.Instructions;
        && ctx->FragmentProgram.Current->Base.Instructions;
     ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
        && ctx->ATIFragmentShader.Current->Instructions[0];
 +}
 +
 +
 +/**
 + * Update vertex/fragment program state.  In particular, update these fields:
 + *   ctx->VertexProgram._Current
 + *   ctx->VertexProgram._TnlProgram,
 + * These point to the highest priority enabled vertex/fragment program or are
 + * NULL if fixed-function processing is to be done.
 + *
 + * This function needs to be called after texture state validation in case
 + * we're generating a fragment program from fixed-function texture state.
 + */
 +static void
 +update_program(GLcontext *ctx)
 +{
 +   const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
 +   const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
 +   const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
  
     /*
      * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
@@@ -448,34 -426,19 +448,37 @@@ _mesa_update_state_locked( GLcontext *c
     GLbitfield new_state = ctx->NewState;
     GLbitfield prog_flags = _NEW_PROGRAM;
  
+    if (new_state == _NEW_CURRENT_ATTRIB) 
+       goto out;
     if (MESA_VERBOSE & VERBOSE_STATE)
        _mesa_print_state("_mesa_update_state", new_state);
  
 +   /* Determine which state flags effect vertex/fragment program state */
 +   if (ctx->FragmentProgram._MaintainTexEnvProgram) {
 +      prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
 +   }
 +   if (ctx->VertexProgram._MaintainTnlProgram) {
 +      prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
 +                     _NEW_TRANSFORM | _NEW_POINT |
 +                     _NEW_FOG | _NEW_LIGHT |
 +                     _MESA_NEW_NEED_EYE_COORDS);
 +   }
 +
 +   /*
 +    * Now update derived state info
 +    */
 +
 +   if (new_state & prog_flags)
 +      update_program_enables( ctx );
 +
     if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
        _mesa_update_modelview_project( ctx, new_state );
  
     if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
        _mesa_update_texture( ctx, new_state );
  
-    if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL))
+    if (new_state & _NEW_BUFFERS)
        _mesa_update_framebuffer(ctx);
  
     if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
        _mesa_update_stencil( ctx );
  
  #if FEATURE_pixel_transfer
 -   if (new_state & _IMAGE_NEW_TRANSFER_STATE)
 +   if (new_state & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_pixel( ctx, new_state );
  #endif
  
     if (new_state & _MESA_NEW_NEED_EYE_COORDS) 
        _mesa_update_tnl_spaces( ctx, new_state );
  
 -   if (ctx->FragmentProgram._MaintainTexEnvProgram) {
 -      prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE_MATRIX | _NEW_LIGHT |
 -                     _NEW_RENDERMODE |
 -                     _NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
 -   }
 -   if (ctx->VertexProgram._MaintainTnlProgram) {
 -      prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
 -                     _NEW_RENDERMODE |
 -                     _NEW_TRANSFORM | _NEW_POINT |
 -                     _NEW_FOG | _NEW_LIGHT |
 -                     _MESA_NEW_NEED_EYE_COORDS);
 -   }
     if (new_state & prog_flags)
        update_program( ctx );
  
 -
 -
     /*
      * Give the driver a chance to act upon the new_state flags.
      * The driver might plug in different span functions, for example.
      * Set ctx->NewState to zero to avoid recursion if
      * Driver.UpdateState() has to call FLUSH_VERTICES().  (fixed?)
      */
+  out:
     new_state = ctx->NewState;
     ctx->NewState = 0;
     ctx->Driver.UpdateState(ctx, new_state);
@@@ -556,3 -534,59 +560,59 @@@ _mesa_update_state( GLcontext *ctx 
     _mesa_update_state_locked(ctx);
     _mesa_unlock_context_textures(ctx);
  }
+ /**
+  * Want to figure out which fragment program inputs are actually
+  * constant/current values from ctx->Current.  These should be
+  * referenced as a tracked state variable rather than a fragment
+  * program input, to save the overhead of putting a constant value in
+  * every submitted vertex, transferring it to hardware, interpolating
+  * it across the triangle, etc...
+  *
+  * When there is a VP bound, just use vp->outputs.  But when we're
+  * generating vp from fixed function state, basically want to
+  * calculate:
+  *
+  * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) | 
+  *                 potential_vp_outputs )
+  *
+  * Where potential_vp_outputs is calculated by looking at enabled
+  * texgen, etc.
+  * 
+  * The generated fragment program should then only declare inputs that
+  * may vary or otherwise differ from the ctx->Current values.
+  * Otherwise, the fp should track them as state values instead.
+  */
+ void
+ _mesa_set_varying_vp_inputs( GLcontext *ctx,
+                              GLbitfield varying_inputs )
+ {
+    if (ctx->varying_vp_inputs != varying_inputs) {
+       ctx->varying_vp_inputs = varying_inputs;
+       ctx->NewState |= _NEW_ARRAY;
+       /*_mesa_printf("%s %x\n", __FUNCTION__, varying_inputs);*/
+    }
+ }
+ /**
+  * Used by drivers to tell core Mesa that the driver is going to
+  * install/ use its own vertex program.  In particular, this will
+  * prevent generated fragment programs from using state vars instead
+  * of ordinary varyings/inputs.
+  */
+ void
+ _mesa_set_vp_override(GLcontext *ctx, GLboolean flag)
+ {
+    if (ctx->VertexProgram._Overriden != flag) {
+       ctx->VertexProgram._Overriden = flag;
+       /* Set one of the bits which will trigger fragment program
+        * regeneration:
+        */
+       ctx->NewState |= _NEW_ARRAY; 
+    }
+ }
index d1f03405c1db9b8b31d58bf0dbbbc704baed557d,10edfc8fb80ef71b06c392eb0c17adaeb83ff79b..af51a206a56c733f74d036328f7aac043e6a6cd8
@@@ -67,11 -67,9 +67,9 @@@ struct texenvprog_cache_ite
  
  
  /**
-  * This MAX is probably a bit generous, but that's OK.  There can be
-  * up to four instructions per texture unit (TEX + 3 for combine),
-  * then there's fog and specular add.
+  * Up to nine instructions per tex unit, plus fog, specular color.
   */
- #define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 4) + 12)
+ #define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12)
  
  #define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
  
@@@ -81,10 -79,12 +79,12 @@@ struct mode_opt 
  };
  
  struct state_key {
-    GLbitfield enabled_units;
+    GLuint nr_enabled_units:8;
+    GLuint enabled_units:8;
     GLuint separate_specular:1;
     GLuint fog_enabled:1;
     GLuint fog_mode:2;
+    GLuint inputs_available:12;
  
     struct {
        GLuint enabled:1;
@@@ -232,6 -232,8 +232,8 @@@ static GLuint translate_mode( GLenum en
  #define TEXTURE_UNKNOWN_INDEX 7
  static GLuint translate_tex_src_bit( GLbitfield bit )
  {
+    /* make sure number of switch cases is correct */
+    assert(NUM_TEXTURE_TARGETS == 7);
     switch (bit) {
     case TEXTURE_1D_BIT:   return TEXTURE_1D_INDEX;
     case TEXTURE_2D_BIT:   return TEXTURE_2D_INDEX;
     }
  }
  
+ #define VERT_BIT_TEX_ANY    (0xff << VERT_ATTRIB_TEX0)
+ #define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0)
+ /**
+  * Identify all possible varying inputs.  The fragment program will
+  * never reference non-varying inputs, but will track them via state
+  * constants instead.
+  *
+  * This function figures out all the inputs that the fragment program
+  * has access to.  The bitmask is later reduced to just those which
+  * are actually referenced.
+  */
+ static GLbitfield get_fp_input_mask( GLcontext *ctx )
+ {
+    const GLboolean vertexShader = (ctx->Shader.CurrentProgram &&
+                                    ctx->Shader.CurrentProgram->VertexProgram);
+    const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
+    GLbitfield fp_inputs = 0x0;
+    if (ctx->VertexProgram._Overriden) {
+       /* Somebody's messing with the vertex program and we don't have
+        * a clue what's happening.  Assume that it could be producing
+        * all possible outputs.
+        */
+       fp_inputs = ~0;
+    }
+    else if (ctx->RenderMode == GL_FEEDBACK) {
+       fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0);
+    }
+    else if (!(vertexProgram || vertexShader) ||
+             !ctx->VertexProgram._Current) {
+       /* Fixed function vertex logic */
+       GLbitfield varying_inputs = ctx->varying_vp_inputs;
+       /* These get generated in the setup routine regardless of the
+        * vertex program:
+        */
+       if (ctx->Point.PointSprite)
+          varying_inputs |= FRAG_BITS_TEX_ANY;
+       /* First look at what values may be computed by the generated
+        * vertex program:
+        */
+       if (ctx->Light.Enabled) {
+          fp_inputs |= FRAG_BIT_COL0;
+          if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+             fp_inputs |= FRAG_BIT_COL1;
+       }
+       fp_inputs |= (ctx->Texture._TexGenEnabled |
+                     ctx->Texture._TexMatEnabled) << FRAG_ATTRIB_TEX0;
+       /* Then look at what might be varying as a result of enabled
+        * arrays, etc:
+        */
+       if (varying_inputs & VERT_BIT_COLOR0) fp_inputs |= FRAG_BIT_COL0;
+       if (varying_inputs & VERT_BIT_COLOR1) fp_inputs |= FRAG_BIT_COL1;
+       fp_inputs |= (((varying_inputs & VERT_BIT_TEX_ANY) >> VERT_ATTRIB_TEX0) 
+                     << FRAG_ATTRIB_TEX0);
+    }
+    else {
+       /* calculate from vp->outputs */
+       struct gl_vertex_program *vprog;
+       GLbitfield vp_outputs;
+       /* Choose GLSL vertex shader over ARB vertex program.  Need this
+        * since vertex shader state validation comes after fragment state
+        * validation (see additional comments in state.c).
+        */
+       if (vertexShader)
+          vprog = ctx->Shader.CurrentProgram->VertexProgram;
+       else
+          vprog = ctx->VertexProgram._Current;
+       vp_outputs = vprog->Base.OutputsWritten;
+       /* These get generated in the setup routine regardless of the
+        * vertex program:
+        */
+       if (ctx->Point.PointSprite)
+          vp_outputs |= FRAG_BITS_TEX_ANY;
+       if (vp_outputs & (1 << VERT_RESULT_COL0)) fp_inputs |= FRAG_BIT_COL0;
+       if (vp_outputs & (1 << VERT_RESULT_COL1)) fp_inputs |= FRAG_BIT_COL1;
+       fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) >> VERT_RESULT_TEX0) 
+                     << FRAG_ATTRIB_TEX0);
+    }
+    
+    return fp_inputs;
+ }
  /**
   * Examine current texture environment state and generate a unique
   * key to identify it.
  static void make_state_key( GLcontext *ctx,  struct state_key *key )
  {
     GLuint i, j;
-       
+    GLbitfield inputs_referenced = FRAG_BIT_COL0;
+    GLbitfield inputs_available = get_fp_input_mask( ctx );
     memset(key, 0, sizeof(*key));
  
     for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
  
        key->unit[i].enabled = 1;
        key->enabled_units |= (1<<i);
+       key->nr_enabled_units = i+1;
+       inputs_referenced |= FRAG_BIT_TEX(i);
  
        key->unit[i].source_index = 
         translate_tex_src_bit(texUnit->_ReallyEnabled);                
        }
     }
        
-    if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+    if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
        key->separate_specular = 1;
+       inputs_referenced |= FRAG_BIT_COL1;
+    }
  
     if (ctx->Fog.Enabled) {
        key->fog_enabled = 1;
        key->fog_mode = translate_fog_mode(ctx->Fog.Mode);
+       inputs_referenced |= FRAG_BIT_FOGC; /* maybe */
     }
+    key->inputs_available = (inputs_available & inputs_referenced);
  }
  
- /* Use uregs to represent registers internally, translate to Mesa's
+ /**
+  * Use uregs to represent registers internally, translate to Mesa's
   * expected formats on emit.  
   *
   * NOTE: These are passed by value extensively in this file rather
@@@ -339,16 -447,16 +447,16 @@@ static const struct ureg undef = 
  };
  
  
- /* State used to build the fragment program:
+ /** State used to build the fragment program:
   */
  struct texenv_fragment_program {
     struct gl_fragment_program *program;
     GLcontext *ctx;
     struct state_key *state;
  
-    GLbitfield alu_temps;      /* Track texture indirections, see spec. */
-    GLbitfield temps_output;   /* Track texture indirections, see spec. */
-    GLbitfield temp_in_use;    /* Tracks temporary regs which are in use. */
+    GLbitfield alu_temps;      /**< Track texture indirections, see spec. */
+    GLbitfield temps_output;   /**< Track texture indirections, see spec. */
+    GLbitfield temp_in_use;    /**< Tracks temporary regs which are in use. */
     GLboolean error;
  
     struct ureg src_texture[MAX_TEXTURE_COORD_UNITS];   
      * else undef.
      */
  
-    struct ureg src_previous;  /* Reg containing color from previous 
+    struct ureg src_previous;  /**< Reg containing color from previous 
                                 * stage.  May need to be decl'd.
                                 */
  
-    GLuint last_tex_stage;     /* Number of last enabled texture unit */
+    GLuint last_tex_stage;     /**< Number of last enabled texture unit */
  
     struct ureg half;
     struct ureg one;
@@@ -438,7 -546,7 +546,7 @@@ static struct ureg get_tex_temp( struc
  {
     int bit;
     
-    /* First try to find availble temp not previously used (to avoid
+    /* First try to find available temp not previously used (to avoid
      * starting a new texture indirection).  According to the spec, the
      * ~p->temps_output isn't necessary, but will keep it there for
      * now:
  }
  
  
+ /** Mark a temp reg as being no longer allocatable. */
+ static void reserve_temp( struct texenv_fragment_program *p, struct ureg r )
+ {
+    if (r.file == PROGRAM_TEMPORARY)
+       p->temps_output |= (1 << r.idx);
+ }
  static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p )
  {
     GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps;
@@@ -501,11 -617,29 +617,29 @@@ static struct ureg register_param5( str
  #define register_param3(p,s0,s1,s2)    register_param5(p,s0,s1,s2,0,0)
  #define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
  
+ static GLuint frag_to_vert_attrib( GLuint attrib )
+ {
+    switch (attrib) {
+    case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0;
+    case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1;
+    default:
+       assert(attrib >= FRAG_ATTRIB_TEX0);
+       assert(attrib <= FRAG_ATTRIB_TEX7);
+       return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0;
+    }
+ }
  
  static struct ureg register_input( struct texenv_fragment_program *p, GLuint input )
  {
-    p->program->Base.InputsRead |= (1 << input);
-    return make_ureg(PROGRAM_INPUT, input);
+    if (p->state->inputs_available & (1<<input)) {
+       p->program->Base.InputsRead |= (1 << input);
+       return make_ureg(PROGRAM_INPUT, input);
+    }
+    else {
+       GLuint idx = frag_to_vert_attrib( input );
+       return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, idx );
+    }
  }
  
  
@@@ -556,10 -690,12 +690,12 @@@ emit_op(struct texenv_fragment_program 
  
     emit_dst( &inst->DstReg, dest, mask );
  
+ #if 0
     /* Accounting for indirection tracking:
      */
     if (dest.file == PROGRAM_TEMPORARY)
        p->temps_output |= 1 << dest.idx;
+ #endif
  
     return inst;
  }
@@@ -614,6 -750,10 +750,10 @@@ static struct ureg emit_texld( struct t
  
     p->program->Base.NumTexInstructions++;
  
+    /* Accounting for indirection tracking:
+     */
+    reserve_temp(p, dest);
     /* Is this a texture indirection?
      */
     if ((coord.file == PROGRAM_TEMPORARY &&
@@@ -638,14 -778,16 +778,16 @@@ static struct ureg register_const4f( st
  {
     GLfloat values[4];
     GLuint idx, swizzle;
+    struct ureg r;
     values[0] = s0;
     values[1] = s1;
     values[2] = s2;
     values[3] = s3;
     idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
                                       &swizzle );
-    ASSERT(swizzle == SWIZZLE_NOOP);
-    return make_ureg(PROGRAM_CONSTANT, idx);
+    r = make_ureg(PROGRAM_CONSTANT, idx);
+    r.swz = swizzle;
+    return r;
  }
  
  #define register_scalar_const(p, s0)    register_const4f(p, s0, s0, s0, s0)
@@@ -1031,6 -1173,7 +1173,7 @@@ static void load_texture( struct texenv
         p->src_texture[unit] = emit_texld( p, OPCODE_TXP,
                                            tmp, WRITEMASK_XYZW, 
                                            unit, dim, texcoord );
         if (p->state->unit[unit].shadow)
            p->program->Base.ShadowSamplers |= 1 << unit;
  
@@@ -1157,6 -1300,7 +1300,7 @@@ create_new_program(GLcontext *ctx, stru
        for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++)
         if (key->enabled_units & (1<<unit)) {
            p.src_previous = emit_texenv( &p, unit );
+             reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */
            release_temps(ctx, &p);     /* release all temps */
         }
     }
@@@ -1261,3 -1405,42 +1405,3 @@@ _mesa_get_fixed_func_fragment_program(G
  
     return prog;
  }
 -
 -
 -
 -/**
 - * If _MaintainTexEnvProgram is set we'll generate a fragment program that
 - * implements the current texture env/combine mode.
 - * This function generates that program and puts it into effect.
 - *
 - * XXX: remove this function.  currently only called by some drivers,
 - * not by mesa core.  We now handle this properly from inside mesa.
 - */
 -void
 -_mesa_UpdateTexEnvProgram( GLcontext *ctx )
 -{
 -   const struct gl_fragment_program *prev = ctx->FragmentProgram._Current;
 -      
 -   ASSERT(ctx->FragmentProgram._MaintainTexEnvProgram);
 -
 -   /* If a conventional fragment program/shader isn't in effect... */
 -   if (!ctx->FragmentProgram._Enabled &&
 -       (!ctx->Shader.CurrentProgram ||
 -        !ctx->Shader.CurrentProgram->FragmentProgram) ) 
 -   {
 -      struct gl_fragment_program *newProg;
 -
 -      newProg = _mesa_get_fixed_func_fragment_program(ctx);
 -
 -      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, newProg);
 -      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, newProg);
 -   } 
 -
 -   /* Tell the driver about the change.  Could define a new target for
 -    * this?
 -    */
 -   if (ctx->FragmentProgram._Current != prev && ctx->Driver.BindProgram) {
 -      ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
 -                         (struct gl_program *) ctx->FragmentProgram._Current);
 -   }
 -}
diff --combined src/mesa/main/teximage.c
index 18ca8450d36066507d53e4932678478c537d0e43,fdc72ed8436f672084574a13957742b4c2e3ec34..8fd69c4f6ac0cf79207c52aee6a5f81f258a9035
@@@ -1161,19 -1161,30 +1161,30 @@@ _mesa_init_teximage_fields(GLcontext *c
     img->Width = width;
     img->Height = height;
     img->Depth = depth;
     img->Width2 = width - 2 * border;   /* == 1 << img->WidthLog2; */
-    img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
-    img->Depth2 = depth - 2 * border;   /* == 1 << img->DepthLog2; */
     img->WidthLog2 = logbase2(img->Width2);
-    if (height == 1)  /* 1-D texture */
+    if (height == 1) { /* 1-D texture */
+       img->Height2 = 1;
        img->HeightLog2 = 0;
-    else
+    }
+    else {
+       img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
        img->HeightLog2 = logbase2(img->Height2);
-    if (depth == 1)   /* 2-D texture */
+    }
+    if (depth == 1) {  /* 2-D texture */
+       img->Depth2 = 1;
        img->DepthLog2 = 0;
-    else
+    }
+    else {
+       img->Depth2 = depth - 2 * border;   /* == 1 << img->DepthLog2; */
        img->DepthLog2 = logbase2(img->Depth2);
+    }
     img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
     img->IsCompressed = GL_FALSE;
     img->CompressedSize = 0;
  
@@@ -2420,7 -2431,7 +2431,7 @@@ _mesa_TexImage1D( GLenum target, GLint 
           return;   /* error was recorded */
        }
  
 -      if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +      if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
         _mesa_update_state(ctx);
  
        texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@@ -2526,7 -2537,7 +2537,7 @@@ _mesa_TexImage2D( GLenum target, GLint 
           return;   /* error was recorded */
        }
  
 -      if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +      if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
         _mesa_update_state(ctx);
  
        texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@@ -2627,7 -2638,7 +2638,7 @@@ _mesa_TexImage3D( GLenum target, GLint 
           return;   /* error was recorded */
        }
  
 -      if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +      if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
         _mesa_update_state(ctx);
  
        texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@@ -2720,7 -2731,7 +2731,7 @@@ _mesa_TexSubImage1D( GLenum target, GLi
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
  #if FEATURE_convolve
@@@ -2780,7 -2791,7 +2791,7 @@@ _mesa_TexSubImage2D( GLenum target, GLi
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
  #if FEATURE_convolve
@@@ -2840,7 -2851,7 +2851,7 @@@ _mesa_TexSubImage3D( GLenum target, GLi
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
     if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset,
@@@ -2896,7 -2907,7 +2907,7 @@@ _mesa_CopyTexImage1D( GLenum target, GL
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
  #if FEATURE_convolve
@@@ -2961,7 -2972,7 +2972,7 @@@ _mesa_CopyTexImage2D( GLenum target, GL
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
  #if FEATURE_convolve
@@@ -3029,7 -3040,7 +3040,7 @@@ _mesa_CopyTexSubImage1D( GLenum target
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
     if (copytexsubimage_error_check1(ctx, 1, target, level))
@@@ -3084,7 -3095,7 +3095,7 @@@ _mesa_CopyTexSubImage2D( GLenum target
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
     if (copytexsubimage_error_check1(ctx, 2, target, level))
@@@ -3139,7 -3150,7 +3150,7 @@@ _mesa_CopyTexSubImage3D( GLenum target
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  
 -   if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
 +   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
        _mesa_update_state(ctx);
  
     if (copytexsubimage_error_check1(ctx, 3, target, level))