What is the Content Pipeline?

The XNA Game Studio Content Pipeline is a set of processes applied when a game that includes art assets is built. The process starts with an art asset in its original form as a file, and continues to its transformation as data that can be retrieved and used within an XNA Game Studio game through the XNA Framework Class Library.

The Content Pipeline is designed to be extensible, so that it can easily support new input file formats and new types of conversion.

Most XNA Game Studio developers can ignore the inner workings of the Content Pipeline. The most commonly used types of game assets and formats are inherently supported by XNA Game Studio. However, if you are a game developer who needs to support a new file format or game-engine capability, it is useful to understand the stages of the Content Pipeline that transform an asset from a digital-content creation (DCC) output file to part of the game binary.

Content Pipeline Components

A game asset is made available to an XNA Game Studio game after it is added to the Content project. Once the asset is part of the game solution, it is included in the Content Pipeline.

Here are the Content Pipeline processes.

Bb447745.ContentPipeline_Diagram(en-us,XNAGameStudio.41).jpg

Processes fall into two types depending on when they execute: design time components and runtime components.

Here is a summary of how the two components differ:

Activity Design time Runtime
Executes on Development computer Game device
Runs under Visual Studio (on Windows) Windows, Xbox 360, or Windows Phone
Uses framework Content Pipeline Class Library XNA library (redistributable)
Distributed with game? No Yes

Design-Time Components

The design-time components of the XNA Game Studio Content Pipeline that process your game assets execute within Visual Studio when you build your XNA Game Studio game as an executable file. These processes perform the initial transformation of an asset from its digital content creation (DCC) format to a managed code object that your game can use upon execution.

Design-time components use the Content Pipeline Class Library, which can be used and extended to create custom Content Pipeline design-time components.

Importer

An importer converts game assets from a particular DCC file format into objects in the XNA Game Studio Content Document Object Model (DOM) that standard content processors can consume, or into some other custom form that a particular custom processor can consume.

An importer typically converts content into managed objects based on the Content DOM, which includes strong typing for such assets as meshes, vertices, and materials. A custom importer, however, may produce custom objects for a particular custom content processor to consume.

Content processor

A processor takes one specific type of an imported game asset and compiles it into a managed code object that can be loaded and used by XNA Game Studio games on Windows, Xbox 360, or Windows Phone.

Each content processor acts upon a specific object type. For example, the Effect Processor accepts only EffectContent objects, representing a DirectX Effect asset.

When you include a game asset file in your XNA Game Studio solution's content project, its using dialog properties page specifies the appropriate importer and processor. Thereafter, when you build your game (by pressing F5), the assigned importer and processor for each asset is invoked automatically. The asset is built into your game in a form that can be loaded at run time by your game.

The managed code objects created by the content processor are serialized into a compact binary format (also referred to as an intermediate format) file with an .XNB extension by the Content Pipeline content compiler. This .XNB file is used by the runtime components of the Content Pipeline that assist your game in retrieving the transformed game assets.

The format of data in the .XNB file is tightly coupled to the XNA Framework. It is not designed for use by other runtime libraries.

Runtime Components

Runtime components of the Content Pipeline support loading and using the transformed game asset by your XNA Game Studio game. These components use the XNA library, which can be extended to create custom components.

Content Loader When the game needs the game asset's managed code object, it must call the ContentManager.Load method to invoke the content loader, specifying the object type it expects. The content loader then locates and loads the asset from the compact binary format (.XNB) file into the memory space of the game where it can be used.

See Also

Adding New Content Types
What Is Content?
Loading Additional Content Types