From 20141d9efdf674a3c7a13a75fabe533665d02cd0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 5 Apr 2011 06:18:18 +0200 Subject: [PATCH] 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 +-- src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c | 2 ++ src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c | 2 ++ src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c | 7 +++++++ src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h | 3 +++ src/mesa/drivers/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 97ec0a1a1f2..6a000cfe2c6 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 28d132a5fe3..646a415ca51 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 9b5c7c6e489..c7f79bc53c7 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 25afd272bee..e3e498e8fb4 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c @@ -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", diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h index 7e666101276..b5868820611 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 fed3a3f7642..2dae56a2428 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 2b9d85fae8b..8980bd3dde1 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) -- 2.30.2