diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/macros.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index dafeaa372f1..5228c3a8f28 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -685,6 +685,17 @@ minify(unsigned value, unsigned levels) } /** + * Return true if the given value is a power of two. + * + * Note that this considers 0 a power of two. + */ +static inline bool +is_power_of_two(unsigned value) +{ + return (value & (value - 1)) == 0; +} + +/** * Align a value up to an alignment value * * If \c value is not already aligned to the requested alignment value, it |