DDS File Layout for Volume Textures

A volume texture is an extension of the standard texture for Direct3D 9, and can be defined with or without mipmaps. If a file contains a volume texture, DDSCAPS_COMPLEX, DDSCAPS2_VOLUME, DDSD_DEPTH, and dwDepth should be set. For volumes without mipmaps, each depth slice is written to the file in order. If mipmaps are included, all depth slices for a given mipmap level are written together, with each level containing half as many slices as the previous level with a minimum of 1. Volume textures do not support DXTn compression as of Direct3D 9.

For example, a 64-by-64-by-4 volume map, a pixel format of R8G8B8 (3 bytes per pixel), and all mipmap levels would contain the following:

Texture Size/Type # Bytes
"DDS ", 64x64x4, pitch=768, pixel format=R8G8B8, bitcount=24, mipmapcount=7, (DEPTH, TEXTURE, PITCH, COMPLEX, MIPMAP, VOLUME, RGB) 128 bytes
64-by-64 slice 1 of 4 main image. 12288 bytes
64-by-64 slice 2 of 4 main image. 12288 bytes
64-by-64 slice 3 of 4 main image. 12288 bytes
64-by-64 slice 4 of 4 main image. 12288 bytes
32-by-32 slice 1 of 2 mipmap image. 3072 bytes
32-by-32 slice 2 of 2 mipmap image. 3072 bytes
16-by-16 slice 1 of 1 mipmap image. 768 bytes
8-by-8 slice 1 of 1 mipmap image. 192 bytes
4-by-4 slice 1 of 1 mipmap image. 48 bytes
2-by-2 slice 1 of 1 mipmap image. 12 bytes
1-by-1 slice 1 of 1 mipmap image. 4 bytes