diff options
author | Dylan Baker <[email protected]> | 2018-09-06 11:36:19 -0700 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2020-04-21 11:09:03 -0700 |
commit | e533fad182e7069ee0850154f51316dd779501c3 (patch) | |
tree | aa38ebcd833ad137faf53889fea2202bac7e9eab /src/mesa | |
parent | c1e7c1f4224789f0bc4cc847cecde350e2c6d2f2 (diff) |
replace _mesa_is_pow_two with util_is_power_of_two_*
Mostly this uses util_is_power_of_two_or_zero, which has the same
behavior as _mesa_is_pow_two when the input is zero. In cases where the
value is known to be != 0 ahead of time I used the _nonzero variant as
it may be faster on some platforms.
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Kristian H. Kristensen <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/common/meta_blit.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/i915_texstate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv04_surface.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 2 | ||||
-rw-r--r-- | src/mesa/main/pixel.c | 6 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 26 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_light.c | 2 |
8 files changed, 27 insertions, 27 deletions
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; |