summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-09-25 13:06:31 -0600
committerBrian Paul <[email protected]>2010-09-25 13:37:05 -0600
commite31f0f996537046228602a251706613ca4163209 (patch)
tree11542ad2e6692d47f3f13963308d4e64b535634d /src
parentf3e6a0faa9090cfcfcafe06e1481ed5a18838ca0 (diff)
softpipe: fix repeat() function for NPOT textures
The trick of casting the coord to an unsigned value only works for POT textures. Add a bias instead. This fixes a few piglit texwrap failures.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index e654bb77c29..96ccf1da988 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -105,14 +105,14 @@ lerp_3d(float a, float b, float c,
/**
* Compute coord % size for repeat wrap modes.
- * Note that if coord is a signed integer, coord % size doesn't give
- * the right value for coord < 0 (in terms of texture repeat). Just
- * casting to unsigned fixes that.
+ * Note that if coord is negative, coord % size doesn't give the right
+ * value. To avoid that problem we add a large multiple of the size
+ * (rather than using a conditional).
*/
static INLINE int
repeat(int coord, unsigned size)
{
- return (int) ((unsigned) coord % size);
+ return (coord + size * 1024) % size;
}