Browse Source

Fix ktx parsing failing if texture array has 6 layers (#84)

* Fix ktx parsing failing if texture array has 6 layers 

Fixing line in code that assumes if numSides == 6 then it must be a cubemap even though numSides in this situation can refer to numLayers as well.

* Update src/image.cpp

confirmed this works and makes sense

Co-authored-by: Raziel Alphadios <[email protected]>

---------

Co-authored-by: Raziel Alphadios <[email protected]>
Paul Gruenbacher 2 years ago
parent
commit
daedacc877
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/image.cpp

+ 1 - 1
src/image.cpp

@@ -5210,7 +5210,7 @@ namespace bimg
 
 				if (_imageContainer.m_ktx)
 				{
-					const uint32_t size = numSides == 6 ? mipSize : mipSize * numSides;
+					const uint32_t size = _imageContainer.m_numLayers == 1 && _imageContainer.m_cubeMap ? mipSize : mipSize * numSides;
 					uint32_t imageSize  = bx::toHostEndian(*(const uint32_t*)&data[offset], _imageContainer.m_ktxLE);
 					BX_ASSERT(size == imageSize, "KTX: Image size mismatch %d (expected %d).", size, imageSize);
 					BX_UNUSED(size, imageSize);