Imagination PowerVR SDK Blog

Incorrect KTX file structure when use PVRTexLib



Here is the KTX file structure from

<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)]


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]**




Byte cubePadding[0-3]



Byte mipPadding[3 - ((imageSize + 3) % 4)]

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.


Yikes, good catch!

I’m not 100% why this hasn’t been noticed before but I’ll definitely fix this for the next release.

If this is a blocking issue for you, if you email I should be able to provide a version with the fix in. Otherwise the next release should be available within the next month or so.




I’ve mailed you already.