Export (0) Print
Expand All

Content Compression

XNA Game Studio offers data compression - an easy way to decrease the size of certainly built game assets (e.g. textures, shaders, and meshes). This is convenient for media storage and downloads and reduces the time required to deploy a game when debugging.

Transparent Compression

Compression and decompression of game assets is a transparent operation to games. You don't need to modify your game to make use of compressed data.

  • Compression occurs as part of the content pipeline portion of the build process. 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.
Dd231952.note(en-US,XNAGameStudio.30).gifNote

Compression of game assets is not available for Zune projects. Microsoft has concluded that the small benefit gained by compressing data for Zune is exceeded by the performance requirements of the Zune processor for decompression.

Compression Algorithm

The compression used by XNA Game Studio uses 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. However, the average compression ratio for most game asset types is around 60 percent.

The automatic compression algorithms will not compress source data that is very small (a file size less than one disk sector), as the performance benefits of compression are typically lost or even made worse by the execution overhead to decompress the data. These assets will be saved in 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 the 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 to be permitted, no action is required. The base class definition of ContentTypeWriter.ShouldCompressContent returns true.

Community Additions

ADD
Show:
© 2014 Microsoft