LibGL+LibSoftGPU: Use more expressive is_power_of_two

This commit is contained in:
Jelle Raaijmakers 2022-01-30 16:11:36 +01:00 committed by Linus Groh
parent 971b39ae4f
commit 7004b20656
Notes: sideshowbarker 2024-07-17 18:23:28 +09:00
2 changed files with 5 additions and 10 deletions

View File

@ -971,8 +971,8 @@ void SoftwareGLContext::gl_tex_image_2d(GLenum target, GLint level, GLint intern
RETURN_WITH_ERROR_IF(width < 0 || height < 0 || width > (2 + Texture2D::MAX_TEXTURE_SIZE) || height > (2 + Texture2D::MAX_TEXTURE_SIZE), GL_INVALID_VALUE);
// Check if width and height are a power of 2
if (!m_device_info.supports_npot_textures) {
RETURN_WITH_ERROR_IF((width & (width - 1)) != 0, GL_INVALID_VALUE);
RETURN_WITH_ERROR_IF((height & (height - 1)) != 0, GL_INVALID_VALUE);
RETURN_WITH_ERROR_IF(!is_power_of_two(width), GL_INVALID_VALUE);
RETURN_WITH_ERROR_IF(!is_power_of_two(height), GL_INVALID_VALUE);
}
RETURN_WITH_ERROR_IF(border != 0, GL_INVALID_VALUE);

View File

@ -19,14 +19,9 @@ Image::Image(unsigned width, unsigned height, unsigned depth, unsigned max_level
VERIFY(max_levels > 0);
VERIFY(layers > 0);
if ((width & (width - 1)) == 0)
m_width_is_power_of_two = true;
if ((height & (height - 1)) == 0)
m_height_is_power_of_two = true;
if ((depth & (depth - 1)) == 0)
m_depth_is_power_of_two = true;
m_width_is_power_of_two = is_power_of_two(width);
m_height_is_power_of_two = is_power_of_two(height);
m_depth_is_power_of_two = is_power_of_two(depth);
unsigned level;
for (level = 0; level < max_levels; ++level) {