This documentation is archived and is not being maintained.

Content Compression

XNA Game Studio offers data compression—an easy way to decrease the size of certain built game assets such as textures, shaders, and meshes. Data compression reduces not only the size required for media storage and downloads, but also the deploy time required for debugging a game.

Transparent Compression

Compression and decompression of game assets is a transparent operation. You do not need to modify your game to use compressed data.

  • Compression occurs in the build as part of the Content Pipeline processes. It is performed automatically when you select the property in the Content Build page of the Project Designer.
  • Decompression occurs automatically when you access the assets through ContentManager.Load.

Compression Algorithm

The compression used by XNA Game Studio is a variant of the LZ family of compression algorithms, which is an efficient, lossless method. The ratio of compressed data to source data can vary significantly depending on the character of the source data. For most game asset types, the average compression ratio is about 60 percent.

The automatic compression algorithms do not compress source data that is small in size—less than one disk sector. Performance benefits of data compression typically are lost, or even made worse, by the execution overhead required for decompression. Assets are saved in an uncompressed format.

Disabling Compression

Some content types, such as Song Class and SoundEffect Class data, may not benefit from a general lossless compression algorithm. This is especially true if data is already compressed in a specialized format.

When implementing a custom content importer, compression can be disabled by overriding the method ContentTypeWriter.ShouldCompressContent, which must return false. If compression is permitted, no action is required. The base class definition of ContentTypeWriter.ShouldCompressContent returns true.