mesa: decrease the array size of ctx->Texture.FixedFuncUnit to 8
GL allows doing glTexEnv on 192 texture units, while in reality, only MaxTextureCoordUnits units are used by fixed-func shaders. There is a piglit patch that adjusts piglits/texunits to check only MaxTextureCoordUnits units. Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
07c10cc59c
commit
78043a75f6
|
@ -209,6 +209,8 @@ enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
|
||||||
{
|
{
|
||||||
struct gl_fixedfunc_texture_unit *texUnit =
|
struct gl_fixedfunc_texture_unit *texUnit =
|
||||||
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
||||||
|
if (!texUnit)
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
const GLbitfield newenabled = state
|
const GLbitfield newenabled = state
|
||||||
? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit);
|
? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit);
|
||||||
|
@ -1293,6 +1295,9 @@ is_texture_enabled(struct gl_context *ctx, GLbitfield bit)
|
||||||
const struct gl_fixedfunc_texture_unit *const texUnit =
|
const struct gl_fixedfunc_texture_unit *const texUnit =
|
||||||
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
||||||
|
|
||||||
|
if (!texUnit)
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
|
return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1370,7 +1370,7 @@ struct gl_texture_attrib
|
||||||
GLint NumCurrentTexUsed;
|
GLint NumCurrentTexUsed;
|
||||||
|
|
||||||
struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
|
struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
|
||||||
struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
|
struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_TEXTURE_COORD_UNITS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -400,6 +400,15 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
|
||||||
struct gl_fixedfunc_texture_unit *texUnit =
|
struct gl_fixedfunc_texture_unit *texUnit =
|
||||||
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
* fixed-function units are usable. This is probably a spec bug.
|
||||||
|
* Ignore glTexEnv(GL_TEXTURE_ENV) calls for non-fixed-func units,
|
||||||
|
* because we don't want to process calls that have no effect.
|
||||||
|
*/
|
||||||
|
if (!texUnit)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_TEXTURE_ENV_MODE:
|
case GL_TEXTURE_ENV_MODE:
|
||||||
set_env_mode(ctx, texUnit, (GLenum) iparam0);
|
set_env_mode(ctx, texUnit, (GLenum) iparam0);
|
||||||
|
@ -649,6 +658,15 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
|
||||||
struct gl_fixedfunc_texture_unit *texUnit =
|
struct gl_fixedfunc_texture_unit *texUnit =
|
||||||
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
* fixed-function units are usable. This is probably a spec bug.
|
||||||
|
* Ignore calls for non-fixed-func units, because we don't process
|
||||||
|
* glTexEnv for them either.
|
||||||
|
*/
|
||||||
|
if (!texUnit)
|
||||||
|
return;
|
||||||
|
|
||||||
if (pname == GL_TEXTURE_ENV_COLOR) {
|
if (pname == GL_TEXTURE_ENV_COLOR) {
|
||||||
if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
|
if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
|
||||||
_mesa_update_state(ctx);
|
_mesa_update_state(ctx);
|
||||||
|
@ -717,6 +735,15 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
|
||||||
struct gl_fixedfunc_texture_unit *texUnit =
|
struct gl_fixedfunc_texture_unit *texUnit =
|
||||||
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
_mesa_get_current_fixedfunc_tex_unit(ctx);
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
* fixed-function units are usable. This is probably a spec bug.
|
||||||
|
* Ignore calls for non-fixed-func units, because we don't process
|
||||||
|
* glTexEnv for them either.
|
||||||
|
*/
|
||||||
|
if (!texUnit)
|
||||||
|
return;
|
||||||
|
|
||||||
if (pname == GL_TEXTURE_ENV_COLOR) {
|
if (pname == GL_TEXTURE_ENV_COLOR) {
|
||||||
params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] );
|
params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] );
|
||||||
params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
|
params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
|
||||||
|
|
|
@ -103,7 +103,7 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) {
|
for (u = 0; u < src->Const.MaxTextureCoordUnits; u++) {
|
||||||
dst->Texture.FixedFuncUnit[u].Enabled = src->Texture.FixedFuncUnit[u].Enabled;
|
dst->Texture.FixedFuncUnit[u].Enabled = src->Texture.FixedFuncUnit[u].Enabled;
|
||||||
dst->Texture.FixedFuncUnit[u].EnvMode = src->Texture.FixedFuncUnit[u].EnvMode;
|
dst->Texture.FixedFuncUnit[u].EnvMode = src->Texture.FixedFuncUnit[u].EnvMode;
|
||||||
COPY_4V(dst->Texture.FixedFuncUnit[u].EnvColor, src->Texture.FixedFuncUnit[u].EnvColor);
|
COPY_4V(dst->Texture.FixedFuncUnit[u].EnvColor, src->Texture.FixedFuncUnit[u].EnvColor);
|
||||||
|
|
|
@ -65,6 +65,9 @@ _mesa_get_current_fixedfunc_tex_unit(struct gl_context *ctx)
|
||||||
{
|
{
|
||||||
unsigned unit = ctx->Texture.CurrentUnit;
|
unsigned unit = ctx->Texture.CurrentUnit;
|
||||||
|
|
||||||
|
if (unit >= ARRAY_SIZE(ctx->Texture.FixedFuncUnit))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return &ctx->Texture.FixedFuncUnit[unit];
|
return &ctx->Texture.FixedFuncUnit[unit];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue