Closed MarkCallow closed 4 months ago
Compressed formats use only internalformat
in OpenGL. See https://registry.khronos.org/OpenGL-Refpages/gl4/html/glCompressedTexImage2D.xhtml.
Compressed formats use only internalformat in OpenGL
If you use glCompressedTexImage2D
, but you can also use glTexImage2D
. See https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml and https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt.
In the context of libktx, it is already identifying compressed textures and using glCompressedTexImage*
to load them so it isn't much of a problem provided the format lookup, which happens earlier, is guarded. In the general context of a KTX file one can use the DFD's colorModel
to quickly determine if a texture is compressed so I suppose it is okay to force everyone to have to choose the upload command according to the internalformat.
Please add a note at the top of Appendix B and to switch_test/vk2gl.c
to the effect that for compressed formats only the mapping to the GL internalformat is provided. In vk2gl.c
add something like "therefore only vkFormat2glInternalFormat provides a valid result."
but you can also use
glTexImage2D
That workflow has different semantics and is unrelated to KTX operations. Specifically, the following command uploads uncompressed RGBA8 data and expects the OpenGL driver to compress it on the fly.
glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
That workflow has different semantics
Oh! Silly me. Apologies. A comment in vk2gl.c is still a good idea, maybe not so important in Appendix B.
Here are the line counts for each file:
Note that
2glFormat
and2glType
have only 96 lines which 2glInternalFormat has 202.mtl
and dxgi` look suspiciously short as well.I ran into this while trying to get the glFormat for
VK_FORMAT_BC3_UNORM_BLOCK
and not finding it. Its not the generator. The data is missing informats.json
.I am aware that most block compressed formats have a glFormat of GL_RGBA and glType of GL_UNSIGNED_BYTE. Most, but not all. Even if these values are true for the equivalents of all VkFormats used in ktx v2, when all you have is the token value it is not easy to special case for the compressed formats. It would be better if all formats can be handled uniformly. Therefore type and format info should be included in the database entry for all formats having a GL equivalent.