Mesa (master): r300/compiler: implement the CND opcode

Marek Olšák mareko at kemper.freedesktop.org
Mon Apr 4 21:38:28 PDT 2011


Module: Mesa
Branch: master
Commit: 20141d9efdf674a3c7a13a75fabe533665d02cd0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=20141d9efdf674a3c7a13a75fabe533665d02cd0

Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Apr  5 06:18:18 2011 +0200

r300/compiler: implement the CND opcode

No one uses it now, but I will need it for a lowering pass.

---

 src/gallium/drivers/r300/r300_tgsi_to_rc.c         |    3 +--
 .../drivers/dri/r300/compiler/r300_fragprog_emit.c |    2 ++
 .../drivers/dri/r300/compiler/r500_fragprog_emit.c |    2 ++
 .../drivers/dri/r300/compiler/radeon_opcodes.c     |    7 +++++++
 .../drivers/dri/r300/compiler/radeon_opcodes.h     |    3 +++
 .../dri/r300/compiler/radeon_pair_translate.c      |    1 +
 src/mesa/drivers/dri/r300/r300_reg.h               |    2 +-
 7 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
index 97ec0a1..6a000cf 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -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;
diff --git a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
index 28d132a..646a415 100644
--- a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
+++ b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
@@ -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;
diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
index 9b5c7c6..c7f79bc 100644
--- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
+++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
@@ -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;
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c
index 25afd27..e3e498e 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c
@@ -81,6 +81,13 @@ struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {
 		.IsComponentwise = 1
 	},
 	{
+		.Opcode = RC_OPCODE_CND,
+		.Name = "CND",
+		.NumSrcRegs = 3,
+		.HasDstReg = 1,
+		.IsComponentwise = 1
+	},
+	{
 		.Opcode = RC_OPCODE_COS,
 		.Name = "COS",
 		.NumSrcRegs = 1,
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h
index 7e66610..b586882 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h
@@ -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,
 
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
index fed3a3f..2dae56a 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
@@ -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:
diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h
index 2b9d85f..8980bd3 100644
--- a/src/mesa/drivers/dri/r300/r300_reg.h
+++ b/src/mesa/drivers/dri/r300/r300_reg.h
@@ -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)



More information about the mesa-commit mailing list