[Mesa-dev] [PATCH] softpipe: fix clamping when using unormalized coordinates

Morgan Armand morgan.devel at gmail.com
Sun Nov 13 02:24:37 PST 2011


---
 src/gallium/drivers/softpipe/sp_tex_sample.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 72629a0..9b0e54e1 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -491,7 +491,8 @@ wrap_linear_unorm_clamp(const float s[4], unsigned size,
    uint ch;
    for (ch = 0; ch < 4; ch++) {
       /* Not exactly what the spec says, but it matches NVIDIA output */
-      float u = CLAMP(s[ch] - 0.5F, 0.0f, (float) size - 1.0f);
+      float u = CLAMP(s[ch], 0.0f, (float) size);
+      u -= 0.5F;
       icoord0[ch] = util_ifloor(u);
       icoord1[ch] = icoord0[ch] + 1;
       w[ch] = frac(u);
@@ -512,8 +513,8 @@ wrap_linear_unorm_clamp_to_border(const float s[4], unsigned size,
       u -= 0.5F;
       icoord0[ch] = util_ifloor(u);
       icoord1[ch] = icoord0[ch] + 1;
-      if (icoord1[ch] > (int) size - 1)
-         icoord1[ch] = size - 1;
+      if (icoord1[ch] > (int) size)
+         icoord1[ch] = size;
       w[ch] = frac(u);
    }
 }
-- 
1.7.7.1.msysgit.0



More information about the mesa-dev mailing list