From daedacc87717fc8fdfa4d02abd37563eb081e2ed Mon Sep 17 00:00:00 2001 From: Paul Gruenbacher Date: Wed, 31 Jan 2024 14:00:16 -0600 Subject: [PATCH] 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 <64050682+RazielXYZ@users.noreply.github.com> --------- Co-authored-by: Raziel Alphadios <64050682+RazielXYZ@users.noreply.github.com> --- src/image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image.cpp b/src/image.cpp index a1b0432..2593d34 100644 --- a/src/image.cpp +++ b/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);