vc4: Fix FLR for integer values less than 0.
authorEric Anholt <eric@anholt.net>
Wed, 20 Aug 2014 21:44:36 +0000 (14:44 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 22 Aug 2014 17:16:57 +0000 (10:16 -0700)
If we didn't truncate at all, then we don't need to fix for truncation
happening in the wrong direction.

Fixes piglit builtin-functions/*-floor-*

src/gallium/drivers/vc4/vc4_program.c

index c11ee5aa1b1cc32292fd164e0e8fe3a153f3ee5b..9f59bdffe0c3b54a8dd66d33e0749c9bed01ed1b 100644 (file)
@@ -431,8 +431,14 @@ tgsi_to_qir_flr(struct tgsi_to_qir *trans,
 {
         struct qcompile *c = trans->c;
         struct qreg trunc = qir_ITOF(c, qir_FTOI(c, src[0 * 4 + i]));
+
+        /* This will be < 0 if we truncated and the truncation was of a value
+         * that was < 0 in the first place.
+         */
+        struct qreg diff = qir_FSUB(c, src[0 * 4 + i], trunc);
+
         return qir_CMP(c,
-                       src[0 * 4 + i],
+                       diff,
                        qir_FSUB(c, trunc, qir_uniform_f(trans, 1.0)),
                        trunc);
 }