dp4

DirectX8

Microsoft DirectX 8.1 (pixel shader versions 1.2, 1.3, 1.4)

dp4

Calculates a four-component dot product. The scalar result is replicated to all channels.

dp4 dest, src0, src1

Registers

Argument Description RegistersVersion
vn cn tn rn
dest Destination register x 1.2, 1.3
x 1.4
src0, src1 Source register x x x x 1.2, 1.3
x x 1.4 phase 1
x x x 1.4 phase 2

This instruction cannot be co-issued.

This instruction does not automatically clamp the output result between zero and one. If clamping is necessary, use the saturate modifier.

To learn more about registers, see Registers.

Remarks

This instruction executes in both the vector and alpha pipeline.

dp4 r0, t0, v0      // Copy scalar result to RGBA components.

For pixel shader version 1.2 and 1.3, dp4 counts as two arithmetic instructions. Unfortunately, this was discovered too late in the development cycle and therefore is not validated properly when calling CreatePixelShader. It is being incorrectly counted as consuming only one arithmetic instruction. Be sure to manually count this instruction as two arithmetic instructions toward the maximum instruction count. For more information about instruction counts, see Counting Instructions.

In addition, for pixel shader version 1.2 and 1.3, the destination register for dp4 cannot be the same as any of the source registers. Validation does not catch this, so be sure to keep this in mind.