KTX alignment in TexTool

This topic contains 1 reply, has 2 voices, and was last updated by  CarlosSarria 3 weeks, 5 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #58736

    Brad
    Member

    I’m trying to load up a KTX file I encoded from a PNG in PVRTexTool in my application, but the file won’t load. The original image is a roughness map and I encoded it as GL_RED8 with mipmap generation.

    I traced into the code it appears to be an issue with the image sizes. When I get down to the 2×2 mip, the file reports an image size of 4 bytes. However, the KTX specification says

    Uncompressed texture data matches a GL_UNPACK_ALIGNMENT of 4.

    meaning that each row of the image data must be 4 byte aligned. So the image size should be 8, not 4 (2 rows of 4 bytes each, the first two of which are the pixel data, and the remaining two as padding).

    Is my reading of the KTX spec incorrect?

    • This topic was modified 1 month ago by  Brad.
    #58745

    Hi Brad,

    Yes, your reading is correct and this is a bug in PVRTexTool. PVRTexTool writes out the correct amount of padding per row but we don’t seem to be taking row alignment when calculating the texture size. So that even though the data for a 2×2 8bpp mipmap is written out correctly as 8 bytes, we only write the value of 4 for the mipmap size instead of this 8.
    We have fixed this problem in our MAIN branch and it will be available in our next release.

    Thanks!

    Carlos.

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.