Multiple-element Textures

Traditional textures are considered to be single-element textures. Multiple-element textures enable applications to write simultaneously to multiple elements of a texture from the pixel shader. The result in the next rendering pass is that an application can use one or more of the elements as a single-element texture - that is, as inputs to the pixel shader. These additional elements can be thought of as a temporary store for intermediate results that will be used in a later pass by the application.

The first generation of hardware that exposes this feature has the following restrictions:

The usage of multiple-element textures follows these steps:

  1. Applications discover support for this feature by checking for the availability of multiple-element texture formats.
  2. The application creates these surfaces by calling IDirect3DDevice9::CreateTexture.
  3. The application sets the surface as a render target using the IDirect3DDevice9::SetRenderTarget call. The pixel shader provides output to the surfaces using the mov - ps instruction.
  4. IDirect3DDevice9::SetTexture is called to set a multiple-element texture surface to a particular stage. As with other textures, the same surface is allowed to be set to multiple stages at once.
  5. IDirect3DDevice9::SetSamplerState is called to set D3DSAMP_ELEMENTINDEX to the appropriate element number in the multiple-element texture from which the sampler samples. Default value for this state is 0, which means non-multiple-element textures will work. Setting this state to an inappropriate number results in an undefined behavior - if the multiple-element texture is only two elements wide but the sampler is asked to sample from the fourth element, for example.

API Support

The following is a summary of the API elements that support multiple-element textures: