转载请注明出处为KlayGE游戏引擎,本文的永久链接为http://www.klayge.org/?p=1176

Direct3D 11 class hardware through the Direct3D 11 API supports two new texture compression formats: BC6H and BC7. These new Block Compressed formats provide excellent compression for High-Dynamic Range (HDR) images and higher-fidelity traditional content. The D3DX11 library includes a software implementation of the encoder, but the new BC formats are extremely asymmetric meaning the encoding algorithm has a very large search space to determine the optimal compression for each 4×4 block. This makes a great candidate for a GPGPU DirectCompute implementation of the compression algorithm. The BC6HBC7EncoderDecoder11 sample in the DirectX SDK provides such an implementation using DirectCompute 4.0.

Attached to this post is a ZIP containing an updated copy of the C++ source files and the two HLSL shaders for encoding which you can drop into the BC6HBC7EncoderDecoder11 sample code in the DirectX SDK (June 2010). This update enables support for HD Photo source images which makes a great source for HDR content (D3DX11 supports the HD Photo file format, but COM must be explicitly initialized for it to work properly), as well as a work-around for an HLSL compiler bug with the June 2010 release that affected encoding in some cases. There are also a few minor cleanups and a diagnostic message to highlight that the source image must have dimensions that are a multiple of 4 for the encoder to succeed (this is a requirement for all the BC formats).

For more information on BC6H and BC7 texture compression, see the Gamefest 2010 talk Block Compression Smorgasbord (US). Remember that DDS files containing BC6H and BC7 content are stored using the ‘DX10’ header extension, which is not widely supported by existing tools

BC7EncodeDecoder11.zip

[via]