?/TD>
Microsoft DirectX 9.0

Source Register Selectors


This modifier replicates a single channel of a source-register argument to all channels.

Syntax

source register.channel

ChannelSyntaxVersion
1_1 1_2 1_3 1_4
Red replicate source register.r X
Green replicate source register.g X
Blue replicate source register.b X X X X
Alpha replicate source register.a X X X X

Register

Source register. For more about register types, see Registers - ps_1_X.

In version 1_1, 1_2, and 1_3, blue replicate is available only on the source register of arithmetic instruction, which uses alpha Register Write Masks.

Remarks

Source register selectors are applied before any Register Modifiers and before the instruction runs.

Copying the contents of a channel into one or more other channels is commonly referred to as "swizzling."

These selectors are valid on source registers for arithmetic instructions. The four selectors operate on different channels.

An alternate syntax for the r,g,b,a channels is x,y,z,w.

Source selectors and source modifiers may be combined freely. In this example, register r0 uses the invert, bias, and signed scaling modifier, as well as the green selector. The contents of the source register are unaffected; the modifier modifies only the data read.

-r0_bx2.g

To understand the order of the execution of these modifiers and selectors, see Order of Operations.

This operator can be used in conjunction with the Invert or Negate operators.

Alpha replicate functionality is analogous to the D3DTA_ALPHAREPLICATE flag in the Microsoft?DirectX?6.0 and 7.0 multitexture syntax.

These examples illustrate each of the four selectors.

// Replicate the red color channel to the all channels before
// doing the multiply.
mul r0, r0, r1.r    // the result is r1.rgba = r1.r
					
// Replicate the green color channel to the all channels before
// doing the multiply.
mul r0, r0, r1.g    // the result is r1.rgba = r1.g

// Replicate the blue color channel to the all channels before
// doing the multiply.
mul r0, r0, r1.b    // the result is r1.rgba = r1.b
					
// For ps 1_1, 1_2, 1_3, the blue replicate example 
// would require a destination write mask.					
mul r0.a, r0, r1.b					

// alpha replicate
mul r0, r0, r1.a    ; Replicate the alpha color channel to all channels.

alpha write mask

The alpha write mask is also referred to as the scalar write mask, because it uses the scalar pipeline.

add r0.a, t1, v1

So this instruction effectively puts the sum of the alpha component of t1 and the alpha component of v1 into r0.a.

color write mask.

The color write mask is used to control writing to the color channels.

// The color write mask is also referred to as the vector write mask, 
// because it uses the vector pipeline.
mul r0.rgb, t0, v0


© 2002 Microsoft Corporation. All rights reserved.