Windows Dev Center

if_comp - ps

Start an if bool - ps...else - ps...endif - ps block, with a condition based on values that could be computed in a shader. This instruction is used to skip a block of code, based on a condition.

Syntax

if_comp src0, src1

 

Where:

  • _comp is a comparison between the two source registers. It can be one of the following:
    SyntaxComparison
    _gtGreater than
    _ltLess than
    _geGreater than or equal
    _leLess than or equal
    _eqEqual to
    _neNot equal to

     

  • src0 is a source register. Replicate swizzle is required to select a component.
  • src1 is a source register. Replicate swizzle is required to select a component.

Remarks

Pixel shader versions1_11_21_31_42_02_x2_sw3_03_sw
if_compxxxx

 

This instruction is used to skip a block of code, based on a condition.



if (src0 comparison src1)
   jump to the corresponding else or endif instruction;


Be careful using the equals and not equals comparison modes on floating point numbers. Because rounding occurs during during floating point calculations, the comparison can be done against an epsilon value (small nonzero number) to avoid errors.

Restrictions include:

  • if_comp...else - ps...endif - ps blocks (along with the predicated if blocks) can be nested up to 24 layers deep.
  • src0 and src1 registers require a replicate swizzle.
  • if_comp blocks must end with an else - vs or endif - vs instruction.
  • if_comp...else - ps...endif - ps blocks cannot straddle a loop block. The if_comp block must be completely inside or outside the loop block.

Example

This instruction provides conditional dynamic flow control.



if_lt r3.x, r4.y
// Instructions to run if r3.x < r4.y

else
// Instructions to run otherwise

endif


 

 

Community Additions

ADD
Show:
© 2015 Microsoft