Source Register Swizzling (HLSL VS reference)

Before an instruction runs, the data in a source register is copied to a temporary register. Swizzling refers to the ability to copy any source register component to any temporary register component. Swizzling does not affect the source register data.

Component Swizzling

As shown in the following table, swizzling can be applied to the individual components of the source register data (where r is one of the valid vertex shader input Registers - vs_1_1).

Component modifier Description
r.[xyzw][xyzw][xyzw][xyzw] Source swizzle

 

  • All four components are always copied. If fewer than four components are specified, the last component is repeated (xy means .xyyy). If no components are specified, x is repeated (.xxxx).
  • The components can appear in any order. v0.ywx results in v0.ywxx.
  • The rgba components can be used respectively for xyzw (r for x, g for b, etc.).
  • These instructions implement source-register single component swizzles: exp, expp, log, logp, pow, rcp, rsq. The result of these instructions is copied to all four destination register components.

Swizzling cannot be used on the m3x2 - vs, m3x3 - vs, m4x3 - vs, and m4x4 - vs instructions.

Vertex Shader Register Modifiers