diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 418fc75c724..8c3a9a789a9 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -247,7 +247,7 @@ static GLboolean 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; @@ -1401,7 +1401,7 @@ static GLboolean 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; diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c index a69c8dd7435..95b44004c32 100644 --- a/src/mesa/main/texenv.c +++ b/src/mesa/main/texenv.c @@ -408,7 +408,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) 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 @@ -670,7 +670,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) 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 @@ -747,7 +747,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) 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 diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c index 4eb2f60464a..96d0228d8ca 100644 --- a/src/mesa/main/texgen.c +++ b/src/mesa/main/texgen.c @@ -85,7 +85,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) 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) { @@ -297,7 +297,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) 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) { @@ -334,7 +334,7 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) 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) { @@ -379,7 +379,7 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) 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) { diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h index c0b73b14e82..f2e55f1a4af 100644 --- a/src/mesa/main/texstate.h +++ b/src/mesa/main/texstate.h @@ -61,10 +61,8 @@ _mesa_get_current_tex_unit(struct gl_context *ctx) * \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;