texld - ps_2_0 and up

Sample a texture at a particular sampler, using provided texture coordinates. This instruction is different from the texld - ps_1_4 instruction used in pixel shader version 1_4.


texld dst, src0, src1



  • dst is a destination register.
  • src0 is a source register that provides the texture coordinates for the texture sample.
  • src1 identifies the Sampler (Direct3D 9 asm-ps) (s#), where # specifies which texture sampler number to sample. The sampler has associated with it a texture and a sampler state defined by D3DSAMPLERSTATETYPE.

ps_2_0 and ps_2_x

dst must be a Temporary Register (r#) and only .xyzw mask (default mask) is allowed.

src0 must be either a Texture Coordinate Register (t#) or a Temporary Register (r#), with no modifier or swizzle.

src1 must be a Sampler (Direct3D 9 asm-ps) (s#), with no modifier or swizzle.

If the D3DD3DPSHADERCAPS2_0_NODEPENDENTREADLIMIT cap bit is not set (in D3DPSHADERCAPS2_0), a given texture instruction (texld, texldp, texldb - ps, texldd ) may be dependent upon, at most, third order. A first-order dependent texture instruction is a texture instruction in which either:

A second-order dependent texture instruction is defined as a texture instruction that reads or writes to a Temporary Register (r#) whose contents, before executing the texture instruction, depend (perhaps indirectly) on the outcome of a first-order dependent texture instruction. An (n)th-order dependent texture instruction derives from an (n - 1)th-order texture instruction.


src1 must be a Sampler (Direct3D 9 asm-ps) (s#), with no modifier. Swizzle is allowed on src0 or src1. The swizzle is applied to the texture coordintates before texture lookup.


This instruction is supported in the following versions:

Pixel shader versions 1_1 1_2 1_3 1_4 2_0 2_x 2_sw 3_0 3_sw
texld x x x x x


The number of coordinates required for src0 to perform the texture sample depends on how src1 was declared, plus the .w component. Sampler types are declared with dcl_samplerType (sm2, sm3 - ps asm). If src1 is declared as a 2D sampler, then src0 must contain .xy coordinates; if src1 is declared as either a cube sampler or a volume sampler, then src0 must contain .xyz coordinates. Sampling a texture with fewer dimensions than are present in the texture coordinate is allowed since the extra texture coordinate component(s) are ignored.

If the source texture contains fewer than four components, defaults are placed in the missing components. Defaults depend on the texture format as shown in the following table:

Texture Format Default Values
D3DFMT_V8U8, D3DFMT_V16U16, D3DFMT_G16R16, D3DFMT_G16R16F, D3DFMT_G32R32F B = A = 1.0
D3DFMT_A8 R = G = B = 0.0
D3DFMT_R16F, D3DFMT_R32F G = B = A = 1.0
All depth/stencil formats R = B = 0.0, A = 1.0


Pixel Shader Instructions