Mesa (gallium-0.2): gallium: PPC: clamp y to [-128,128] for LIT

Brian Paul brianp at kemper.freedesktop.org
Wed Oct 22 23:31:40 UTC 2008


Module: Mesa
Branch: gallium-0.2
Commit: 0ac99457811eb766e9bdd3903857b5c0fdef7694
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ac99457811eb766e9bdd3903857b5c0fdef7694

Author: Brian Paul <brian.paul at tungstengraphics.com>
Date:   Wed Oct 22 17:29:37 2008 -0600

gallium: PPC: clamp y to [-128,128] for LIT

---

 src/gallium/auxiliary/tgsi/tgsi_ppc.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
index 96beec0..9ad7ecd 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
@@ -636,16 +636,17 @@ emit_lit(struct gen_context *gen, struct tgsi_full_instruction *inst)
 
          FETCH(gen, *inst, w_vec, 0, CHAN_W);        /* w_vec = src[0].w */
 
-         /* XXX clamp Y to [-128, 128] */
+         /* clamp Y to [-128, 128] */
          load_constant_vec(gen, p128_vec, 128.0f);
          load_constant_vec(gen, n128_vec, -128.0f);
+         ppc_vmaxfp(gen->f, y_vec, y_vec, n128_vec); /* y = max(y, -128) */
+         ppc_vminfp(gen->f, y_vec, y_vec, p128_vec); /* y = min(y, 128) */
 
          /* if temp.x > 0
-          *    pow(tmp.y, tmp.w)
+          *    z = pow(tmp.y, tmp.w)
           * else
-          *   0.0
+          *    z = 0.0
           */
-
          ppc_vec_pow(gen->f, pow_vec, y_vec, w_vec);      /* pow = pow(y, w) */
          ppc_vcmpgtfpx(gen->f, pos_vec, x_vec, zero_vec); /* pos = x > 0 */
          ppc_vand(gen->f, z_vec, pow_vec, pos_vec);       /* z = pow & pos */




More information about the mesa-commit mailing list