vc4: Add support for nir_iabs.
authorEric Anholt <eric@anholt.net>
Wed, 1 Apr 2015 22:19:38 +0000 (15:19 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 2 Apr 2015 17:32:35 +0000 (10:32 -0700)
Tested using the GLSL 1.30 tests for integer abs().  Not currently used,
but it was one of the new opcodes used by robclark's idiv lowering.

src/gallium/drivers/vc4/vc4_program.c

index 5ed2165b014a2c1cda0957b1083b2e1ddb7769a4..bcceb3ccb5217710a704b042be255822f369dd10 100644 (file)
@@ -1069,9 +1069,14 @@ ntq_emit_alu(struct vc4_compile *c, nir_alu_instr *instr)
         case nir_op_fsign:
                 *dest = ntq_fsign(c, src[0]);
                 break;
+
         case nir_op_fabs:
                 *dest = qir_FMAXABS(c, src[0], src[0]);
                 break;
+        case nir_op_iabs:
+                *dest = qir_MAX(c, src[0],
+                                qir_SUB(c, qir_uniform_ui(c, 0), src[0]));
+                break;
 
         default:
                 fprintf(stderr, "unknown NIR ALU inst: ");