From 52b46d9fd64fa89af4e772a675bb2cc3579a0415 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 21 Nov 2012 20:47:20 +0100 Subject: [PATCH] Implement prev_pow2 - will need this for 360 to round down texture formats if passed value too large --- general.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/general.h b/general.h index 90a25b9c75..ee4e8b3e05 100644 --- a/general.h +++ b/general.h @@ -632,6 +632,16 @@ static inline uint32_t next_pow2(uint32_t v) return v; } +static inline uint32_t prev_pow2(uint32_t v) +{ + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + return v - (v >> 1); +} + static inline uint8_t is_little_endian(void) { union