mesa/swrast: use logf2 instead of util_fast_log2
authorDylan Baker <dylan.c.baker@intel.com>
Thu, 30 Apr 2020 19:40:56 +0000 (12:40 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 30 Jun 2020 21:43:22 +0000 (21:43 +0000)
The fast version is apparently not accurate enough. I wrote a very
simply test program that called logf2 and the old LOG2 function 100000
times. Across that the two functions had very similar run times, neither
appeared meaningfully faster, so the optimization of bringing back yet
another way to calculate log2f seems pointless.

Fixes: bd4e769515345a6b20562310334bc828c0bb6605
       ("replace LOG2 with util_fast_log2")

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2856
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5406>

src/mesa/swrast/s_span.c
src/mesa/swrast/s_texfilter.c

index 2eb22539a0f679fcc5d6f4f53acb4a2105335bd7..dcb2db01e6d09c204ce444195eb1b73fd1380125 100644 (file)
@@ -426,7 +426,7 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
    GLfloat x = sqrtf(dudx * dudx + dvdx * dvdx);
    GLfloat y = sqrtf(dudy * dudy + dvdy * dvdy);
    GLfloat rho = MAX2(x, y);
-   GLfloat lambda = util_fast_log2(rho);
+   GLfloat lambda = log2f(rho);
    return lambda;
 }
 
@@ -453,7 +453,7 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
    maxU = MAX2(dsdx2, dsdy2) * texW;
    maxV = MAX2(dtdx2, dtdy2) * texH;
    rho = MAX2(maxU, maxV);
-   lambda = util_fast_log2(rho);
+   lambda = logf2(rho);
    return lambda;
 }
 #endif
index 381eb343812dc76056b59ac82b5e53c6a980c361..28bd57be8a10d11ce73ddd8ef1714103bfe4ecee 100644 (file)
@@ -1961,7 +1961,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
       /* note: we need to have Pmin=sqrt(Pmin2) here, but we can avoid
        * this since 0.5*log(x) = log(sqrt(x))
        */
-      lod = 0.5f * util_fast_log2(Pmin2);
+      lod = 0.5f * log2f(Pmin2);
 
       if (adjustLOD) {
          /* from swrast/s_texcombine.c _swrast_texture_span */