enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
 {
    struct gl_fixedfunc_texture_unit *texUnit =
-      _mesa_get_current_fixedfunc_tex_unit(ctx);
+      _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
    if (!texUnit)
       return GL_FALSE;
 
 is_texture_enabled(struct gl_context *ctx, GLbitfield bit)
 {
    const struct gl_fixedfunc_texture_unit *const texUnit =
-      _mesa_get_current_fixedfunc_tex_unit(ctx);
+      _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
    if (!texUnit)
       return GL_FALSE;
 
 
    if (target == GL_TEXTURE_ENV) {
       struct gl_fixedfunc_texture_unit *texUnit =
-         _mesa_get_current_fixedfunc_tex_unit(ctx);
+         _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
       /* The GL spec says that we should report an error if the unit is greater
        * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only
 
    if (target == GL_TEXTURE_ENV) {
       struct gl_fixedfunc_texture_unit *texUnit =
-         _mesa_get_current_fixedfunc_tex_unit(ctx);
+         _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
       /* The GL spec says that we should report an error if the unit is greater
        * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only
 
    if (target == GL_TEXTURE_ENV) {
       struct gl_fixedfunc_texture_unit *texUnit =
-         _mesa_get_current_fixedfunc_tex_unit(ctx);
+         _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
       /* The GL spec says that we should report an error if the unit is greater
        * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only
 
       return;
    }
 
-   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
+   texUnit = _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
       return;
    }
 
-   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
+   texUnit = _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
       return;
    }
 
-   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
+   texUnit = _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
       return;
    }
 
-   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
+   texUnit = _mesa_get_fixedfunc_tex_unit(ctx, ctx->Texture.CurrentUnit);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
 
  * \return NULL if the current unit is not a fixed-func texture unit
  */
 static inline struct gl_fixedfunc_texture_unit *
-_mesa_get_current_fixedfunc_tex_unit(struct gl_context *ctx)
+_mesa_get_fixedfunc_tex_unit(struct gl_context *ctx, GLuint unit)
 {
-   unsigned unit = ctx->Texture.CurrentUnit;
-
    if (unit >= ARRAY_SIZE(ctx->Texture.FixedFuncUnit))
       return NULL;