Mesa (7.9): r300/compiler: fix translating the src negate bits in pair_translate

Marek Olšák mareko at kemper.freedesktop.org
Sat Mar 12 21:40:27 UTC 2011


Module: Mesa
Branch: 7.9
Commit: c198d29fbe8fc6456ff751f26e109c691692360a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c198d29fbe8fc6456ff751f26e109c691692360a

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sat Mar 12 09:32:16 2011 +0100

r300/compiler: fix translating the src negate bits in pair_translate

(1, -_, ...) was converted to (-1, ...) because of the negation
in the second component.
Masking out the unused bits fixes this.

Piglit:
- glsl-fs-texture2d-branching

NOTE: This is a candidate for the 7.9 and 7.10 branches.
(cherry picked from commit d96305e4fcc67047e730cdc177bfa3da4307ff5a)

---

 .../dri/r300/compiler/radeon_pair_translate.c      |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

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 840c7a5..a500a2c 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
@@ -211,16 +211,21 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
 		if (needrgb && !istranscendent) {
 			unsigned int srcrgb = 0;
 			unsigned int srcalpha = 0;
+			unsigned int srcmask = 0;
 			int j;
 			/* We don't care about the alpha channel here.  We only
 			 * want the part of the swizzle that writes to rgb,
 			 * since we are creating an rgb instruction. */
 			for(j = 0; j < 3; ++j) {
 				unsigned int swz = GET_SWZ(inst->SrcReg[i].Swizzle, j);
-				if (swz < 3)
+
+				if (swz < RC_SWIZZLE_W)
 					srcrgb = 1;
-				else if (swz < 4)
+				else if (swz == RC_SWIZZLE_W)
 					srcalpha = 1;
+
+				if (swz < RC_SWIZZLE_UNUSED)
+					srcmask |= 1 << j;
 			}
 			source = rc_pair_alloc_source(pair, srcrgb, srcalpha,
 							inst->SrcReg[i].File, inst->SrcReg[i].Index);
@@ -232,7 +237,7 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
 			pair->RGB.Arg[i].Source = source;
 			pair->RGB.Arg[i].Swizzle = inst->SrcReg[i].Swizzle & 0x1ff;
 			pair->RGB.Arg[i].Abs = inst->SrcReg[i].Abs;
-			pair->RGB.Arg[i].Negate = !!(inst->SrcReg[i].Negate & (RC_MASK_X | RC_MASK_Y | RC_MASK_Z));
+			pair->RGB.Arg[i].Negate = !!(srcmask & inst->SrcReg[i].Negate & (RC_MASK_X | RC_MASK_Y | RC_MASK_Z));
 		}
 		if (needalpha) {
 			unsigned int srcrgb = 0;




More information about the mesa-commit mailing list