cmp - ps

Choose src1 if src0 >= 0. Otherwise, choose src2. The comparison is done per channel.

Syntax

cmp dst, src0, src1, src2

where

Remarks

Pixel shader versions 1_1 1_2 1_3 1_4 2_0 2_x 2_sw 3_0 3_sw
cmp x x x x x x x x

There are a few additional limitations for versions 1_2 and 1_3:

This example does a four-channel comparison.

ps_1_4
def c0, -0.6, 0.6, 0, 0.6
def c1  0,0,0,0
def c2  1,1,1,1

mov r1, c1
mov r2, c2

cmp r0, c0, r1, r2   // r0 is assigned 1,0,0,0 based on the following:

// r0.x = c2.x because c0.x < 0
// r0.y = c1.y because c0.y >= 0
// r0.z = c1.z because c0.z >= 0
// r0.w = c1.w because c0.w >= 0