Move clamping of texture LOD bias to texture application time.
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 28 Aug 2003 23:31:00 +0000 (23:31 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 28 Aug 2003 23:31:00 +0000 (23:31 +0000)
src/mesa/main/texstate.c
src/mesa/swrast/s_texture.c

index 2c1d155f52ece56e98515e316b81353a0ce42f81..a62106aa4916122383f9b1cc8f4267aa5c208826 100644 (file)
@@ -525,8 +525,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
         if (texUnit->LodBias == param[0])
            return;
         FLUSH_VERTICES(ctx, _NEW_TEXTURE);
-         texUnit->LodBias = CLAMP(param[0], -ctx->Const.MaxTextureLodBias,
-                                  ctx->Const.MaxTextureLodBias);
+         texUnit->LodBias = param[0];
       }
       else {
          TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
@@ -1402,9 +1401,10 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
       case GL_TEXTURE_LOD_BIAS:
          /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias*/
          if (ctx->Extensions.EXT_texture_lod_bias) {
-            texObj->LodBias = CLAMP(params[0],
-                                    -ctx->Const.MaxTextureLodBias,
-                                    ctx->Const.MaxTextureLodBias);
+            if (texObj->LodBias != params[0]) {
+               FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+               texObj->LodBias = params[0];
+            }
          }
          break;
 
index b9e08148ecfb251559fb8009f2834564c62f1996..36f2975312dfccf751c55a3b3203983214521f93 100644 (file)
@@ -4200,9 +4200,12 @@ _swrast_texture_span( GLcontext *ctx, struct sw_span *span )
          if (span->arrayMask & SPAN_LAMBDA) {
             if (texUnit->LodBias + curObj->LodBias != 0.0F) {
                /* apply LOD bias, but don't clamp yet */
+               const GLfloat bias = CLAMP(texUnit->LodBias + curObj->LodBias,
+                                          -ctx->Const.MaxTextureLodBias,
+                                          ctx->Const.MaxTextureLodBias);
                GLuint i;
                for (i = 0; i < span->end; i++) {
-                  lambda[i] += (texUnit->LodBias + curObj->LodBias);
+                  lambda[i] += bias;
                }
             }