summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/intel/compiler/brw_reg.h2
-rw-r--r--src/intel/compiler/brw_vec4_generator.cpp3
-rw-r--r--src/mesa/drivers/common/meta_blit.c6
-rw-r--r--src/mesa/drivers/dri/i915/i915_texstate.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_surface.c4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c2
-rw-r--r--src/mesa/main/pixel.c6
-rw-r--r--src/mesa/main/teximage.c26
-rw-r--r--src/mesa/swrast/s_texture.c6
-rw-r--r--src/mesa/tnl/t_vb_light.c2
-rw-r--r--src/util/imports.h10
11 files changed, 29 insertions, 40 deletions
diff --git a/src/intel/compiler/brw_reg.h b/src/intel/compiler/brw_reg.h
index 60dc2778edd..865cd9e0f36 100644
--- a/src/intel/compiler/brw_reg.h
+++ b/src/intel/compiler/brw_reg.h
@@ -986,7 +986,7 @@ static inline struct brw_reg
spread(struct brw_reg reg, unsigned s)
{
if (s) {
- assert(_mesa_is_pow_two(s));
+ assert(util_is_power_of_two_nonzero(s));
if (reg.hstride)
reg.hstride += cvt(s) - 1;
diff --git a/src/intel/compiler/brw_vec4_generator.cpp b/src/intel/compiler/brw_vec4_generator.cpp
index be5eaf43ca0..bdc45371c4e 100644
--- a/src/intel/compiler/brw_vec4_generator.cpp
+++ b/src/intel/compiler/brw_vec4_generator.cpp
@@ -2064,8 +2064,7 @@ generate_code(struct brw_codegen *p,
*
* where they pack the four bytes from the low and high four DW.
*/
- assert(_mesa_is_pow_two(dst.writemask) &&
- dst.writemask != 0);
+ assert(util_is_power_of_two_nonzero(dst.writemask));
unsigned offset = __builtin_ctz(dst.writemask);
dst.type = BRW_REGISTER_TYPE_UB;
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 96f1cba9d6f..9c218568a6e 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -85,7 +85,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
y_scale = samples / x_scale;
/* We expect only power of 2 samples in source multisample buffer. */
- assert(samples > 0 && _mesa_is_pow_two(samples));
+ assert(samples > 0 && util_is_power_of_two_nonzero(samples));
while (samples >> (shader_offset + 1)) {
shader_offset++;
}
@@ -278,7 +278,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
}
/* We expect only power of 2 samples in source multisample buffer. */
- assert(samples > 0 && _mesa_is_pow_two(samples));
+ assert(samples > 0 && util_is_power_of_two_nonzero(samples));
while (samples >> (shader_offset + 1)) {
shader_offset++;
}
@@ -482,7 +482,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
* (so the floating point exponent just gets increased), rather than
* doing a naive sum and dividing.
*/
- assert(_mesa_is_pow_two(samples));
+ assert(util_is_power_of_two_or_zero(samples));
/* Fetch each individual sample. */
sample_resolve = rzalloc_size(mem_ctx, 1);
for (i = 0; i < samples; i++) {
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 544aaa72097..6b4f6ed38e2 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -342,7 +342,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
* Thus, I guess we need do this for other platforms as well.
*/
if (tObj->Target == GL_TEXTURE_CUBE_MAP_ARB &&
- !_mesa_is_pow_two(firstImage->Height))
+ !util_is_power_of_two_or_zero(firstImage->Height))
return false;
state[I915_TEXREG_SS3] = ss3; /* SS3_NORMALIZED_COORDS */
diff --git a/src/mesa/drivers/dri/nouveau/nv04_surface.c b/src/mesa/drivers/dri/nouveau/nv04_surface.c
index 7fb2de15683..91c1fbb0739 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_surface.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_surface.c
@@ -208,8 +208,8 @@ nv04_surface_copy_swizzle(struct gl_context *ctx,
unsigned x, y;
/* Swizzled surfaces must be POT */
- assert(_mesa_is_pow_two(dst->width) &&
- _mesa_is_pow_two(dst->height));
+ assert(util_is_power_of_two_or_zero(dst->width) &&
+ util_is_power_of_two_or_zero(dst->height));
if (context_chipset(ctx) < 0x10) {
BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index 8d01e21db72..51f99ffe6e6 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -102,7 +102,7 @@ unsigned get_texture_image_row_stride(radeonContextPtr rmesa, mesa_format format
} else {
unsigned row_align;
- if (!_mesa_is_pow_two(width) || target == GL_TEXTURE_RECTANGLE) {
+ if (!util_is_power_of_two_or_zero(width) || target == GL_TEXTURE_RECTANGLE) {
row_align = rmesa->texture_rect_row_align - 1;
} else if (tiling) {
unsigned tileWidth, tileHeight;
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index d8dfab7be2b..3623030071f 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -184,7 +184,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
/* test that mapsize is a power of two */
- if (!_mesa_is_pow_two(mapsize)) {
+ if (!util_is_power_of_two_or_zero(mapsize)) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
return;
}
@@ -225,7 +225,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
/* test that mapsize is a power of two */
- if (!_mesa_is_pow_two(mapsize)) {
+ if (!util_is_power_of_two_or_zero(mapsize)) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
return;
}
@@ -280,7 +280,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
/* test that mapsize is a power of two */
- if (!_mesa_is_pow_two(mapsize)) {
+ if (!util_is_power_of_two_or_zero(mapsize)) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" );
return;
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 86de72d7593..47220c917cf 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -977,7 +977,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+ if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
return GL_FALSE;
}
return GL_TRUE;
@@ -992,9 +992,9 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
if (height < 2 * border || height > 2 * border + maxSize)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+ if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+ if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
return GL_FALSE;
}
return GL_TRUE;
@@ -1010,11 +1010,11 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
if (depth < 2 * border || depth > 2 * border + maxSize)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+ if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+ if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
return GL_FALSE;
- if (depth > 0 && !_mesa_is_pow_two(depth - 2 * border))
+ if (depth > 0 && !util_is_power_of_two_nonzero(depth - 2 * border))
return GL_FALSE;
}
return GL_TRUE;
@@ -1047,9 +1047,9 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
if (height < 2 * border || height > 2 * border + maxSize)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+ if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+ if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
return GL_FALSE;
}
return GL_TRUE;
@@ -1062,7 +1062,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
if (height < 0 || height > ctx->Const.MaxArrayTextureLayers)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+ if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
return GL_FALSE;
}
return GL_TRUE;
@@ -1079,9 +1079,9 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
if (depth < 0 || depth > ctx->Const.MaxArrayTextureLayers)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+ if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+ if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
return GL_FALSE;
}
return GL_TRUE;
@@ -1100,9 +1100,9 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
if (level >= ctx->Const.MaxCubeTextureLevels)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+ if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+ if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
return GL_FALSE;
}
return GL_TRUE;
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index d35bea96b92..b41cd5d57ae 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -127,9 +127,9 @@ _swrast_init_texture_image(struct gl_texture_image *texImage)
{
struct swrast_texture_image *swImg = swrast_texture_image(texImage);
- if ((texImage->Width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
- (texImage->Height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
- (texImage->Depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
+ if ((texImage->Width == 1 || util_is_power_of_two_or_zero(texImage->Width2)) &&
+ (texImage->Height == 1 || util_is_power_of_two_or_zero(texImage->Height2)) &&
+ (texImage->Depth == 1 || util_is_power_of_two_or_zero(texImage->Depth2)))
swImg->_IsPowerOfTwo = GL_TRUE;
else
swImg->_IsPowerOfTwo = GL_FALSE;
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index cd0a5544c93..655e5827d0c 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -399,7 +399,7 @@ static void validate_lighting( struct gl_context *ctx,
}
else {
/* Power of two means only a single active light. */
- if (_mesa_is_pow_two(ctx->Light._EnabledLights))
+ if (util_is_power_of_two_or_zero(ctx->Light._EnabledLights))
tab = _tnl_light_fast_single_tab;
else
tab = _tnl_light_fast_tab;
diff --git a/src/util/imports.h b/src/util/imports.h
index 4ebae04ffc7..03a6c0ef358 100644
--- a/src/util/imports.h
+++ b/src/util/imports.h
@@ -190,16 +190,6 @@ static inline int IFLOOR(float f)
#endif
}
-
-/**
- * Is x a power of two?
- */
-static inline int
-_mesa_is_pow_two(int x)
-{
- return !(x & (x - 1));
-}
-
/**
* Round given integer to next higer power of two
* If X is zero result is undefined.