[Mesa-dev] [PATCH 2/3] Remove redundant util_unsigned_logbase2

Matt Turner mattst88 at gmail.com
Sun May 8 21:17:01 PDT 2011


util_logbase2 is exactly the same function.

Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
 src/gallium/auxiliary/gallivm/lp_bld_sample.c |    2 +-
 src/gallium/auxiliary/util/u_math.h           |   12 ------------
 src/gallium/drivers/llvmpipe/lp_rast_debug.c  |    2 +-
 src/gallium/drivers/nv50/nv50_screen.c        |    2 +-
 src/gallium/drivers/softpipe/sp_tex_sample.c  |    4 ++--
 5 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 4636371..cb6717d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -1055,7 +1055,7 @@ lp_build_sample_partial_offset(struct lp_build_context *bld,
       subcoord = LLVMBuildURem(builder, coord, block_width, "");
       coord    = LLVMBuildUDiv(builder, coord, block_width, "");
 #else
-      unsigned logbase2 = util_unsigned_logbase2(block_length);
+      unsigned logbase2 = util_logbase2(block_length);
       LLVMValueRef block_shift = lp_build_const_int_vec(bld->gallivm, bld->type, logbase2);
       LLVMValueRef block_mask = lp_build_const_int_vec(bld->gallivm, bld->type, block_length - 1);
       subcoord = LLVMBuildAnd(builder, coord, block_mask, "");
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index ad2a1f8..2ecade5 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -414,18 +414,6 @@ unsigned ffs( unsigned u )
 #endif
 
 
-/* Could also binary search for the highest bit.
- */
-static INLINE unsigned
-util_unsigned_logbase2(unsigned n)
-{
-   unsigned log2 = 0;
-   while (n >>= 1)
-      ++log2;
-   return log2;
-}
-
-
 /**
  * Return float bits.
  */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
index 64ac616..bc7dc64 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
@@ -398,7 +398,7 @@ lp_debug_draw_bins_by_cmd_length( struct lp_scene *scene )
       for (x = 0; x < scene->tiles_x; x++) {
          const char *bits = " ...,-~:;=o+xaw*#XAWWWWWWWWWWWWWWWW";
          int sz = lp_scene_bin_size(scene, x, y);
-         int sz2 = util_unsigned_logbase2(sz);
+         int sz2 = util_logbase2(sz);
          debug_printf("%c", bits[MIN2(sz2,32)]);
       }
       debug_printf("\n");
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 4dad859..c026242 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -488,7 +488,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
    BEGIN_RING(chan, RING_3D(LOCAL_ADDRESS_HIGH), 3);
    OUT_RELOCh(chan, screen->tls_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
    OUT_RELOCl(chan, screen->tls_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
-   OUT_RING  (chan, util_unsigned_logbase2(tls_space / 8));
+   OUT_RING  (chan, util_logbase2(tls_space / 8));
 
    ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 16, 4 << 16,
                         &screen->uniforms);
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 02892c1..1446aee 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -2243,8 +2243,8 @@ sp_sampler_variant_bind_view( struct sp_sampler_variant *samp,
 
    samp->view = view;
    samp->cache = tex_cache;
-   samp->xpot = util_unsigned_logbase2( texture->width0 );
-   samp->ypot = util_unsigned_logbase2( texture->height0 );
+   samp->xpot = util_logbase2( texture->width0 );
+   samp->ypot = util_logbase2( texture->height0 );
    samp->level = view->u.tex.first_level;
 }
 
-- 
1.7.3.4



More information about the mesa-dev mailing list