?/TD>
Microsoft DirectX 9.0

Pixel Shader Texture Addressing


Texture addressing is the mechanism by which texture coordinates are either retrieved directly or used to sample data from a texture.

Texture coordinates can be supplied as part of the vertex format or can be read from certain kinds of texture maps. Texture coordinates are sometimes referred to as TCs. A 2-D texture map is addressed, or looked up, using (UV) coordinates. A 3-D texture map (cube map or volume map) is addressed using (UVW) texture coordinates. Alternately, texture coordinates can be used directly, with no lookup.

Sampling occurs when a texture coordinate is used to address the texel data at a particular location. This is also commonly referred to as performing a texture lookup. In order to sample a texture, it must first be associated with a texture stage. The actual data sampled at the texture coordinate address is controlled by four things.

  1. The pixel shader texture addressing instruction.
  2. The texture coordinates.
  3. The texture set at a texture stage.
  4. The texture sampling attributes set in the texture stage states.

The following diagram shows ways that texture coordinates are used for texture addressing.

Pixel shader texture addressing diagram

For pixel shader version 1_1 to 1_3, texture coordinates are used in three ways:

For pixel shader version 1_4, the texture registers (t#) have a different meaning than previous pixel shader versions. They contain texture coordinates so they should be thought of as texture coordinate registers. These texture coordinate registers are read only (used as source parameters for texture addressing instructions) and are not available to arithmetic instructions.

Having texture coordinates in their own register means that the texture coordinate set and the texture stage number can be different in pixel shader version 1_4 texture addressing instructions. The texture stage number from which to sample is determined by the destination register number, but the texture coordinate set is determined by the new source (t#) register specified.

The "Modify TCs" box in the previous diagram does not apply to pixel shader version 1_4 because modification of texture coordinates before texture sampling is accomplished using standard arithmetic instructions, followed by a dependent read. Dependent reads are described in the following diagram and text.

Pixel shader dependent read diagram

Often, it is useful to perform some operation on texture coordinates before using them to sample a texture. This is referred to as a dependent read. The term "dependent" indicates that the texture data that gets sampled depends on some result computed in the pixel shader.

For pixel shader version 1_1 to 1_3, dependent reads are limited to a texture addressing instruction using the result of a previous texture addressing instruction as a source parameter. For pixel shader version 1_4, the dependent reads are much more flexible in that the texture coordinates for a texture sample may be derived from the result of previous texture addressing instructions and/or arbitrary pixel shader arithmetic instructions. Dependent reads in pixel shader version 1_4 always involve an (r#) registers being used as the texture coordinates for a texture address instruction. This means that the dependent read only occurs in phase 2. For more information about ordering arithmetic and texture addressing instructions within a shader, see Instruction Flow.



© 2002 Microsoft Corporation. All rights reserved.