Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

cmp - ps

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

Syntax

cmp dst, src0, src1, src2

 

where

  • dst is the destination register.
  • src0 is a source register.
  • src1 is a source register.
  • src2 is a source register.

Remarks

Pixel shader versions1_11_21_31_42_02_x2_sw3_03_sw
cmpxxxxxxxx

 

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

  • Each shader can use up to a maximum of three cmp instructions.
  • The destination register cannot be the same as any of the source registers.

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


 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.