Upravit

Sdílet prostřednictvím


texldp - ps

Projected texture load instruction. This instruction divides the input texture coordinate by the fourth element (.a or .w) just before sampling.

Syntax

texldp dst, src0, src1

 

where

For the set of restrictions when using texldp, see texld.

Remarks

texldp performs projection on the coordinates read from src0 before performing the sample. Each texture coordinate is divided by src0.w, then the texture is sampled. When texldp completes, the contents of src0 are unaffected (unless dst is the same register). An alternative to using texldp is to manually perform the projection division in the shader. However, performing the division in shader code is usually slower than when performed by the texldp instruction, so avoid such additional math when possible.

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 Format Default Values for missing components
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

 

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
texldp x x x x x

 

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.

ps_3_0

For ps_3_0, 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 Instructions