XMVectorPermute

Permutes the components of two vectors to create a new vector.

Syntax

XMVECTOR XMVectorPermute(
         XMVECTOR V1,
         XMVECTOR V2,
         XMVECTOR Control
)

Parameters

  • V1
    [in] First vector.
  • V2
    [in] Second vector.
  • Control
    [in] Vector describing how to permute and recombine V1 and V2. This vector is typically created using XMVectorPermuteControl.

Return Value

Returns the permuted vector that resulted from combining the source vectors.

Remarks

If you visualize V1 and V2 as though they are arranged linearly, forming an array of 32 bytes, the components of Control are indices into that array that select which components to select for the resulting vector. For every byte in Control, the low 5 bits specify which byte to read from the 32-byte array formed by V1 and V2, this is then assigned to the output vector.

Manual construction of a control vector is not necessary. There are two simple ways of constructing an appropriate control vector:

  1. Using the XMVectorPermuteControl function to construct a control vector.

    See Using XMVectorPermute and XMVectorPermuteControl for a demonstration of how this function can be used.

  2. The control vector can be constructed using the XM_PERMUTE_[0,1][,X,Y,Z,W] constant (see DirectXMath Library Constants). As an example, in pseudo-code, an instance of Control with the elements:

       Control = { XM_PERMUTE_0Z,   XM_PERMUTE_1X,   XM_PERMUTE_0W,   XM_PERMUTE_1Y }

    would return a vector Result with the following components of V1 and V2

       Result = { V1.Z,  V2.X,   V1.W,   V2.Y }

Requirements

Header: Declared in DirectXMath.h.

Namespace: Use DirectX.

See Also

XMVectorPermuteControl
XMVectorSwizzle