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

Author: Patrick Rudolph <s...@das-labor.org>
Date:   Mon Mar 28 11:52:00 2016 +0200

r600g: fix and optimize tgsi_cmp when using ABS and NEG modifier

Some apps set NEG and ABS on the source param to test for zero.
Use ALU_OP3_CNDE insted of ALU_OP3_CNDGE and unset both modifiers.

It also removes the need for a MOV instruction, as ABS isn't
supported on op3.

Tested on AMD CAYMAN and AMD RV770.

Signed-off-by: Patrick Rudolph <s...@das-labor.org>
Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Dave Airlie <airl...@redhat.com>

---

 src/gallium/drivers/r600/r600_shader.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 64b049a..cd5ae44 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -7707,6 +7707,15 @@ static int tgsi_cmp(struct r600_shader_ctx *ctx)
        int i, r, j;
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
        int temp_regs[3];
+       unsigned op;
+
+       if (ctx->src[0].abs && ctx->src[0].neg) {
+               op = ALU_OP3_CNDE;
+               ctx->src[0].abs = 0;
+               ctx->src[0].neg = 0;
+       } else {
+               op = ALU_OP3_CNDGE;
+       }
 
        for (j = 0; j < inst->Instruction.NumSrcRegs; j++) {
                temp_regs[j] = 0;
@@ -7719,7 +7728,7 @@ static int tgsi_cmp(struct r600_shader_ctx *ctx)
                        continue;
 
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
-               alu.op = ALU_OP3_CNDGE;
+               alu.op = op;
                r = tgsi_make_src_for_op3(ctx, temp_regs[0], i, &alu.src[0], 
&ctx->src[0]);
                if (r)
                        return r;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to