Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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 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:
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 versions | 1_1 | 1_2 | 1_3 | 1_4 | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
---|---|---|---|---|---|---|---|---|---|
.x | x | x | x | x | x | x | |||
.y | x | x | x | x | x | x | |||
.z | x* | x* | x* | x | x | x | x | x | x |
.w | x | x | x | x | x | x | x | x | x |
.xyzw (default) | x | x | x | x | x | x | x | x | x |
.yzxw | x | x | x | x | x | ||||
.zxyw | x | x | x | x | x | ||||
.wzyx | x | x | x | x | x | ||||
arbitrary swizzle | x | x | x | x |
* Only available if destination write mask is .w (.a).
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 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.
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today