summaryrefslogtreecommitdiff
path: root/src/mesa/main/imports.h
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-11-10 20:15:28 -0700
committerBrian <brian.paul@tungstengraphics.com>2008-11-10 20:16:00 -0700
commitbe1b8e5d6c6692010a3ec117035d9b218929e2b3 (patch)
treeb21ff72555b2c3870036562924fa86c8042e53bc /src/mesa/main/imports.h
parent8df4f6667f2892368791ae25505a996bc0edfacb (diff)
mesa: new _mesa_is_pow_two() function
Diffstat (limited to 'src/mesa/main/imports.h')
-rw-r--r--src/mesa/main/imports.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 89d0662f79..453151ce0b 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -462,6 +462,16 @@ static INLINE int iceil(float f)
#endif
+/**
+ * Is x a power of two?
+ */
+static INLINE int
+_mesa_is_pow_two(int x)
+{
+ return !(x & (x - 1));
+}
+
+
/***
*** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
*** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]