getMipLevelSizeInBytes method
- int mipLevel
Returns the size in bytes of the mipLevel mip level (one slice). Mip
dimensions are clamped at 1, matching standard mip chain semantics. For
block-compressed formats the dimensions are rounded up to whole blocks.
Implementation
int getMipLevelSizeInBytes(int mipLevel) {
final int w = getMipLevelWidth(mipLevel);
final int h = getMipLevelHeight(mipLevel);
final int bw = format.blockWidth;
final int bh = format.blockHeight;
final int blocksWide = (w + bw - 1) ~/ bw;
final int blocksHigh = (h + bh - 1) ~/ bh;
return blocksWide * blocksHigh * format.bytesPerBlock;
}