965: Fix color clamping issues
authorKrzysztof Czurylo <krzysztof.czurylo@intel.com>
Wed, 30 Jul 2008 17:19:08 +0000 (10:19 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 21 Aug 2008 22:01:59 +0000 (15:01 -0700)
Patch is correctly applied this time.

src/mesa/drivers/dri/i965/brw_vs_emit.c

index ad414f42cce292540cd0830d6ef1d72f92727d3c..8759826e83b3fa489856cf2728e802804c1956dd 100644 (file)
@@ -1165,6 +1165,27 @@ void brw_vs_emit(struct brw_vs_compile *c )
          brw_MOV(p, get_dst(c, inst->DstReg), dst);
       }
 
+      /* Result color clamping.
+       *
+       * When destination register is an output register and
+       * it's primary/secondary front/back color, we have to clamp
+       * the result to [0,1]. This is done by enabling the
+       * saturation bit for the last instruction.
+       *
+       * We don't use brw_set_saturate() as it modifies
+       * p->current->header.saturate, which affects all the subsequent
+       * instructions. Instead, we directly modify the header
+       * of the last (already stored) instruction.
+       */
+      if (inst->DstReg.File == PROGRAM_OUTPUT) {
+         if ((inst->DstReg.Index == VERT_RESULT_COL0)
+             || (inst->DstReg.Index == VERT_RESULT_COL1)
+             || (inst->DstReg.Index == VERT_RESULT_BFC0)
+             || (inst->DstReg.Index == VERT_RESULT_BFC1)) {
+            p->store[p->nr_insn-1].header.saturate = 1;
+         }
+      }
+
       release_tmps(c);
    }