Mesa (master): swrast: use better _swrast_compute_lambda() function

Brian Paul brianp at kemper.freedesktop.org
Tue Mar 17 16:33:44 UTC 2009


Module: Mesa
Branch: master
Commit: c334ce273e946733928339b1c7f9a02ccdef1b4b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c334ce273e946733928339b1c7f9a02ccdef1b4b

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Mar 17 10:28:32 2009 -0600

swrast: use better _swrast_compute_lambda() function

The MAX-based function can produce values that are non-monotonic for a span
which causes glitches in texture filtering.  The sqrt-based one avoids that.

This is perhaps slightly slower than before, but the difference
probably isn't noticable given we're doing software mipmap filtering.

Issue reported by Nir Radian <nirr at horizonsemi.com>

---

 src/mesa/swrast/s_span.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 5e1f412..15a783b 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -442,11 +442,10 @@ _swrast_span_interpolate_z( const GLcontext *ctx, SWspan *span )
  * Compute mipmap LOD from partial derivatives.
  * This the ideal solution, as given in the OpenGL spec.
  */
-#if 0
-static GLfloat
-compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
-               GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH,
-               GLfloat s, GLfloat t, GLfloat q, GLfloat invQ)
+GLfloat
+_swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
+                       GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH,
+                       GLfloat s, GLfloat t, GLfloat q, GLfloat invQ)
 {
    GLfloat dudx = texW * ((s + dsdx) / (q + dqdx) - s * invQ);
    GLfloat dvdx = texH * ((t + dtdx) / (q + dqdx) - t * invQ);
@@ -458,13 +457,13 @@ compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
    GLfloat lambda = LOG2(rho);
    return lambda;
 }
-#endif
 
 
 /**
  * Compute mipmap LOD from partial derivatives.
  * This is a faster approximation than above function.
  */
+#if 0
 GLfloat
 _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
                      GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH,
@@ -485,6 +484,7 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
    lambda = LOG2(rho);
    return lambda;
 }
+#endif
 
 
 /**




More information about the mesa-commit mailing list