Mesa (staging/20.1): mesa/swrast: use logf2 instead of util_fast_log2

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 30 22:31:52 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 6128ab7712f0c6f145a1b8eac3bb6185a4e8bc40
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6128ab7712f0c6f145a1b8eac3bb6185a4e8bc40

Author: Dylan Baker <dylan.c.baker at intel.com>
Date:   Thu Apr 30 12:40:56 2020 -0700

mesa/swrast: use logf2 instead of util_fast_log2

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 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5406>
(cherry picked from commit fde25a6ed94409eca4e6b47f73774356314095d9)

---

 .pick_status.json             | 2 +-
 src/mesa/swrast/s_span.c      | 4 ++--
 src/mesa/swrast/s_texfilter.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e98e2d89c65..e354caaf911 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4,7 +4,7 @@
         "description": "mesa/swrast: use logf2 instead of util_fast_log2",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "bd4e769515345a6b20562310334bc828c0bb6605"
     },
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 2eb22539a0f..dcb2db01e6d 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -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
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index 381eb343812..28bd57be8a1 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -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 */



More information about the mesa-commit mailing list