KhronosGroup / KTX-Software

KTX (Khronos Texture) Library and Tools
Other
874 stars 229 forks source link

KTX1 - ktxinfo incorrect validation of GL_LUMINANCE and GL_LUMINANCE_ALPHA? #615

Closed solidpixel closed 2 years ago

solidpixel commented 2 years ago

I think it is intended that KTX1 supports the legacy GL_LUMINANCE and GL_LUMINANCE_ALPHA pixel formats, given that it doesn't allow the KTXswizzle metadata that KTX2 has. For OpenGL ES 2.0 glTexSubImage2D() for these formats you specify the LUM/LUM_ALP as both the "internalFormat" and the "format", as there is no sized equivalent.

Currently ktxinfo throws an error that the format is invalid if format and internalFormat are the same. Am I handling these wrong?

MarkCallow commented 2 years ago

Actually it is libktx that is throwing the error. The code comment which you originally included in the issue report explains why.

// glInternalFormat is either unsized (which is no longer and should
// never have been supported by libktx) or glFormat is sized.

Note the part in parentheses.

In a KTX file you should specify as glInternalFormat the appropriate sized LUMINANCE format for the glType, e.g. GL_LUMINANCE8_ALPHA8. Specify, e.g. GL_LUMINANCE_ALPHA as the format and glBaseInternalFormat. A GL loader when loading to older versions such as OpenGL ES 2.0 should use the glBaseInternalFormat field value as internalformat parameter of glTex{,Sub}Image2D. ktxTexture_GLupload does this.

solidpixel commented 2 years ago

Thanks Mark.