From d4e6df9ab6e7b707278e3739abee776418c6f527 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 16 Jul 2009 19:20:25 +0100 Subject: [PATCH] mesa: Fix logbase2. It was providing 1 too many for non power two values. --- src/mesa/state_tracker/st_cb_texture.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 22685bd5d95..15f84b66382 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -237,14 +237,12 @@ do_memcpy(void *dest, const void *src, size_t n) } -static int -logbase2(int n) +static INLINE unsigned +logbase2(unsigned n) { - GLint i = 1, log2 = 0; - while (n > i) { - i *= 2; - log2++; - } + unsigned log2 = 0; + while (n >>= 1) + ++log2; return log2; } -- 2.30.2