[Mesa-dev] [PATCH 02/28] replace _mesa_next_pow_two_* with util_next_power_of_two_*

Dylan Baker dylan at pnwbakers.com
Fri Nov 9 18:39:55 UTC 2018


The 64 bit variant in imports.h isn't even used.
---
 .../drivers/dri/radeon/radeon_mipmap_tree.c   |  2 +-
 src/mesa/main/imports.h                       | 52 -------------------
 2 files changed, 1 insertion(+), 53 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index c4b3c61cbf4..7f02143e08a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -129,7 +129,7 @@ static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree
 	radeon_mipmap_level *lvl = &mt->levels[level];
 	GLuint height;
 
-	height = _mesa_next_pow_two_32(lvl->height);
+	height = util_next_power_of_two(lvl->height);
 
 	lvl->rowstride = get_texture_image_row_stride(rmesa, mt->mesaFormat, lvl->width, mt->tilebits, mt->target);
 	lvl->size = get_texture_image_size(mt->mesaFormat, lvl->rowstride, height, lvl->depth, mt->tilebits);
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 6193a83396f..3ed2c5edb07 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -205,58 +205,6 @@ static inline int IFLOOR(float f)
 #endif
 }
 
-/**
- * Round given integer to next higer power of two
- * If X is zero result is undefined.
- *
- * Source for the fallback implementation is
- * Sean Eron Anderson's webpage "Bit Twiddling Hacks"
- * http://graphics.stanford.edu/~seander/bithacks.html
- *
- * When using builtin function have to do some work
- * for case when passed values 1 to prevent hiting
- * undefined result from __builtin_clz. Undefined
- * results would be different depending on optimization
- * level used for build.
- */
-static inline int32_t
-_mesa_next_pow_two_32(uint32_t x)
-{
-#ifdef HAVE___BUILTIN_CLZ
-	uint32_t y = (x != 1);
-	return (1 + y) << ((__builtin_clz(x - y) ^ 31) );
-#else
-	x--;
-	x |= x >> 1;
-	x |= x >> 2;
-	x |= x >> 4;
-	x |= x >> 8;
-	x |= x >> 16;
-	x++;
-	return x;
-#endif
-}
-
-static inline int64_t
-_mesa_next_pow_two_64(uint64_t x)
-{
-#ifdef HAVE___BUILTIN_CLZLL
-	uint64_t y = (x != 1);
-	STATIC_ASSERT(sizeof(x) == sizeof(long long));
-	return (1 + y) << ((__builtin_clzll(x - y) ^ 63));
-#else
-	x--;
-	x |= x >> 1;
-	x |= x >> 2;
-	x |= x >> 4;
-	x |= x >> 8;
-	x |= x >> 16;
-	x |= x >> 32;
-	x++;
-	return x;
-#endif
-}
-
 
 /*
  * Returns the floor form of binary logarithm for a 32-bit integer.
-- 
2.19.1



More information about the mesa-dev mailing list