|
|
@@ -3136,15 +3136,18 @@ namespace bimg
|
|
|
|
|
|
for (uint8_t lod = 0, num = _imageContainer.m_numMips; lod < num; ++lod)
|
|
|
{
|
|
|
- uint32_t imageSize = bx::toHostEndian(*(const uint32_t*)&data[offset], _imageContainer.m_ktxLE) / _imageContainer.m_numLayers;
|
|
|
- offset += sizeof(uint32_t);
|
|
|
-
|
|
|
width = bx::uint32_max(blockWidth * minBlockX, ( (width + blockWidth - 1) / blockWidth )*blockWidth);
|
|
|
height = bx::uint32_max(blockHeight * minBlockY, ( (height + blockHeight - 1) / blockHeight)*blockHeight);
|
|
|
depth = bx::uint32_max(1, depth);
|
|
|
|
|
|
- uint32_t size = width*height*depth*bpp/8;
|
|
|
+ const uint32_t mipSize = width*height*depth*bpp/8;
|
|
|
+
|
|
|
+ const uint32_t size = mipSize*numSides;
|
|
|
+ uint32_t imageSize = bx::toHostEndian(*(const uint32_t*)&data[offset], _imageContainer.m_ktxLE);
|
|
|
BX_CHECK(size == imageSize, "KTX: Image size mismatch %d (expected %d).", size, imageSize);
|
|
|
+ BX_UNUSED(size, imageSize);
|
|
|
+
|
|
|
+ offset += sizeof(uint32_t);
|
|
|
|
|
|
for (uint16_t side = 0; side < numSides; ++side)
|
|
|
{
|
|
|
@@ -3154,7 +3157,7 @@ namespace bimg
|
|
|
_mip.m_width = width;
|
|
|
_mip.m_height = height;
|
|
|
_mip.m_blockSize = blockSize;
|
|
|
- _mip.m_size = size;
|
|
|
+ _mip.m_size = mipSize;
|
|
|
_mip.m_data = &data[offset];
|
|
|
_mip.m_bpp = bpp;
|
|
|
_mip.m_format = format;
|
|
|
@@ -3162,7 +3165,7 @@ namespace bimg
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- offset += imageSize;
|
|
|
+ offset += mipSize;
|
|
|
|
|
|
BX_CHECK(offset <= _size, "Reading past size of data buffer! (offset %d, size %d)", offset, _size);
|
|
|
BX_UNUSED(_size);
|