diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2005-11-19 17:08:15 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2005-11-19 17:08:15 +0000 |
commit | 6f445a106186ac5e7e99cd55c1e27ac23b5053fd (patch) | |
tree | 3d5f0fa8f28828ed035f1831104eb52f2598fd62 /src/mesa/drivers | |
parent | 41c8eabe0ff32e85c8abb4eee63e3215241d2ddb (diff) |
in run_texnorm_stage() check if the texture unit is really enabled before trying to normalize the texcoords
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/savage/savagerender.c | 102 |
1 files changed, 52 insertions, 50 deletions
diff --git a/src/mesa/drivers/dri/savage/savagerender.c b/src/mesa/drivers/dri/savage/savagerender.c index 22e3f13396..514434c427 100644 --- a/src/mesa/drivers/dri/savage/savagerender.c +++ b/src/mesa/drivers/dri/savage/savagerender.c @@ -246,57 +246,59 @@ static GLboolean run_texnorm_stage( GLcontext *ctx, return GL_TRUE; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { - GLuint reallyEnabled = ctx->Texture.Unit[i]._ReallyEnabled; - struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; - GLboolean normalizeS = (texObj->WrapS == GL_REPEAT); - GLboolean normalizeT = (reallyEnabled & TEXTURE_2D_BIT) && - (texObj->WrapT == GL_REPEAT); - GLfloat *in = (GLfloat *)VB->TexCoordPtr[i]->data; - GLint instride = VB->TexCoordPtr[i]->stride; - GLfloat (*out)[4] = store->texcoord[i].data; - GLint j; - - if (!ctx->Texture.Unit[i]._ReallyEnabled || - VB->TexCoordPtr[i]->size == 4) - /* Never try to normalize homogenous tex coords! */ - continue; - - if (normalizeS && normalizeT) { - /* take first texcoords as rough estimate of mean value */ - GLfloat correctionS = -floor(in[0]+0.5); - GLfloat correctionT = -floor(in[1]+0.5); - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0] + correctionS; - out[j][1] = in[1] + correctionT; - in = (GLfloat *)((GLubyte *)in + instride); - } - } else if (normalizeS) { - /* take first texcoords as rough estimate of mean value */ - GLfloat correctionS = -floor(in[0]+0.5); - if (reallyEnabled & TEXTURE_2D_BIT) { - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0] + correctionS; - out[j][1] = in[1]; - in = (GLfloat *)((GLubyte *)in + instride); - } - } else { - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0] + correctionS; - in = (GLfloat *)((GLubyte *)in + instride); - } - } - } else if (normalizeT) { - /* take first texcoords as rough estimate of mean value */ - GLfloat correctionT = -floor(in[1]+0.5); - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0]; - out[j][1] = in[1] + correctionT; - in = (GLfloat *)((GLubyte *)in + instride); - } + const GLbitfield reallyEnabled = ctx->Texture.Unit[i]._ReallyEnabled; + if (reallyEnabled) { + const struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; + const GLboolean normalizeS = (texObj->WrapS == GL_REPEAT); + const GLboolean normalizeT = (reallyEnabled & TEXTURE_2D_BIT) && + (texObj->WrapT == GL_REPEAT); + const GLfloat *in = (GLfloat *)VB->TexCoordPtr[i]->data; + const GLint instride = VB->TexCoordPtr[i]->stride; + GLfloat (*out)[4] = store->texcoord[i].data; + GLint j; + + if (!ctx->Texture.Unit[i]._ReallyEnabled || + VB->TexCoordPtr[i]->size == 4) + /* Never try to normalize homogenous tex coords! */ + continue; + + if (normalizeS && normalizeT) { + /* take first texcoords as rough estimate of mean value */ + GLfloat correctionS = -floor(in[0]+0.5); + GLfloat correctionT = -floor(in[1]+0.5); + for (j = 0; j < VB->Count; ++j) { + out[j][0] = in[0] + correctionS; + out[j][1] = in[1] + correctionT; + in = (GLfloat *)((GLubyte *)in + instride); + } + } else if (normalizeS) { + /* take first texcoords as rough estimate of mean value */ + GLfloat correctionS = -floor(in[0]+0.5); + if (reallyEnabled & TEXTURE_2D_BIT) { + for (j = 0; j < VB->Count; ++j) { + out[j][0] = in[0] + correctionS; + out[j][1] = in[1]; + in = (GLfloat *)((GLubyte *)in + instride); + } + } else { + for (j = 0; j < VB->Count; ++j) { + out[j][0] = in[0] + correctionS; + in = (GLfloat *)((GLubyte *)in + instride); + } + } + } else if (normalizeT) { + /* take first texcoords as rough estimate of mean value */ + GLfloat correctionT = -floor(in[1]+0.5); + for (j = 0; j < VB->Count; ++j) { + out[j][0] = in[0]; + out[j][1] = in[1] + correctionT; + in = (GLfloat *)((GLubyte *)in + instride); + } + } + + if (normalizeS || normalizeT) + VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] = &store->texcoord[i]; } - - if (normalizeS || normalizeT) - VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] = &store->texcoord[i]; } return GL_TRUE; |