BUG: PowerVR Texture Tool KTX Export Error

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  PaulL 2 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31908

    Dear PowerVR,
    your texture tool is amazing, but i have found a bug. When u export a KTX file, in certain cases, it has wrong imageSize. The export image bytes are correct, but the imageSize parameter is not. This is a serious problem, couz my ktx loader implementation relie on this parameter (also severel others like PicoPixel). But good news, it is easy to fix.
    KTX File Format Specification says:

    imageSize is the number of bytes of pixel data in the current LOD level. This includes all z slices, all faces, all rows (or rows of blocks) and all pixels (or blocks) in each row for the mipmap level

    also says:

    Uncompressed texture data matches a GL_UNPACK_ALIGNMENT of 4

    .
    So let count together: I have an 2×2 GL_RGB GL_UNSIGNED_BYTE image (mipmap level). Your implementation returns 12 for imageSize. This is wrong! U have to include the padding on scanline. Becouse the first row of byte are (RGBRGB) 6bytes long, but u shold round that up to 8 bytes (UNPACK_ALIGNMENT). Correct way to calculate imageSize is (SOLUTION):

    uint bpp=8; //the size of the pixel in bits;
    uint width=2; //the width of the image (or mipmap level)
    uint height=2; //the height of the image (or mipmap level)
    uint scanlineSize=bpp*width/8; //its 6
    scanlineSize+=3-(scanlineSize+3)%4; //round up to 4 byte boundary! so its 8
    uint imageSize=scanlineSize*height;

    Plz fix your code, i woud like to avoid crashes and recalculation of this parameter. (Even picopixel crashes)
    Thank You:
    collerblade

    #39258

    Forget to mention: The image bytes are correct! So there is no need to change that! Only the imageSize parameter is wrong!

    #39259

    PaulL
    Admin

    Thank you for your feedback, I’ve filed a bug report on our internal tracker (BRN52842).

    Look out for the BRN number in future release notes.

    Thanks,
    Paul.

    #39260

    Thank You!

    A minor modification:
    Bpp is actually 24bit i was mistaken.

    uint bpp=24; //the size of the pixel in bits;
    uint width=2; //the width of the image (or mipmap level)
    uint height=2; //the height of the image (or mipmap level)
    uint scanlineSize=bpp*width/8; //its 6
    scanlineSize+=3-(scanlineSize+3)%4; //round up to 4 byte boundary! so its 8
    uint imageSize=scanlineSize*height;

    Also the editor crashes, while tries to open the “rgb-mipmap-reference.ktx” file. This file is a reference ktx file.

    Collerblade

    #39261

    PaulL
    Admin

    Thank you again for your feedback.

    I’ve filed a bug report for the KTX reference file open failure on our internal tracker (BRN52880).

    Thanks,
    Paul.

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