Add mipmap calculation function
This commit is contained in:
parent
25153001c0
commit
fe4dd717f1
1 changed files with 16 additions and 0 deletions
|
|
@ -399,4 +399,20 @@ namespace psemek::gfx
|
|||
: id_{0}
|
||||
{}
|
||||
|
||||
template <std::size_t D>
|
||||
std::size_t mipmap_count(geom::vector<std::size_t, D> const & size)
|
||||
{
|
||||
std::size_t s = 0;
|
||||
for (std::size_t i = 0; i < D; ++i)
|
||||
s = std::max(s, size[i]);
|
||||
|
||||
std::size_t result = 1;
|
||||
while (s > 1)
|
||||
{
|
||||
s /= 2;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue