From: José Fonseca Date: Thu, 16 Jul 2009 18:20:25 +0000 (+0100) Subject: mesa: Fix logbase2. X-Git-Tag: 062012170305~16521^2~104 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4e6df9ab6e7b707278e3739abee776418c6f527;p=profile%2Fivi%2Fmesa.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 22685bd..15f84b6 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; }