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.

Syntax

texldb dst, src0, src1

Where:

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 (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.

ps_3_0

src1 must be a Sampler (s#), with no modifier. Swizzle is allowed on src1, and when applied, the texture lookup results are pre-swizzled before written to dst.

Remarks

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

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 - ps. 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 Format Default Values
D3DFMT_R5G6B5, D3DFMT_R8G8B8, D3DFMT_L8, D3DFMT_L16, D3DFMT_R3G3B2, D3DFMT_CxV8U8, D3DFMT_L6V5U5 A = 1.0
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