r300/compiler: Unbreak DDX/DDY.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Tue, 30 Mar 2010 17:43:51 +0000 (10:43 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Tue, 30 Mar 2010 17:43:51 +0000 (10:43 -0700)
Fixes progs/glsl/deriv.

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_pair_translate.c

index 4e84eefd658ae24a88214e02bef1da7bb65bf989..b6dfe28def99e6adfa2aac39df1dd5a9fff72d1e 100644 (file)
@@ -190,6 +190,17 @@ static unsigned int use_source(struct r500_fragment_program_code* code, struct r
        return 0;
 }
 
+/**
+ * NOP the specified instruction if it is not a texture lookup.
+ */
+static void alu_nop(struct r300_fragment_program_compiler *c, int ip)
+{
+       PROG_CODE;
+
+       if ((code->inst[ip].inst0 & 0x3) != R500_INST_TYPE_TEX) {
+               code->inst[ip].inst0 |= R500_INST_NOP;
+       }
+}
 
 /**
  * Emit a paired ALU instruction.
@@ -205,6 +216,14 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
 
        int ip = ++code->inst_end;
 
+       /* Quirk: MDH/MDV (DDX/DDY) need a NOP on previous non-TEX instructions. */
+       if (inst->RGB.Opcode == RC_OPCODE_DDX || inst->Alpha.Opcode == RC_OPCODE_DDX ||
+               inst->RGB.Opcode == RC_OPCODE_DDY || inst->Alpha.Opcode == RC_OPCODE_DDY) {
+               if (ip > 0) {
+                       alu_nop(c, ip - 1);
+               }
+       }
+
        code->inst[ip].inst5 = translate_rgb_op(c, inst->RGB.Opcode);
        code->inst[ip].inst4 = translate_alpha_op(c, inst->Alpha.Opcode);
 
@@ -252,8 +271,8 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
        code->inst[ip].inst4 |= translate_arg_alpha(inst, 1) << R500_ALPHA_SEL_B_SHIFT;
        code->inst[ip].inst5 |= translate_arg_alpha(inst, 2) << R500_ALU_RGBA_ALPHA_SEL_C_SHIFT;
 
-    code->inst[ip].inst3 |= R500_ALU_RGB_TARGET(inst->RGB.Target);
-    code->inst[ip].inst4 |= R500_ALPHA_TARGET(inst->Alpha.Target);
+       code->inst[ip].inst3 |= R500_ALU_RGB_TARGET(inst->RGB.Target);
+       code->inst[ip].inst4 |= R500_ALPHA_TARGET(inst->Alpha.Target);
 
        if (inst->WriteALUResult) {
                code->inst[ip].inst3 |= R500_ALU_RGB_WMASK;
index c1c0181fac1653893d21ffe97cc754db18fc72d1..9d289fce3429e439dce7cf5c4c59b77f2dfcf338 100644 (file)
@@ -75,14 +75,14 @@ struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {
        {
                .Opcode = RC_OPCODE_DDX,
                .Name = "DDX",
-               .NumSrcRegs = 1,
+               .NumSrcRegs = 2,
                .HasDstReg = 1,
                .IsComponentwise = 1
        },
        {
                .Opcode = RC_OPCODE_DDY,
                .Name = "DDY",
-               .NumSrcRegs = 1,
+               .NumSrcRegs = 2,
                .HasDstReg = 1,
                .IsComponentwise = 1
        },
index fff5b0c21735a5158f96e8fc4c80429b56721856..3a26e7daaf9563bf58bd886c9d088f02e6e1de8d 100644 (file)
@@ -159,11 +159,6 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
        int nargs = opcode->NumSrcRegs;
        int i;
 
-       /* Special case for DDX/DDY (MDH/MDV). */
-       if (inst->Opcode == RC_OPCODE_DDX || inst->Opcode == RC_OPCODE_DDY) {
-               nargs++;
-       }
-
        for(i = 0; i < opcode->NumSrcRegs; ++i) {
                int source;
                if (needrgb && !istranscendent) {