Here is the KTX file structure from http://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec
<pre =“pseudo-code” style="margin-left: 0em; font-size: medium; page-break-inside: avoid; text-align: left; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-color: initial; -: initial; -attachment: initial; -origin: initial; -clip: initial; padding-top: 0.5em; padding-right: 1em; padding-bottom: 0.5em; padding-left: 1em; min-width: 45em; border-color: initial; line-height: 20px; -webkit-text-size-adjust: none; ">Byte[12] identifier
UInt32 endianness
UInt32 glType
UInt32 glTypeSize
UInt32 glFormat
Uint32 glInternalFormat
Uint32 glBaseInternalFormat
UInt32 pixelWidth
UInt32 pixelHeight
UInt32 pixelDepth
UInt32 numberOfArrayElements
UInt32 numberOfFaces
UInt32 numberOfMipmapLevels
UInt32 bytesOfKeyValueData
for each keyValuePair that fits in bytesOfKeyValueData
UInt32 keyAndValueByteSize
Byte keyAndValue[keyAndValueByteSize]
Byte valuePadding[3 - ((keyAndValueByteSize + 3) % 4)]
end
for each mipmap_level in numberOfMipmapLevels
UInt32 imageSize;
for each array_element in numberOfArrayElements
for each face in numberOfFaces
for each z_slice in pixelDepth
for each row or row_of_blocks in pixelHeight
for each pixel or block_of_pixels in pixelWidth
Byte data[format-specific-number-of-bytes]**
end
end
end
Byte cubePadding[0-3]
end
end
Byte mipPadding[3 - ((imageSize + 3) % 4)]
end
UInt32 endianness
UInt32 glType
UInt32 glTypeSize
UInt32 glFormat
Uint32 glInternalFormat
Uint32 glBaseInternalFormat
UInt32 pixelWidth
UInt32 pixelHeight
UInt32 pixelDepth
UInt32 numberOfArrayElements
UInt32 numberOfFaces
UInt32 numberOfMipmapLevels
UInt32 bytesOfKeyValueData
for each keyValuePair that fits in bytesOfKeyValueData
UInt32 keyAndValueByteSize
Byte keyAndValue[keyAndValueByteSize]
Byte valuePadding[3 - ((keyAndValueByteSize + 3) % 4)]
end
for each mipmap_level in numberOfMipmapLevels
UInt32 imageSize;
for each array_element in numberOfArrayElements
for each face in numberOfFaces
for each z_slice in pixelDepth
for each row or row_of_blocks in pixelHeight
for each pixel or block_of_pixels in pixelWidth
Byte data[format-specific-number-of-bytes]**
end
end
end
Byte cubePadding[0-3]
end
end
Byte mipPadding[3 - ((imageSize + 3) % 4)]
end
I found the PVRTexLib save incorrect KTX file that missed “UInt32 imageSize;” before every MIPMaps level compressed pixel data.
Mali GPU Texture Compression Tool is corrected.
Same issue with PVRTexTool GUI/CL.