dp3 - ps
Microsoft DirectX 9.0 SDK Update (October 2004)

dp3 - ps


Computes the three-component dot product of the source registers.

Syntax

dp3 dst, src0, src1

where

Remarks

Pixel shader versions1_11_21_31_42_02_x2_sw3_03_sw
dp3xxxxxxxxx

The following code snippet shows the operations performed:

dest.x = dest.y = dest.z = dest.w = 
  (src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z);

This instruction runs in the vector pipeline, always writing out to the color channels. For version 1_4, this instruction still uses the vector pipeline but may write to any channel.

An instruction with a destination register .rgb (.xyz) write mask may be co-issued with dp3 as shown below.

dp3 r0.rgb, t0, v0            // Copy scalar result to color components
+mov r2.a, t0                 // Copy alpha component from t0 in parallel 

The dp3 instruction can be modified using the Source Register Signed Scaling input argument modifier (_bx2) applied to its input arguments if they are not already expanded to signed dynamic range. For a lighting shader, the saturate instruction modifier (_sat) is often used to clamp the negative values to black, as shown in the following example.

dp3_sat r0, t0_bx2, v0_bx2    // t0 is a bump map, v0 contains the light direction


© 2004 Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center.