i915: Add support for SSG opcode.
authorEric Anholt <eric@anholt.net>
Tue, 17 Aug 2010 23:12:15 +0000 (16:12 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 17 Aug 2010 23:39:18 +0000 (16:39 -0700)
Fixes glsl-fs-sign and many of the tests of trig builtins.

src/mesa/drivers/dri/i915/i915_fragprog.c

index 3101bd17001576cd5f3af5a56c3282d2b0ca6da9..4a2e6209d075cbd496deb5a68a15a02a03e3c7d7 100644 (file)
@@ -983,6 +983,41 @@ upload_program(struct i915_fragment_program *p)
                         0);
          break;
 
+      case OPCODE_SSG:
+        dst = get_result_vector(p, inst);
+        flags = get_result_flags(inst);
+         src0 = src_vector(p, &inst->SrcReg[0], program);
+        tmp = i915_get_utemp(p);
+
+        /* tmp = (src < 0.0) */
+        i915_emit_arith(p,
+                        A0_SLT,
+                        tmp,
+                        flags, 0,
+                        src0,
+                        swizzle(src0, ZERO, ZERO, ZERO, ZERO),
+                        0);
+
+        /* dst = (0.0 < src) */
+        i915_emit_arith(p,
+                        A0_SLT,
+                        dst,
+                        flags, 0,
+                        swizzle(src0, ZERO, ZERO, ZERO, ZERO),
+                        src0,
+                        0);
+
+        /* dst = (src > 0.0) - (src < 0.0) */
+        i915_emit_arith(p,
+                        A0_ADD,
+                        dst,
+                        flags, 0,
+                        dst,
+                        negate(tmp, 1, 1, 1, 1),
+                        0);
+
+         break;
+
       case OPCODE_SUB:
          src0 = src_vector(p, &inst->SrcReg[0], program);
          src1 = src_vector(p, &inst->SrcReg[1], program);