Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

Source Register Swizzling

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

Source Swizzling

Source swizzle allows individual component of a source register to take on the value of any of the four components of the same source register before the register is read for computation.

For example, the .zxxy swizzle means:

  • .x component will take on the value of .z component
  • .y component will take on the value of .x component
  • .z component will take on the value of .x component
  • .w component will take on the value of .y component

The components can appear in any order. If fewer than four components are specified, the last component is repeated. For example:



.xy  = .xyyy
.wzx = .wzxx
.z   = .zzzz


If no component is specified, no swizzling is applied.

Some instructions have restrictions for source swizzle. They are listed in the respected instruction reference pages.

Pixel shader versions1_11_21_31_42_02_x2_sw3_03_sw
.xxxxxxx
.yxxxxxx
.zx*x*x*xxxxxx
.wxxxxxxxxx
.xyzw (default)xxxxxxxxx
.yzxwxxxxx
.zxywxxxxx
.wzyxxxxxx
arbitrary swizzlexxxx

 

* Only available if destination write mask is .w (.a).

Arbitrary Swizzle

Swizzles can be applied to source registers in an arbitrary order; that is, any source register can take any component mask, in any order.

Replicate Swizzle

Replicate swizzle copies one component to another. This is, exactly one of the .x, .y, .z, .w swizzle components (or the .r, .g, .b, .a equivalents) must be specified.

Related topics

ps_1_1__ps_1_2__ps_1_3__ps_1_4 Registers
ps_2_0 Registers
ps_2_x Registers
ps_3_0 Registers

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.