Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception (per KTX spec) of imageSize for non-array cubemap textures. #42

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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