Mesa (master): u_math: Add align function npot alignments

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Tue Jun 22 18:08:51 UTC 2010


Module: Mesa
Branch: master
Commit: ed3d17e14c1edbbb114e1490bca5e998cd108e86
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ed3d17e14c1edbbb114e1490bca5e998cd108e86

Author: Jakob Bornecrantz <wallbraker at gmail.com>
Date:   Sun Jun 13 16:07:49 2010 +0200

u_math: Add align function npot alignments

---

 src/gallium/auxiliary/util/u_math.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 6370e77..fe19466 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -567,12 +567,26 @@ util_bswap16(uint16_t n)
 #define MAX3( A, B, C ) MAX2( MAX2( A, B ), C )
 
 
+/**
+ * Align a value, only works pot alignemnts.
+ */
 static INLINE int
 align(int value, int alignment)
 {
    return (value + alignment - 1) & ~(alignment - 1);
 }
 
+/**
+ * Works like align but on npot alignments.
+ */
+static INLINE size_t
+util_align_npot(size_t value, size_t alignment)
+{
+   if (value % alignment)
+      return value + (alignment - (value % alignment));
+   return value;
+}
+
 static INLINE unsigned
 u_minify(unsigned value, unsigned levels)
 {




More information about the mesa-commit mailing list