-
Notifications
You must be signed in to change notification settings - Fork 341
OpenGL texture format enums table
Here's a table of the OpenGL texture format / internal-format enums the command line tool writes into a .KTX (KTX1) file for each compressed texture format in the transcoder_texture_format enum in transcoder/basisu_transcoder.h. These are the values emitted by the KTX1 writer in encoder/basisu_gpu_texture.cpp.
The transcoder supports all of these GPU texture formats, and the encoder library has code to decompress all of them.
sRGB note: The rows below show the linear GL enums, which is what the CLI writes by default. When the KTX1 writer is invoked with its sRGB flag set, the sRGB-capable formats switch to their sRGB enums: LDR ASTC uses GL_COMPRESSED_SRGB8_ALPHA8_ASTC_WxH_KHR (0x93D0-0x93DD), BC1 0x8C4C, BC3 0x8C4F, BC7 0x8E8D, ETC2 RGBA 0x9279, and PVRTC1 RGB/RGBA 0x8A55/0x8A57. HDR formats never use sRGB enums.
| transcoder_texture_format | GL internal format | GL base internal format |
|---|---|---|
| cTFETC1_RGB | GL_ETC1_RGB8_OES (0x8D64) | GL_RGB (0x1907) |
| cTFETC2_RGBA | GL_COMPRESSED_RGBA8_ETC2_EAC (0x9278) | GL_RGBA (0x1908) |
| cTFBC1_RGB | GL_COMPRESSED_RGB_S3TC_DXT1_EXT (0x83F0) | GL_RGB (0x1907) |
| cTFBC3_RGBA | GL_COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F3) | GL_RGBA (0x1908) |
| cTFBC4_R | GL_COMPRESSED_RED_RGTC1_EXT (0x8DBB) | GL_RED (0x1903) |
| cTFBC5_RG | GL_COMPRESSED_RED_GREEN_RGTC2_EXT (0x8DBD) | GL_RG (0x8227) |
| cTFBC7_RGBA | GL_COMPRESSED_RGBA_BPTC_UNORM (0x8E8C) | GL_RGBA (0x1908) |
| cTFPVRTC1_4_RGB | GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG (0x8C00) | GL_RGB (0x1907) |
| cTFPVRTC1_4_RGBA | GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG (0x8C02) | GL_RGBA (0x1908) |
| cTFPVRTC2_4_RGB, cTFPVRTC2_4_RGBA | GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG (0x9138) | GL_RGBA (0x1908) |
| cTFATC_RGB | GL_ATC_RGB_AMD (0x8C92) | GL_RGB (0x1907) |
| cTFATC_RGBA | GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD (0x87EE) | GL_RGBA (0x1908) |
| cTFETC2_EAC_R11 | GL_COMPRESSED_R11_EAC (0x9270) | GL_RED (0x1903) |
| cTFETC2_EAC_RG11 | GL_COMPRESSED_RG11_EAC (0x9272) | GL_RG (0x8227) |
| cTFFXT1_RGB | GL_COMPRESSED_RGB_FXT1_3DFX (0x86B0) | GL_RGB (0x1907) |
Linear enums shown; the sRGB equivalents are the 0x93D0-0x93DD range in the same order. All use base internal format GL_RGBA (0x1908). Note the GL enum order is width-major (8x8 comes before 10x5), which differs from the area-ordered transcoder_texture_format enum — always map by block size, never by ordinal.
| transcoder_texture_format | GL internal format (linear) | sRGB equivalent |
|---|---|---|
| cTFASTC_LDR_4x4_RGBA | GL_COMPRESSED_RGBA_ASTC_4x4_KHR (0x93B0) | GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR (0x93D0) |
| cTFASTC_LDR_5x4_RGBA | GL_COMPRESSED_RGBA_ASTC_5x4_KHR (0x93B1) | ..._5x4_KHR (0x93D1) |
| cTFASTC_LDR_5x5_RGBA | GL_COMPRESSED_RGBA_ASTC_5x5_KHR (0x93B2) | ..._5x5_KHR (0x93D2) |
| cTFASTC_LDR_6x5_RGBA | GL_COMPRESSED_RGBA_ASTC_6x5_KHR (0x93B3) | ..._6x5_KHR (0x93D3) |
| cTFASTC_LDR_6x6_RGBA | GL_COMPRESSED_RGBA_ASTC_6x6_KHR (0x93B4) | ..._6x6_KHR (0x93D4) |
| cTFASTC_LDR_8x5_RGBA | GL_COMPRESSED_RGBA_ASTC_8x5_KHR (0x93B5) | ..._8x5_KHR (0x93D5) |
| cTFASTC_LDR_8x6_RGBA | GL_COMPRESSED_RGBA_ASTC_8x6_KHR (0x93B6) | ..._8x6_KHR (0x93D6) |
| cTFASTC_LDR_8x8_RGBA | GL_COMPRESSED_RGBA_ASTC_8x8_KHR (0x93B7) | ..._8x8_KHR (0x93D7) |
| cTFASTC_LDR_10x5_RGBA | GL_COMPRESSED_RGBA_ASTC_10x5_KHR (0x93B8) | ..._10x5_KHR (0x93D8) |
| cTFASTC_LDR_10x6_RGBA | GL_COMPRESSED_RGBA_ASTC_10x6_KHR (0x93B9) | ..._10x6_KHR (0x93D9) |
| cTFASTC_LDR_10x8_RGBA | GL_COMPRESSED_RGBA_ASTC_10x8_KHR (0x93BA) | ..._10x8_KHR (0x93DA) |
| cTFASTC_LDR_10x10_RGBA | GL_COMPRESSED_RGBA_ASTC_10x10_KHR (0x93BB) | ..._10x10_KHR (0x93DB) |
| cTFASTC_LDR_12x10_RGBA | GL_COMPRESSED_RGBA_ASTC_12x10_KHR (0x93BC) | ..._12x10_KHR (0x93DC) |
| cTFASTC_LDR_12x12_RGBA | GL_COMPRESSED_RGBA_ASTC_12x12_KHR (0x93BD) | ..._12x12_KHR (0x93DD) |
HDR formats are written with linear ASTC/BPTC enums (sRGB does not apply to HDR). Note the HDR ASTC rows use the same GL enum values as the LDR ASTC rows above — GL defines no separate ASTC HDR tokens; the HDR-ness is a property of the block data itself. Also note BC6H uses the unsigned BPTC float enum.
| transcoder_texture_format | GL internal format | GL base internal format |
|---|---|---|
| cTFBC6H | GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT (0x8E8F) | GL_RGB (0x1907) |
| cTFASTC_HDR_4x4_RGBA | GL_COMPRESSED_RGBA_ASTC_4x4_KHR (0x93B0) | GL_RGBA (0x1908) |
| cTFASTC_HDR_6x6_RGBA | GL_COMPRESSED_RGBA_ASTC_6x6_KHR (0x93B4) | GL_RGBA (0x1908) |
The following uncompressed / raster transcoder_texture_formats are not supported by the KTX1 writer and are skipped by the CLI's KTX output path. The CLI writes these as .PNG (LDR) or .EXR (HDR) raster images instead:
- LDR raster: cTFRGBA32, cTFRGB565, cTFBGR565, cTFRGBA4444
- HDR raster: cTFRGB_HALF, cTFRGBA_HALF, cTFRGB_9E5
(For reference, the natural GL internal-format enums for these would be GL_RGBA8 0x8058 / GL_RGB565 0x8D62 / GL_RGBA4 0x8056 / GL_RGB16F 0x881B / GL_RGBA16F 0x881A / GL_RGB9_E5 0x8C3D — but the encoder does not emit these to KTX1. cTFBGR565 has no distinct GL enum: GL defines no sized internal format for the byte-swapped B-in-high-bits 565 layout.)
Also note: cTFBC7_ALT (= 7) is a legacy alias of cTFBC7_RGBA and is not a distinct format.