Skip to content

Commit

Permalink
Implement exception (per KTX spec) of imageSize for non-array cubemap…
Browse files Browse the repository at this point in the history
… textures.

fixes BinomialLLC#40
  • Loading branch information
jimblacklercorp committed Jun 20, 2019
1 parent f0cb9db commit b274b7b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion basisu_gpu_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,10 @@ namespace basisu
{
uint32_t img_size = gpu_images[0][level_index].get_size_in_bytes();

img_size = img_size * header.m_numberOfFaces * maximum<uint32_t>(1, header.m_numberOfArrayElements);
// KTX spec: "For most textures imageSize is the number of bytes of pixel data in the current LOD level.
// For non-array cubemap textures imageSize is the number of bytes in each face of the texture for the current LOD level."
if (!cubemap_flag || header.m_numberOfArrayElements > 0)
img_size = img_size * header.m_numberOfFaces * maximum<uint32_t>(1, header.m_numberOfArrayElements);

assert(img_size && ((img_size & 3) == 0));

Expand All @@ -703,6 +706,9 @@ namespace basisu

} // array_index

if (cubemap_flag && header.m_numberOfArrayElements == 0)
img_size = img_size * header.m_numberOfFaces;

assert(bytes_written == img_size);

} // level_index
Expand Down

0 comments on commit b274b7b

Please sign in to comment.