Export (0) Print
Expand All

DDS Texture Example

For an uncompressed texture, use the DDSD_PITCH and DDPF_RGB flags; for a compressed texture, use the DDSD_LINEARSIZE and DDPF_FOURCC flags. For a mipmapped texture, use the DDSD_MIPMAPCOUNT, DDSCAPS_MIPMAP, and DDSCAPS_COMPLEX flags also as well as the mipmap count member. If mipmaps are generated, all levels down to 1-by-1 are usually written.

For a compressed texture, the size of each mipmap level image is typically one-fourth the size of the previous, with a minimum of 8 (DXT1) or 16 (DXT2-5) bytes (for square textures). Use the following formula to calculate the size of each level for a non-square texture:



max(1, ( (width + 3) / 4 ) ) x max(1, ( (height + 3) / 4 ) ) x 8(DXT1) or 16(DXT2-5)


This table lists the amount of space taken up by each layer for a 256-by-256 R8G8B8 texture, without using compression.

DDS Components# Bytes
header128
256-by-256 main image196608
128-by-128 mipmap image49152
64-by-64 mipmap image12288
32-by-32 mipmap image3072
16-by-16 mipmap image768
8-by-8 mipmap image192
4-by-4 mipmap image48
2-by-2 mipmap image12
1-by-1 mipmap image3

 

This table lists the amount of space taken up by each layer for the same texture using compression (DXT1).

DDS Components# Bytes
header128
256-by-64 main image8192
128-by-32 mipmap image2048
64-by-16 mipmap image512
32-by-8 mipmap image128
16-by-4 mipmap image32
8-by-2 mipmap image16
4-by-1 mipmap image8
2-by-1 mipmap image8
1-by-1 mipmap image8

 

This table lists the amount of space taken up by each layer for the same texture using a DXGI compression format (in this case BC3_UNORM) that therefore requires the extended header:

DDS Components# Bytes
header (FourCC set to "DX10")128
extended header (DXGI format set to DXGI_FORMAT_BC3_UNORM)20
256-by-64 main image16384
128-by-32 mipmap image4096
64-by-16 mipmap image1024
32-by-8 mipmap image256
16-by-4 mipmap image64
8-by-2 mipmap image32
4-by-1 mipmap image16
2-by-1 mipmap image16
1-by-1 mipmap image16

 

Related topics

Programming Guide for DDS

 

 

Community Additions

ADD
Show:
© 2014 Microsoft