texld

DirectX8

Microsoft Directx 8.1 (pixel shader version 1.4)

texld

Loads the destination register with color data (RGBA) sampled using the contents of the source register as texture coordinates. The sampled texture is the texture associated with the destination register number.

texld dest, src

Registers

Argument Description RegistersVersion
vn cn tn rn
dest Destination register x 1.4
src Source register x 1.4 phase 1
x x 1.4 phase 2

When using r(n) as a source register, the first three components (XYZ) must have been initialized in the previous phase of the shader.

To learn more about registers, see Registers.

Remarks

This instruction samples the texture in the texture stage associated with the destination register number. The texture is sampled using texture coordinate data from the source register.

The syntax for the texld and texcrd instructions expose support for a projective divide with a Texture Register Modifier. For pixel shader version 1.4, the D3DTTFF_PROJECTED texture transform flags is always ignored.

Rules for using texld:

  1. The same .xyz or .xyw modifier must be applied to every read of an individual t(n) register within both texcrd or texld instructions. If .xyw is being used on t(n) register read(s), this can be mixed with other read(s) of the same t(n) register using .xyw_dw.
  2. The _dz source modifier is only valid on texld with r(n) source register (thus phase 2 only).
  3. The _dz source modifier may be used no more than two times per shader.

Examples

The texld instruction offers some control over which components of the source texture coordinate data are used. The complete set of allowed syntax for texld follows, and includes all valid source register modifiers, selectors, and write mask combinations.

texld  r(m), t(n).xyz
// Uses xyz from t(n) to sample 1-D, 2-D, or 3-D texture.

texld  r(m), t(n)
// Same as previous.

texld  r(m), t(n).xyw
// Uses xyw (skipping z) from t(n) to sample 1-D, 2-D or 3-D texture.
 
texld  r(m), t(n)_dw.xyw  
// Samples 1-D or 2-D texture at x/w, y/w from t(n). The result
// is undefined for a cube-map lookup.

texld  r(m), r(n).xyz
// Samples 1-D, 2-D, or 3-D texture at xyz from r(m). 
// This is possible in the second phase of the shader.

texld  r(m), r(n)
// Same as previous.

texld  r(m), r(n)_dz.xyz
// Samples 1-D or 2-D texture at x/z, y/z from r(m). 
// Possible only in second phase.
// The result is undefined for a cube-map lookup.

texld  r(n), r(n)_dz
// Same as previous.