Last active
December 1, 2023 03:27
-
-
Save doug65536/2c9f8a7b1b6b05349e7dbe833c878483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t indexof_mipmap(int level) | |
{ | |
int mask = ~((level - 1) >> 31); | |
uint32_t lvl0sz = texture->iw * texture->ih; | |
int kept = 2 * (level - 1) & mask; | |
uint32_t mul = (0x55555555 >> ((32 - kept) - 2)) & mask; | |
return (lvl0sz * mul) >> (kept & mask); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment