Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced floor(log2(dim) with r_integer_log_2 #383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/renderer/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ TextureType r_texture_type_from_pixmap_format(PixmapFormat fmt) {

uint r_texture_util_max_num_miplevels(uint width, uint height) {
uint dim = max(width, height);
return dim > 0 ? 1 + floor(log2(dim)) : 0; // TODO replace with integer log2
return dim > 0 ? 1 + r_integer_log_2(dim) : 0;
}

Framebuffer* r_framebuffer_create(void) {
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1012,3 +1012,10 @@ INLINE
bool r_supports(RendererFeature feature) {
return r_features() & r_feature_bit(feature);
}

INLINE
uint r_integer_log_2(uint x) {
uint log = 0;
while(x >>= 1) ++log;
return log;
}