summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2012-05-15 22:34:36 +0100
committerJosé Fonseca <[email protected]>2012-05-15 22:39:24 +0100
commitc95cea50a9e14255a60c37b156271b7ab50515e9 (patch)
tree6c028ab04ef8922073ff7cfba13834551025cb92 /src
parent1459c18f45f5bd2a2d99145247093f1b540478ad (diff)
gallivm: Fix lp_build_const_xxx for negative integers.
Do proper rounding. Thanks to Olivier Galibert for investigating this.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_const.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c
index f0611b158d9..59e8fb2ed6e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c
@@ -36,6 +36,7 @@
#include <float.h>
#include "util/u_debug.h"
+#include "util/u_math.h"
#include "lp_bld_type.h"
#include "lp_bld_const.h"
@@ -297,7 +298,7 @@ lp_build_const_elem(struct gallivm_state *gallivm,
else {
double dscale = lp_const_scale(type);
- elem = LLVMConstInt(elem_type, val*dscale + 0.5, 0);
+ elem = LLVMConstInt(elem_type, round(val*dscale), 0);
}
return elem;
@@ -372,10 +373,10 @@ lp_build_const_aos(struct gallivm_state *gallivm,
else {
double dscale = lp_const_scale(type);
- elems[swizzle[0]] = LLVMConstInt(elem_type, r*dscale + 0.5, 0);
- elems[swizzle[1]] = LLVMConstInt(elem_type, g*dscale + 0.5, 0);
- elems[swizzle[2]] = LLVMConstInt(elem_type, b*dscale + 0.5, 0);
- elems[swizzle[3]] = LLVMConstInt(elem_type, a*dscale + 0.5, 0);
+ elems[swizzle[0]] = LLVMConstInt(elem_type, round(r*dscale), 0);
+ elems[swizzle[1]] = LLVMConstInt(elem_type, round(g*dscale), 0);
+ elems[swizzle[2]] = LLVMConstInt(elem_type, round(b*dscale), 0);
+ elems[swizzle[3]] = LLVMConstInt(elem_type, round(a*dscale), 0);
}
for(i = 4; i < type.length; ++i)