Mesa (master): r600c: fix setting negative values to bitfields

Andre Maasikas andrem at kemper.freedesktop.org
Tue Sep 14 09:01:45 PDT 2010


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

Author: Andre Maasikas <amaasikas at gmail.com>
Date:   Tue Sep 14 18:56:39 2010 +0300

r600c: fix setting negative values to bitfields

when setting negative integers to bitfields we could overwrite
other parts of it. So mask the value to be written correctly.
This is used quite often in the driver - hope it doesnt affect
performace or uncover behaviour relied before...

fixes strange effects when setting negative lodbias on evergreen

---

 src/mesa/drivers/dri/r600/r700_chip.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/r600/r700_chip.h b/src/mesa/drivers/dri/r600/r700_chip.h
index ebf1840..0ca237b 100644
--- a/src/mesa/drivers/dri/r600/r700_chip.h
+++ b/src/mesa/drivers/dri/r600/r700_chip.h
@@ -38,7 +38,7 @@
 
 #include "r700_chipoffset.h"
 
-#define SETfield(x, val, shift, mask)  ( (x) = ((x) & ~(mask)) | ((val) << (shift)) ) /* u32All */
+#define SETfield(x, val, shift, mask)  ( (x) = ((x) & ~(mask)) | (((val) << (shift)) & (mask)) )/* u32All */
 #define CLEARfield(x, mask)            ( (x) &= ~(mask) )
 #define SETbit(x, bit)                 ( (x) |= (bit) )
 #define CLEARbit(x, bit)               ( (x) &= ~(bit) )



More information about the mesa-commit mailing list