EffectPool Class

Allows applications to share resources between effects.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public class EffectPool : IDisposable

Effect pools allow different effects to share variables, textures, and shaders between them. This means that for common variables, the data needs to be set only once per frame, rather than once per effect invocation. An effect pool effectively consists of two parts. There is the effect pool itself, and the effects that are part of the pool.

A good example of sharing variables would be the projection matrix of the view. In many cases, the projection matrix is constant over an entire frame. However, every effect used in the frame needs that matrix at some point. If there are several hundred effects running per scene, you would have to set that matrix for each effect. However, by using effect pools, you set the projection matrix once, and that value is automatically used by every effect in the pool when needed.


The content manager uses a static EffectPool when loading all effects. This supports the usage of shared parameters across all effects loaded by the content manager.

For each effect pool, parameters with the same name, type, and semantic are automatically shared across all effects in that pool. An easy way to implement this is an include file that declares each effect variable to be shared and then include that variable file in each effect file needing those variables.

For an example of effect pools, see Shader Series 1: Vertex Lighting, located at http://creators.xna.com.

Xbox 360, Windows XP SP2, Windows Vista

Community Additions