texldb - ps

Biased texture load instruction. This instruction uses the fourth element (.a or .w) to bias the texture-sampling level-of-detail just before sampling.


texldb dst, src0, src1



For the restrictions when using texldb, see the texld - ps_2_0 and up instruction.

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, 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 src1, and when applied, the texture lookup results are pre-swizzled before written to dst.


Pixel shader versions1_11_21_31_42_02_x2_sw3_03_sw


texldb biases the mipmap level-of-detail, computed normally as part of the sample process by the (signed) value in src0.w. Positive bias values will result in smaller mipmaps being selected and vice versa. For ps_2_0 and ps_2_x, bias values can be within the range [-3.0, +3.0]. For ps_3_0, bias values can be within the range [-16.0, +15.0]. Bias values outside these ranges produce undefined results. The sampler state D3DSAMP_MIPMAPLODBIAS is still honored, and the texldb bias is added to this, but on a per-pixel basis. After the biased level-of-detail is computed, D3DSAMP_MAXMIPLEVEL is still honored and the texture sample occurs. After texldb, the contents of src0 are unaffected (unless dst is the same register).

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 .xyw coordinates; if src1 is declared as either a cube sampler or a volume sampler, then src0 must contain .xyzw coordinates. Sampling a 2D texture with .xyzw coordinates is allowed (the .z coordinate is 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 FormatDefault Values
D3DFMT_V8U8, D3DFMT_V16U16, D3DFMT_G16R16, D3DFMT_G16R16F, D3DFMT_G32R32FB = A = 1.0
D3DFMT_A8R = G = B = 0.0
D3DFMT_R16F, D3DFMT_R32FG = B = A = 1.0
All depth/stencil formatsR = B = 0.0, A = 1.0


Related topics

Pixel Shader Instructions