Mesa (master): gallivm: fix different handling of [non] normalized coords in linear soa path

Roland Scheidegger sroland at kemper.freedesktop.org
Wed Oct 13 00:35:32 UTC 2010


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

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Wed Oct 13 02:34:08 2010 +0200

gallivm: fix different handling of [non]normalized coords in linear soa path

There seems to be no reason for it, so do same math for both
(except the scale mul, of course).

---

 src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |   22 +++++---------------
 1 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index af3f468..8c03284 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -294,23 +294,13 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
          if (bld->static_state->normalized_coords) {
             /* mul by tex size */
             coord = lp_build_mul(coord_bld, coord, length_f);
-            /* clamp to length max */
-            coord = lp_build_min(coord_bld, coord, length_f);
-            /* subtract 0.5 */
-            coord = lp_build_sub(coord_bld, coord, half);
-            /* clamp to [0, length - 0.5] */
-            coord = lp_build_max(coord_bld, coord, coord_bld->zero);
-         }
-         /* XXX this is odd normalized ranges from 0 to length-0.5 after denorm
-            but non-normalized ranges from to 0.5 to length-0.5 after clamp.
-            Is this missing the sub 0.5? */
-         else {
-            LLVMValueRef min, max;
-            /* clamp to [0.5, length - 0.5] */
-            min = half;
-            max = lp_build_sub(coord_bld, length_f, min);
-            coord = lp_build_clamp(coord_bld, coord, min, max);
          }
+         /* clamp to length max */
+         coord = lp_build_min(coord_bld, coord, length_f);
+         /* subtract 0.5 */
+         coord = lp_build_sub(coord_bld, coord, half);
+         /* clamp to [0, length - 0.5] */
+         coord = lp_build_max(coord_bld, coord, coord_bld->zero);
          /* convert to int, compute lerp weight */
          lp_build_ifloor_fract(&abs_coord_bld, coord, &coord0, &weight);
          coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one);




More information about the mesa-commit mailing list