mesa: replace _mesa_get_current_fixedfunc_tex_unit with _mesa_get_fixedfunc_tex_unit

The new function implements the same feature but doesn't depend
on ctx->Texture.CurrentUnit.
This change allows to use it from indexed functions.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2019-04-29 19:23:36 +02:00 committed by Marek Olšák
parent b4c54894bb
commit 58030d2b3d
4 changed files with 10 additions and 12 deletions

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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;