Skip to content

Commit

Permalink
imageGetSize now takes an additional mip num argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mindstab committed May 30, 2023
1 parent ec02df8 commit ce8c1e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/bimg/bimg.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ namespace bimg
, bool _hasMips
, uint16_t _numLayers
, TextureFormat::Enum _format
, uint8_t _numMips = 0
);

///
Expand Down
4 changes: 2 additions & 2 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ namespace bimg
return numMips;
}

uint32_t imageGetSize(TextureInfo* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format)
uint32_t imageGetSize(TextureInfo* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint8_t _numMips)
{
const ImageBlockInfo& blockInfo = getBlockInfo(_format);
const uint8_t bpp = blockInfo.bitsPerPixel;
Expand All @@ -329,7 +329,7 @@ namespace bimg
_width = bx::max<uint16_t>(blockWidth * minBlockX, ( (_width + blockWidth - 1) / blockWidth)*blockWidth);
_height = bx::max<uint16_t>(blockHeight * minBlockY, ( (_height + blockHeight - 1) / blockHeight)*blockHeight);
_depth = bx::max<uint16_t>(1, _depth);
const uint8_t numMips = calcNumMips(_hasMips, _width, _height, _depth);
const uint8_t numMips = _numMips > 0 ? _numMips : calcNumMips(_hasMips, _width, _height, _depth);
const uint32_t sides = _cubeMap ? 6 : 1;

uint32_t width = _width;
Expand Down

0 comments on commit ce8c1e1

Please sign in to comment.