diff options
author | Ian Romanick <[email protected]> | 2005-08-18 20:01:01 +0000 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2005-08-18 20:01:01 +0000 |
commit | 61ac29e7c6db3a899edd9d80f8dbbb98fd7ccc90 (patch) | |
tree | 992ddf68267f85cbb05e76bf32f19a0c1cd3b9a6 /src/mesa/drivers/dri/i810/i810tex.c | |
parent | b462855c24dc750b386fbd632b60f3fca3fe7d07 (diff) |
Don't try to update hardware texture fields if there is no hardware texture.
This can happen when all the texture enables for a texture unit are disabled.
This fixes bugzilla #3195.
Diffstat (limited to 'src/mesa/drivers/dri/i810/i810tex.c')
-rw-r--r-- | src/mesa/drivers/dri/i810/i810tex.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/i810/i810tex.c b/src/mesa/drivers/dri/i810/i810tex.c index 72919caba88..34a299ae744 100644 --- a/src/mesa/drivers/dri/i810/i810tex.c +++ b/src/mesa/drivers/dri/i810/i810tex.c @@ -282,48 +282,52 @@ static void i810TexParameter( GLcontext *ctx, GLenum target, } +/** + * Setup hardware bits for new texture environment settings. + * + * \todo + * Determine whether or not \c param can be used instead of + * \c texUnit->EnvColor in the \c GL_TEXTURE_ENV_COLOR case. + */ static void i810TexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param ) { i810ContextPtr imesa = I810_CONTEXT( ctx ); - GLuint unit = ctx->Texture.CurrentUnit; + const GLuint unit = ctx->Texture.CurrentUnit; + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; /* Only one env color. Need a fallback if env colors are different * and texture setup references env color in both units. */ switch (pname) { case GL_TEXTURE_ENV_COLOR: { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLfloat *fc = texUnit->EnvColor; - GLuint r, g, b, a, col; - CLAMPED_FLOAT_TO_UBYTE(r, fc[0]); - CLAMPED_FLOAT_TO_UBYTE(g, fc[1]); - CLAMPED_FLOAT_TO_UBYTE(b, fc[2]); - CLAMPED_FLOAT_TO_UBYTE(a, fc[3]); - - col = ((a << 24) | - (r << 16) | - (g << 8) | - (b << 0)); - - if (imesa->Setup[I810_CTXREG_CF1] != col) { - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_CF1] = col; + GLubyte c[4]; + GLuint envColor; + + UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor ); + envColor = PACK_COLOR_8888( c[3], c[0], c[1], c[2] ); + + if (imesa->Setup[I810_CTXREG_CF1] != envColor) { + I810_STATECHANGE(imesa, I810_UPLOAD_CTX); + imesa->Setup[I810_CTXREG_CF1] = envColor; } break; } + case GL_TEXTURE_ENV_MODE: imesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */ break; - case GL_TEXTURE_LOD_BIAS_EXT: - { - struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current; - i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData; - t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK); - t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(*param); + case GL_TEXTURE_LOD_BIAS: { + if ( texUnit->_Current != NULL ) { + const struct gl_texture_object *tObj = texUnit->_Current; + i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData; + + t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK); + t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(*param); } break; + } default: break; |