Mesa (mesa_7_4_branch): mesa: fix REMAINDER() macro

Brian Paul brianp at kemper.freedesktop.org
Tue Jun 16 14:48:47 UTC 2009


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

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Jun 16 08:48:12 2009 -0600

mesa: fix REMAINDER() macro

The results were incorrect for some negative values of A.
See bug 21872.

(cherry picked from mesa_7_5_branch, commit ed7f4b42307bff4633689d6781cd3643f10041e5)

---

 src/mesa/swrast/s_texfilter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index fce0bcf..f86dbdb 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -226,7 +226,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c,
  * If A is a signed integer, A % B doesn't give the right value for A < 0
  * (in terms of texture repeat).  Just casting to unsigned fixes that.
  */
-#define REMAINDER(A, B) ((unsigned) (A) % (unsigned) (B))
+#define REMAINDER(A, B) (((A) + (B) * 1024) % (B))
 
 
 /**




More information about the mesa-commit mailing list