24/09/2010 Texture compression formats: lost in translation

I spend my time to say it: "It's all about bandwidth!" A renderer can't be efficient without taking good care of the bandwidth and probably the first step is to use compressed textures.

Direct3D and OpenGL provide a lot of texture formats to make the best use of the bandwidth. However, it’s a bit difficult to follow what format name correspond to what kind of data. Direct3D 9 and Direct3D 10 use different and OpenGL is based on an inconsistent naming convention following more or less Direct3D conventions but not really.

All the GPU compressed texture formats work on 4 by 4 pixel blocks and are saved in memory as fixed size compressed blocks which make possible to arbitrary access any block of a texture. Each block has to be fetch as 1 continue memory block but each pixel can be decoded on fly. Because of the proximity of block pixels, each block makes the best usage of the GPU caches. These basic characteristics make compressed texture very convenient to implement on the hardware and they are in practice faster than uncompressed textures.

First note: I don't really know how BC7 and BC6H format work but this is something I will explore later on. It's quite a shame than Direct3D 11 documentation doesn't describe them properly. As far as I have understood, these formats use block shape patterns to decode the block instead of interpolated values to reduce the block artefacts. BC7 is 8 bits like BC3… what are the use cases for BC7 over BC3?

On the regard of BC1 to BC5, every formats use 2 pixels that are interpolated to generate each pixel of the block. These 2 pixels are saved as 16 bits colors (R5G6B5) and the number of interpolated values can change depending on the order of the 2 pixels in the block. Typically, if pixel 0 is bigger than pixel 1 then we use the set of interpolation values with more interpolation values.

In the following table, the compressed formats for OpenGL textures and the equivalent format for different versions of Direct3D.

DescriptionOpenGLDirect3D 9Direct3D 10Direct3D 11
4 bpp, RGB, 2 interpolanted value or 1 interpolated value + alpha bitRGB_S3TC_DXT1_EXT, RGBA_S3TC_DXT1_EXT, SRGB_S3TC_DXT1_EXT, SRGB_ALPHA_S3TC_DXT1_EXTD3DFMT_DXT1BC1_UNORM, BC1_UNORM_SRGBBC1_UNORM, BC1_UNORM_SRGB
8 bpp, RGBA, 16 stored alpha valuesRGBA_S3TC_DXT3_EXT, SRGB_ALPHA_S3TC_DXT1_EXTD3DFMT_DXT2, D3DFMT_DXT3BC2_UNORM, BC2_UNORM_SRGBBC2_UNORM, BC2_UNORM_SRGB
8 bpp, RGBA, 4 or 6 interpolated alphaRGBA_S3TC_DXT5_EXT, SRGB_ALPHA_S3TC_DXT5_EXTD3DFMT_DXT4, D3DFMT_DXT5BC3_UNORM, BC3_UNORM_SRGBBC3_UNORM, BC3_UNORM_SRGB
4 bpp, Red only, single component imagesRED_RGTC1, SIGNED_RED_RGTC1N/ABC4_SNORM, BC4_UNORMBC4_SNORM, BC4_UNORM
8 bpp, Red and green, normal imagesRG_RGTC2, SIGNED_RG_RGTC2N/ABC5_SNORM, BC5_UNORMBC5_SNORM, BC5_UNORM
8 bpp, HDR RGB imagesRGB_BPTC_SIGNED_FLOAT_ARB, RGB_BPTC_UNSIGNED_FLOAT_ARBN/AN/ABC6H_SF16, BC6H_UF16
8 bpp, suposed to be "high quality"RGBA_BPTC_UNORM_ARB, SRGB_ALPHA_BPTC_UNORM_ARBN/AN/ABC7_UNORM, BC7_UNORM_SRGB

On the side of tools, BC6H and BC7 formats are still pretty unsupported. GLI still only support Direct3D 9 DDS files and formats. Obviously, the support for all the formats are really high in my development list for GLI! My favorite texture tool, AMD The Compressonator, haven't been updated and neither the nVidia Texture Tools. The only thing I found to generate BC6H and BC7 is a code sample in the Direct3D SDK and 2 independant exporters in the nVidia Texture Tools repository for BC6H and BC7

  • GL_EXT_texture_compression_s3tc
  • GL_ARB_texture_compression_rgtc
  • GL_ARB_texture_compression_bptc
  • GL_ARB_texture_compression
  • GL_EXR_texture_sRGB
  • Git FAQ >
    < OpenGL Samples Pack 4.1.1.3 released (updated)
    Copyright © Christophe Riccio 2002-2016 all rights reserved
    Designed for Chrome 9, Firefox 4, Opera 11 and Safari 5