r300/compiler: implement the CND opcode
authorMarek Olšák <maraeo@gmail.com>
Tue, 5 Apr 2011 04:18:18 +0000 (06:18 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 5 Apr 2011 04:36:56 +0000 (06:36 +0200)
No one uses it now, but I will need it for a lowering pass.

src/gallium/drivers/r300/r300_tgsi_to_rc.c
src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c
src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h
src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
src/mesa/drivers/dri/r300/r300_reg.h

index 97ec0a1a1f20e5fdafc06daf5bedbdd2a52e7e72..6a000cfe2c6d435fd366cf30e6ed7d87d8b5da44 100644 (file)
@@ -52,8 +52,7 @@ static unsigned translate_opcode(unsigned opcode)
         case TGSI_OPCODE_MAD: return RC_OPCODE_MAD;
         case TGSI_OPCODE_SUB: return RC_OPCODE_SUB;
         case TGSI_OPCODE_LRP: return RC_OPCODE_LRP;
-     /* case TGSI_OPCODE_CND: return RC_OPCODE_CND; */
-     /* case TGSI_OPCODE_CND0: return RC_OPCODE_CND0; */
+        case TGSI_OPCODE_CND: return RC_OPCODE_CND;
      /* case TGSI_OPCODE_DP2A: return RC_OPCODE_DP2A; */
                                         /* gap */
         case TGSI_OPCODE_FRC: return RC_OPCODE_FRC;
index 28d132a5fe3ec42b1a2e73152d09c7fdd8ee6c3f..646a415ca51e14853f7f35dd1995dada1aebc29a 100644 (file)
@@ -108,6 +108,7 @@ static unsigned int translate_rgb_opcode(struct r300_fragment_program_compiler *
 {
        switch(opcode) {
        case RC_OPCODE_CMP: return R300_ALU_OUTC_CMP;
+       case RC_OPCODE_CND: return R300_ALU_OUTC_CND;
        case RC_OPCODE_DP3: return R300_ALU_OUTC_DP3;
        case RC_OPCODE_DP4: return R300_ALU_OUTC_DP4;
        case RC_OPCODE_FRC: return R300_ALU_OUTC_FRC;
@@ -127,6 +128,7 @@ static unsigned int translate_alpha_opcode(struct r300_fragment_program_compiler
 {
        switch(opcode) {
        case RC_OPCODE_CMP: return R300_ALU_OUTA_CMP;
+       case RC_OPCODE_CND: return R300_ALU_OUTA_CND;
        case RC_OPCODE_DP3: return R300_ALU_OUTA_DP4;
        case RC_OPCODE_DP4: return R300_ALU_OUTA_DP4;
        case RC_OPCODE_EX2: return R300_ALU_OUTA_EX2;
index 9b5c7c6e4897d0a7ead8e3b1c417002fd0ebc124..c7f79bc53c7bb56bcac2f96b95582c041f8dd62b 100644 (file)
@@ -93,6 +93,7 @@ static unsigned int translate_rgb_op(struct r300_fragment_program_compiler *c, r
 {
        switch(opcode) {
        case RC_OPCODE_CMP: return R500_ALU_RGBA_OP_CMP;
+       case RC_OPCODE_CND: return R500_ALU_RGBA_OP_CND;
        case RC_OPCODE_DDX: return R500_ALU_RGBA_OP_MDH;
        case RC_OPCODE_DDY: return R500_ALU_RGBA_OP_MDV;
        case RC_OPCODE_DP3: return R500_ALU_RGBA_OP_DP3;
@@ -114,6 +115,7 @@ static unsigned int translate_alpha_op(struct r300_fragment_program_compiler *c,
 {
        switch(opcode) {
        case RC_OPCODE_CMP: return R500_ALPHA_OP_CMP;
+       case RC_OPCODE_CND: return R500_ALPHA_OP_CND;
        case RC_OPCODE_COS: return R500_ALPHA_OP_COS;
        case RC_OPCODE_DDX: return R500_ALPHA_OP_MDH;
        case RC_OPCODE_DDY: return R500_ALPHA_OP_MDV;
index 25afd272beefd397326c360882ddeeb3311a171c..e3e498e8fb4f0ec098fbe64f196d0f0c22984296 100644 (file)
@@ -80,6 +80,13 @@ struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {
                .HasDstReg = 1,
                .IsComponentwise = 1
        },
+       {
+               .Opcode = RC_OPCODE_CND,
+               .Name = "CND",
+               .NumSrcRegs = 3,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
        {
                .Opcode = RC_OPCODE_COS,
                .Name = "COS",
index 7e666101276a2ed96269e324f91777281bbcf5f9..b58688206116b7785b9aefc581d23fbda8e9ae18 100644 (file)
@@ -56,6 +56,9 @@ typedef enum {
        /** vec4 instruction: dst.c = src0.c < 0.0 ? src1.c : src2.c */
        RC_OPCODE_CMP,
 
+       /** vec4 instruction: dst.c = src2.c > 0.5 ? src0.c : src1.c */
+       RC_OPCODE_CND,
+
        /** scalar instruction: dst = cos(src0.x) */
        RC_OPCODE_COS,
 
index fed3a3f764276d48486506ee6ce7aa8af55af2da..2dae56a2428dce38624bc0e5994b1ba494dccea8 100644 (file)
@@ -99,6 +99,7 @@ static void classify_instruction(struct rc_sub_instruction * inst,
        switch(inst->Opcode) {
        case RC_OPCODE_ADD:
        case RC_OPCODE_CMP:
+       case RC_OPCODE_CND:
        case RC_OPCODE_DDX:
        case RC_OPCODE_DDY:
        case RC_OPCODE_FRC:
index 2b9d85fae8b82312b496d0fb2eb1a44d4c527331..8980bd3dde1df129a22ef2135218168e308a6f45 100644 (file)
@@ -1906,7 +1906,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_ALU_OUTC_D2A                (3 << 23)
 #       define R300_ALU_OUTC_MIN                (4 << 23)
 #       define R300_ALU_OUTC_MAX                (5 << 23)
-#       define R300_ALU_OUTC_CMPH               (7 << 23)
+#       define R300_ALU_OUTC_CND                (7 << 23)
 #       define R300_ALU_OUTC_CMP                (8 << 23)
 #       define R300_ALU_OUTC_FRC                (9 << 23)
 #       define R300_ALU_OUTC_REPL_ALPHA         (10 << 23)