Merge remote branch 'origin/7.8'
[mesa.git] / src / mesa / drivers / dri / r300 / compiler / radeon_pair_translate.c
index 72117682725982887d2fa08409243f9c858760d0..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) {
@@ -203,12 +198,21 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
 
        /* Destination handling */
        if (inst->DstReg.File == RC_FILE_OUTPUT) {
-               if (inst->DstReg.Index == c->OutputColor) {
-                       pair->RGB.OutputWriteMask |= inst->DstReg.WriteMask & RC_MASK_XYZ;
-                       pair->Alpha.OutputWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
-               } else if (inst->DstReg.Index == c->OutputDepth) {
-                       pair->Alpha.DepthWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
-               }
+        if (inst->DstReg.Index == c->OutputDepth) {
+            pair->Alpha.DepthWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
+        } else {
+            for (i = 0; i < 4; i++) {
+                if (inst->DstReg.Index == c->OutputColor[i]) {
+                    pair->RGB.Target = i;
+                    pair->Alpha.Target = i;
+                    pair->RGB.OutputWriteMask |=
+                        inst->DstReg.WriteMask & RC_MASK_XYZ;
+                    pair->Alpha.OutputWriteMask |=
+                        GET_BIT(inst->DstReg.WriteMask, 3);
+                    break;
+                }
+            }
+        }
        } else {
                if (needrgb) {
                        pair->RGB.DestIndex = inst->DstReg.Index;