if_comp - vs
Start an if bool - vs...else - vs...endif - vs 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:
Syntax Comparison _gt Greater than _lt Less than _ge Greater than or equal _le Less than or equal _eq Equal to _ne Not 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
Vertex shader versions | 1_1 | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
---|---|---|---|---|---|---|
if_comp | x | x | x | x |
This instruction is used to skip a block of code, based on a condition.
if_lt src0, 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 floating point calculations, the comparison can be done against an epsilon value (small nonzero number) to avoid errors.
Restrictions include:
- if_comp...else - vs...endif - vs 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 - vs...endif - vs blocks cannot straddle a loop block. The if_comp block must be completely inside, or outside the loop - vs 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
Related topics