Nouveau: move the definition of log2i() to header
authorPekka Paalanen <pq@iki.fi>
Sat, 13 Dec 2008 21:24:39 +0000 (23:24 +0200)
committerPekka Paalanen <pq@iki.fi>
Sat, 13 Dec 2008 21:24:39 +0000 (23:24 +0200)
Also make the type unsigned instead of signed, since negative
values do not make sense.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
src/gallium/drivers/nouveau/nouveau_util.h
src/gallium/drivers/nv04/nv04_fragtex.c
src/gallium/drivers/nv10/nv10_fragtex.c
src/gallium/drivers/nv20/nv20_fragtex.c
src/gallium/drivers/nv30/nv30_fragtex.c
src/gallium/drivers/nv30/nv30_state_fb.c
src/gallium/drivers/nv40/nv40_state_fb.c

index c92041ebeba835fc4f5188095d97cfaca890f326..a10114beab98d9ffb9204a448d6ed0d0692cbcc3 100644 (file)
@@ -61,4 +61,31 @@ nouveau_vbuf_split(unsigned remaining, unsigned overhead, unsigned vpp,
        return max;
 }
 
+/* Integer base-2 logarithm, rounded towards zero. */
+static INLINE unsigned log2i(unsigned i)
+{
+       unsigned r = 0;
+
+       if (i & 0xffff0000) {
+               i >>= 16;
+               r += 16;
+       }
+       if (i & 0x0000ff00) {
+               i >>= 8;
+               r += 8;
+       }
+       if (i & 0x000000f0) {
+               i >>= 4;
+               r += 4;
+       }
+       if (i & 0x0000000c) {
+               i >>= 2;
+               r += 2;
+       }
+       if (i & 0x00000002) {
+               r += 1;
+       }
+       return r;
+}
+
 #endif
index 1b866aae1991d4f84e6260bb945cdf6f5e05e748..21f990fd536deb3a4a4fe32319c9d775c2c1f649 100644 (file)
@@ -1,30 +1,5 @@
 #include "nv04_context.h"
-
-static INLINE int log2i(int i)
-{
-       int r = 0;
-
-       if (i & 0xffff0000) {
-               i >>= 16;
-               r += 16;
-       }
-       if (i & 0x0000ff00) {
-               i >>= 8;
-               r += 8;
-       }
-       if (i & 0x000000f0) {
-               i >>= 4;
-               r += 4;
-       }
-       if (i & 0x0000000c) {
-               i >>= 2;
-               r += 2;
-       }
-       if (i & 0x00000002) {
-               r += 1;
-       }
-       return r;
-}
+#include "nouveau/nouveau_util.h"
 
 #define _(m,tf)                                                                \
 {                                                                              \
index 238634d0bb45672a0fb556780a21abffaf316e6a..27f2f8758471064b7b689be1f0241de6e3279437 100644 (file)
@@ -1,30 +1,5 @@
 #include "nv10_context.h"
-
-static INLINE int log2i(int i)
-{
-       int r = 0;
-
-       if (i & 0xffff0000) {
-               i >>= 16;
-               r += 16;
-       }
-       if (i & 0x0000ff00) {
-               i >>= 8;
-               r += 8;
-       }
-       if (i & 0x000000f0) {
-               i >>= 4;
-               r += 4;
-       }
-       if (i & 0x0000000c) {
-               i >>= 2;
-               r += 2;
-       }
-       if (i & 0x00000002) {
-               r += 1;
-       }
-       return r;
-}
+#include "nouveau/nouveau_util.h"
 
 #define _(m,tf)                                                                \
 {                                                                              \
index 94c64f76d5800df2d772538757d420ae9d768af6..495a7be9127f85301a593cfec1e14c7ddeaed2aa 100644 (file)
@@ -1,30 +1,5 @@
 #include "nv20_context.h"
-
-static INLINE int log2i(int i)
-{
-       int r = 0;
-
-       if (i & 0xffff0000) {
-               i >>= 16;
-               r += 16;
-       }
-       if (i & 0x0000ff00) {
-               i >>= 8;
-               r += 8;
-       }
-       if (i & 0x000000f0) {
-               i >>= 4;
-               r += 4;
-       }
-       if (i & 0x0000000c) {
-               i >>= 2;
-               r += 2;
-       }
-       if (i & 0x00000002) {
-               r += 1;
-       }
-       return r;
-}
+#include "nouveau/nouveau_util.h"
 
 #define _(m,tf)                                                                \
 {                                                                              \
index efba8db86d8fd0d076e7fe8b9096955ca5571531..b1d2663af38267caa5cf9310156fce2c86092f35 100644 (file)
@@ -1,30 +1,5 @@
 #include "nv30_context.h"
-
-static INLINE int log2i(int i)
-{
-       int r = 0;
-
-       if (i & 0xffff0000) {
-               i >>= 16;
-               r += 16;
-       }
-       if (i & 0x0000ff00) {
-               i >>= 8;
-               r += 8;
-       }
-       if (i & 0x000000f0) {
-               i >>= 4;
-               r += 4;
-       }
-       if (i & 0x0000000c) {
-               i >>= 2;
-               r += 2;
-       }
-       if (i & 0x00000002) {
-               r += 1;
-       }
-       return r;
-}
+#include "nouveau/nouveau_util.h"
 
 #define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w)                        \
 {                                                                              \
index c549b17656e4db02a8ff987dc838128cdc5e9171..73bdf7e56c567f47578c715785cef158399991d2 100644 (file)
@@ -1,30 +1,5 @@
 #include "nv30_context.h"
-
-static INLINE int log2i(int i)
-{
-       int r = 0;
-
-       if (i & 0xffff0000) {
-               i >>= 16;
-               r += 16;
-       }
-       if (i & 0x0000ff00) {
-               i >>= 8;
-               r += 8;
-       }
-       if (i & 0x000000f0) {
-               i >>= 4;
-               r += 4;
-       }
-       if (i & 0x0000000c) {
-               i >>= 2;
-               r += 2;
-       }
-       if (i & 0x00000002) {
-               r += 1;
-       }
-       return r;
-}
+#include "nouveau/nouveau_util.h"
 
 static boolean
 nv30_state_framebuffer_validate(struct nv30_context *nv30)
index f903b22ba09a1bf786d07547da830c746103db2c..28592d71c37bd9ea124bbe2c08957b8ab0fc5b17 100644 (file)
@@ -1,30 +1,5 @@
 #include "nv40_context.h"
-
-static INLINE int log2i(int i)
-{
-       int r = 0;
-
-       if (i & 0xffff0000) {
-               i >>= 16;
-               r += 16;
-       }
-       if (i & 0x0000ff00) {
-               i >>= 8;
-               r += 8;
-       }
-       if (i & 0x000000f0) {
-               i >>= 4;
-               r += 4;
-       }
-       if (i & 0x0000000c) {
-               i >>= 2;
-               r += 2;
-       }
-       if (i & 0x00000002) {
-               r += 1;
-       }
-       return r;
-}
+#include "nouveau/nouveau_util.h"
 
 static boolean
 nv40_state_framebuffer_validate(struct nv40_context *nv40)