Mesa (master): r600g: introduce r600_bc_src_toggle_neg helper and fix SUB & LRP

Alex Deucher agd5f at kemper.freedesktop.org
Fri Jul 8 21:22:19 UTC 2011


Module: Mesa
Branch: master
Commit: 3efb47f0b0557a6b96a7e41b27725cea4736a061
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3efb47f0b0557a6b96a7e41b27725cea4736a061

Author: Vadim Girlin <vadimgirlin at gmail.com>
Date:   Fri Jul  8 06:19:37 2011 +0400

r600g: introduce r600_bc_src_toggle_neg helper and fix SUB & LRP

SUB & LRP instructions should toggle NEG bit instead of setting it,
otherwise e.g. "SUB a,b,-1" is translated as "ADD a,b,-1"

Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>

---

 src/gallium/drivers/r600/r600_shader.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 6dae692..6bb5ceb 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -945,6 +945,11 @@ static void r600_bc_src_set_abs(struct r600_bc_alu_src *bc_src)
 	bc_src->neg = 0;
 }
 
+static void r600_bc_src_toggle_neg(struct r600_bc_alu_src *bc_src)
+{
+	bc_src->neg = !bc_src->neg;
+}
+
 static void tgsi_dst(struct r600_shader_ctx *ctx,
 		     const struct tgsi_full_dst_register *tgsi_dst,
 		     unsigned swizzle,
@@ -1001,7 +1006,7 @@ static int tgsi_op2_s(struct r600_shader_ctx *ctx, int swap)
 		/* handle some special cases */
 		switch (ctx->inst_info->tgsi_opcode) {
 		case TGSI_OPCODE_SUB:
-			alu.src[1].neg = 1;
+			r600_bc_src_toggle_neg(&alu.src[1]);
 			break;
 		case TGSI_OPCODE_ABS:
 			r600_bc_src_set_abs(&alu.src[0]);
@@ -2195,7 +2200,7 @@ static int tgsi_lrp(struct r600_shader_ctx *ctx)
 		alu.src[0].sel = V_SQ_ALU_SRC_1;
 		alu.src[0].chan = 0;
 		r600_bc_src(&alu.src[1], &ctx->src[0], i);
-		alu.src[1].neg = 1;
+		r600_bc_src_toggle_neg(&alu.src[1]);
 		alu.dst.sel = ctx->temp_reg;
 		alu.dst.chan = i;
 		if (i == lasti) {




More information about the mesa-commit mailing list