summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2010-06-13 16:07:49 +0200
committerJakob Bornecrantz <[email protected]>2010-06-22 20:04:54 +0200
commited3d17e14c1edbbb114e1490bca5e998cd108e86 (patch)
treeac1479cc7541968b16887e52f0bb8f03d0f57310
parent3a3e80ff96b1d564cc128f2fff8d0da11ae0ba84 (diff)
u_math: Add align function npot alignments
-rw-r--r--src/gallium/auxiliary/util/u_math.h14
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 6370e779865..fe19466436a 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)
{