Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1)

m3x2

Computes the product of the input vector and a 3x2 matrix.

m3x2 dest, src0, src1

Registers

dest
Destination register.
src0
Input source register.
src1
Input source register.

To learn more about registers, see Registers.

Remarks

// m3x2 operates as shown by the following equations
dest.x = (src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z);
dest.y = (src0.x * src2.x) + (src0.y * src2.y) + (src0.z * src2.z);

The input vector is in register src0, the input 3x2 matrix is in register src1 (and the next higher register in the same register file--as shown in the expansion below). A 2-D result is produced, leaving the other elements of the destination register (dest.z and dest.w) unaffected.

This operation is commonly used for 2-D transforms. This macro instruction is implemented as a pair of dot products as shown below.

m3x2   r5, v0, c3

which is performed as two dot products:
dp3   r5.x, v0, c3
dp3   r5.y, v0, c4

The swizzle and negate modifiers are not allowed on this instruction.

Example

// This example scales the object in both the x and y direction.

// shader file
vs.1.0
mov r0, v0	    	; load vertex position
m3x2 r1, r0, c5		; scale in x and y
m4x4 oPos, r1, c0	; transform vertices by view/projection matrix

mov oD0, c4		; output constant color

// The resultant green object is half the width and 1/4 the height 
// and is shown below.
// Additional code is used to initialize the constant registers.

D3DXMATRIX mat, matView, matProj;
D3DXMatrixMultiply(&mat, &matView, &matProj);
D3DXMatrixTranspose(&mat, &mat);
// set C0 with the view and projection matrix
m_pd3dDevice->SetVertexShaderConstant(0, &mat, 4);

// set register c4
float colorGreen[4] = {0, 1, 0, 0};
m_pd3dDevice->SetVertexShaderConstant(4, &colorGreen, 1);

// set register c5 (also sets registers c6 and c7)
float scale[][4] = {{0.5f, 0, 0, 0}, {0, 0.25f, 0, 0}, {0, 0, 1, 0}};
m_pd3dDevice->SetVertexShaderConstant(5, &scale, 3);

// The first SetVertexShaderConstant method binds the c0 register 
// with the first row of the view/projection matrix (rows 2, 3, 4 are 
// bound to registers C2, C3, c4 also). The m4x4 instruction (in the 
// shader file) loads the data.
// The second SetVertexShaderConstant method binds the c4 register with 
// the data for the color green. The last SetVertexShaderConstant method 
// binds the c5 register with the first row of the scale matrix (rows 2 and 3 
// are bound to registers C6 and C7 also). The m3x3 instruction (in the shader 
// file) loads the data.