Export (0) Print
Expand All

Modifiers for ps_1_X

Instruction modifiers affect the result of the instruction before it is written into the destination register. For instance, use them to multiply or divide the result by a factor of two, or to clamp the result between zero and one. Instruction modifiers are applied after the instruction runs but before writing the result to the destination register.

A list of the modifiers is shown below.

ModifierDescriptionSyntaxVersion
1_11_21_31_4
_x2Multiply by 2instruction_x2XXXX
_x4Multiply by 4instruction_x4XXXX
_x8Multiply by 8instruction_x8X
_d2Divide by 2instruction_d2XXXX
_d4Divide by 4instruction_d4X
_d8Divide by 8instruction_d8X
_satSaturate (clamp from 0 and 1)instruction_satXXXX

 

  • The multiply modifier multiplies the register data by a power of two after it is read. This is the same as a shift left.
  • The divide modifier divides the register data by a power of two after it is read. This is the same as a shift right.
  • The saturate modifier clamps the range of register values from zero to one.

Instruction modifiers can be used on arithmetic instructions. They may not be used on texture address instructions.

Multiply modifier

This example loads the destination register (dest) with the sum of the two colors in the source operands (src0 and src1) and multiplies the result by two.



add_x2 dest, src0, src1


This example combines two instruction modifiers. First, two colors in the source operands (src0 and src1) are added. The result is then multiplied by two, and clamped between 0.0 to 1.0 for each component. The result is saved in the destination register.



add_x2_sat dest, src0, src1


Divide modifier

This example loads the destination register (dest) with the sum of the two colors in the source operands (src0 and src1) and divides the result by two.



add_d2 dest, src0, src1


Saturate modifier

For arithmetic instructions, the saturation modifier clamps the result of this instruction into the range 0.0 to 1.0 for each component. The following example shows how to use this instruction modifier.



dp3_sat r0, t0_bx2, v0_bx2    ; t0 is bump, v0 is light direction


This operation occurs after any multiply or divide instruction modifier. _sat is most often used to clamp dot product results. However, it also enables consistent emulation of multipass methods where the frame buffer is always in the range 0 to 1, and of DirectX 6 and 7.0 multitexture syntax, in which saturation is defined to occur at every stage.

This example loads the destination register (dest) with the sum of the two colors in the source operands (src0 and src1), and clamps the result into the range 0.0 to 1.0 for each component.



add_sat dest, src0, src1


This example combines two instruction modifiers. First, two colors in the source operands (src0 and src1) are added. The result is multiplied by two and clamped between 0.0 to 1.0 for each component. The result is saved in the destination register.



add_x2_sat dest, src0, src1


 

 

Community Additions

ADD
Show:
© 2014 Microsoft