From: José Fonseca Date: Thu, 16 Jul 2009 18:20:25 +0000 (+0100) Subject: mesa: Fix logbase2. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4e6df9ab6e7b707278e3739abee776418c6f527;p=mesa.git mesa: Fix logbase2. It was providing 1 too many for non power two values. --- 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; }