16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

Replace count_trailing_zeros with std::countr_zero

This commit is contained in:
docentYT
2026-05-01 17:43:43 +02:00
parent ec1dfae953
commit 0e6950a386
3 changed files with 3 additions and 15 deletions

View File

@@ -982,11 +982,11 @@ opengl_texture::create( bool const Static ) {
if (Global.gfx_usegles)
{
if( target == GL_TEXTURE_2D )
glTexStorage2D(target, count_trailing_zeros(std::max(data_width, data_height)) + 1, data_format, data_width, data_height);
glTexStorage2D(target, std::countr_zero(static_cast<unsigned int>(std::max(data_width, data_height))) + 1, data_format, data_width, data_height);
else if( target == GL_TEXTURE_2D_MULTISAMPLE )
glTexStorage2DMultisample( target, samples, data_format, data_width, data_height, GL_FALSE );
else if( target == GL_TEXTURE_2D_ARRAY )
glTexStorage3D( target, count_trailing_zeros( std::max( data_width, data_height ) ) + 1, data_format, data_width, data_height, layers );
glTexStorage3D(target, std::countr_zero(static_cast<unsigned int>(std::max(data_width, data_height))) + 1, data_format, data_width, data_height, layers);
else if( target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY )
glTexStorage3DMultisample( target, samples, data_format, data_width, data_height, layers, GL_FALSE );
}

View File

@@ -457,14 +457,4 @@ std::string deserialize_random_set(cParser &Input, char const *Break)
// shouldn't ever get here but, eh
return "";
}
}
int count_trailing_zeros(uint32_t val)
{
int r = 0;
for (uint32_t shift = 1; !(val & shift); shift <<= 1)
r++;
return r;
}
}

View File

@@ -380,8 +380,6 @@ glm::dvec3 LoadPoint(class cParser &Input);
// extracts a group of tokens from provided data stream
std::string deserialize_random_set(cParser &Input, char const *Break = "\n\r\t ;");
int count_trailing_zeros(uint32_t val);
// extracts a group of <key, value> pairs from provided data stream
// NOTE: expects no more than single pair per line
template <typename MapType_> void deserialize_map(MapType_ &Map, cParser &Input)