KTX example files issues


I’m trying to integrate KTX support into my application, but I’m encountering some issues trying to make sure my KTX serializer and parser code is correct. I’m currently trying to write a validation routine and I’m getting failures when I apply it to the example files in https://github.com/KhronosGroup/KTX/tree/master/testimages

down-reference.ktx contains an internal format of GL_RGB. I thought that internal format was intended to be a sized format.

etc2-sRGB.ktx contains a base internal format of GL_SRGB. I’m unclear on the interaction between SRGB and KTX. https://forums.khronos.org/showthread.php/9572-Storing-color-space-in-KeyValue-data seems to indicate that you should be able to store SRGB data and mark it as such in the glInternalFormat field, but should the corresponding glBaseInternalFormat then be GL_RGB or GL_SRGB? Given that the spec states that glBaseInternalFormat is only for use when contexts don’t support sized format, such as unextended OpenGL ES 2.0 and GL ES 2.0 also doesn’t support SRGB, it seems like this should be GL_RGB.

Both etc2-sRGBa1.ktx and etc2-sRGBa8.ktx have a base internal format of GL_SRGB8_ALPHA8. This seems to defy the spec in two ways, first by being an SRGB reference, based on my point above, and second, by being a sized format, rather than an unsized one, such as GL_RGBA or even GL_SRGB_ALPHA.

Can anyone explain how my validation of these is incorrect based on the spec, or alternatively confirm that these values don’t make sense?


I think your validation is correct and that I made a mistake allowing toktx to write unsized internal formats. I plan to remove that feature and the support in libktx for loading such files. Is down-reference.ktx the only one you found? I think that at least rgba-reference.ktx may also have this problem. I filed https://github.com/KhronosGroup/KTX/issues/30 to remind me to do it. It will be a little while before I can get to it. A pull request - against incoming - would be welcome.

As for the ETC files, the culprit there is ETCPACK. It has the code that writes those odd base internal formats and I copied the files from its testing/testvectors_correct/ktx folder. Please file an issue over there. When loading compressed files baseInternalFormat is not needed. Even when doing decompression in software prior to loading into GL, it is not useful. It is necessary to determine the size, data type and sized internal format necessary to accommodate the uncompressed data and the switch statements or tables to accomplish that can easily select the format as well. So libktx ignores it and therefore has no problem loading these files. However when the issue gets fixed in ETCPACK, I will update the images.

What is your application? Could you contribute the validator as a separate program? It would be useful.


It’s part of the VR application I work on for High Fidelity. I can probably break out the validation logic into a standalone application, but it would be C++. The validation code itself isn’t very long and is visible in this PR: https://github.com/highfidelity/hifi/pull/10458/files

I’m about to go on vacation for the next week, but if I have time I’ll try to create a simple app for validation.


thank you guys so much for sharing this interest information, love you :smiley: