swrast: fix choose_depth_texture_level() to respect mipmap filtering state
authorBrian Paul <brianp@vmware.com>
Tue, 5 Oct 2010 01:59:23 +0000 (19:59 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 5 Oct 2010 01:59:46 +0000 (19:59 -0600)
NOTE: this is a candidate for the 7.9 branch.

src/mesa/swrast/s_texfilter.c

index de694c31bf1ab3f96300cfe9ea84cbcd5be843e8..e5ffe8fa5c522149984b8f9d7276ddd28ebcb3db 100644 (file)
@@ -2975,11 +2975,16 @@ choose_depth_texture_level(const struct gl_texture_object *tObj, GLfloat lambda)
 {
    GLint level;
 
-   lambda = CLAMP(lambda, tObj->MinLod, tObj->MaxLod);
-
-   level = (GLint) lambda;
-
-   level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel);
+   if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
+      /* no mipmapping - use base level */
+      level = tObj->BaseLevel;
+   }
+   else {
+      /* choose mipmap level */
+      lambda = CLAMP(lambda, tObj->MinLod, tObj->MaxLod);
+      level = (GLint) lambda;
+      level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel);
+   }
 
    return level;
 }