summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/macros.h
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2013-07-07 18:38:38 -0700
committerKenneth Graunke <kenneth@whitecape.org>2013-10-13 00:10:44 -0700
commit1a82081db6e57eaa74f852ed8acb391a7f4c2ca6 (patch)
tree32213973060fe67f5530e6a6c3f16b2c74e95ba7 /src/mesa/main/macros.h
parent50c9f04c5f5700ac27f8552694d2a2f2ab6fe89f (diff)
downloadexternal_mesa3d-1a82081db6e57eaa74f852ed8acb391a7f4c2ca6.zip
external_mesa3d-1a82081db6e57eaa74f852ed8acb391a7f4c2ca6.tar.gz
external_mesa3d-1a82081db6e57eaa74f852ed8acb391a7f4c2ca6.tar.bz2
mesa: Move ROUND_DOWN_TO() macro from i915/i965 to macros.h.
This seems generally useful, so it may as well live in core Mesa. In fact, the comment for ALIGN() in macros.h actually says to "see also" ROUND_DOWN_TO, which...was in a driver somewhere. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa/main/macros.h')
-rw-r--r--src/mesa/main/macros.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 05aad4e..4bb17d8 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -675,6 +675,18 @@ minify(unsigned value, unsigned levels)
*/
#define ALIGN(value, alignment) (((value) + (alignment) - 1) & ~((alignment) - 1))
+/**
+ * Align a value down to an alignment value
+ *
+ * If \c value is not already aligned to the requested alignment value, it
+ * will be rounded down.
+ *
+ * \param value Value to be rounded
+ * \param alignment Alignment value to be used. This must be a power of two.
+ *
+ * \sa ALIGN()
+ */
+#define ROUND_DOWN_TO(value, alignment) ((value) & ~(alignment - 1))
/** Cross product of two 3-element vectors */