Module: Mesa
Branch: gallium-0.2
Commit: f72848a09a9d3069705fbe8e4daa29b9918ea56e
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f72848a09a9d3069705fbe8e4daa29b9918ea56e

Author: Pekka Paalanen <[email protected]>
Date:   Sat Dec 13 23:24:39 2008 +0200

Nouveau: move the definition of log2i() to header

Also make the type unsigned instead of signed, since negative
values do not make sense.

Signed-off-by: Pekka Paalanen <[email protected]>

---

 src/gallium/drivers/nouveau/nouveau_util.h |   27 +++++++++++++++++++++++++++
 src/gallium/drivers/nv04/nv04_fragtex.c    |   27 +--------------------------
 src/gallium/drivers/nv10/nv10_fragtex.c    |   27 +--------------------------
 src/gallium/drivers/nv20/nv20_fragtex.c    |   27 +--------------------------
 src/gallium/drivers/nv30/nv30_fragtex.c    |   27 +--------------------------
 src/gallium/drivers/nv30/nv30_state_fb.c   |   27 +--------------------------
 src/gallium/drivers/nv40/nv40_state_fb.c   |   27 +--------------------------
 7 files changed, 33 insertions(+), 156 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_util.h 
b/src/gallium/drivers/nouveau/nouveau_util.h
index c92041e..a10114b 100644
--- a/src/gallium/drivers/nouveau/nouveau_util.h
+++ b/src/gallium/drivers/nouveau/nouveau_util.h
@@ -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
diff --git a/src/gallium/drivers/nv04/nv04_fragtex.c 
b/src/gallium/drivers/nv04/nv04_fragtex.c
index 1b866aa..21f990f 100644
--- a/src/gallium/drivers/nv04/nv04_fragtex.c
+++ b/src/gallium/drivers/nv04/nv04_fragtex.c
@@ -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)                                                                
\
 {                                                                              
\
diff --git a/src/gallium/drivers/nv10/nv10_fragtex.c 
b/src/gallium/drivers/nv10/nv10_fragtex.c
index 238634d..27f2f87 100644
--- a/src/gallium/drivers/nv10/nv10_fragtex.c
+++ b/src/gallium/drivers/nv10/nv10_fragtex.c
@@ -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)                                                                
\
 {                                                                              
\
diff --git a/src/gallium/drivers/nv20/nv20_fragtex.c 
b/src/gallium/drivers/nv20/nv20_fragtex.c
index 94c64f7..495a7be 100644
--- a/src/gallium/drivers/nv20/nv20_fragtex.c
+++ b/src/gallium/drivers/nv20/nv20_fragtex.c
@@ -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)                                                                
\
 {                                                                              
\
diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c 
b/src/gallium/drivers/nv30/nv30_fragtex.c
index efba8db..b1d2663 100644
--- a/src/gallium/drivers/nv30/nv30_fragtex.c
+++ b/src/gallium/drivers/nv30/nv30_fragtex.c
@@ -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)                        
\
 {                                                                              
\
diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c 
b/src/gallium/drivers/nv30/nv30_state_fb.c
index c549b17..73bdf7e 100644
--- a/src/gallium/drivers/nv30/nv30_state_fb.c
+++ b/src/gallium/drivers/nv30/nv30_state_fb.c
@@ -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)
diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c 
b/src/gallium/drivers/nv40/nv40_state_fb.c
index f903b22..28592d7 100644
--- a/src/gallium/drivers/nv40/nv40_state_fb.c
+++ b/src/gallium/drivers/nv40/nv40_state_fb.c
@@ -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)

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to