summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_test_main.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-09-22 14:48:28 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-09-22 15:02:39 +0100
commit9a8e9f4595b66ea094b293da1afcded8f06ab3d6 (patch)
treefd0217ae16af46f360490cfc5352af8113f30574 /src/gallium/drivers/llvmpipe/lp_test_main.c
parent162b0efff6e82cc5f332a71aa16a376a2e9ba40c (diff)
llvmpipe: Special case complementary and identify blend factors in SoA.
One multiplication instead of two. Also fix floating point random number generation and verification. TODO: Do the same for AoS blending.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_test_main.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_main.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_test_main.c b/src/gallium/drivers/llvmpipe/lp_test_main.c
index 7bbbc61d4c2..7a0d06ae2c8 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_main.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_main.c
@@ -205,16 +205,19 @@ random_elem(struct lp_type type, void *dst, unsigned index)
assert(index < type.length);
value = (double)rand()/(double)RAND_MAX;
if(!type.norm) {
- unsigned long long mask;
- if (type.floating)
- mask = ~(unsigned long long)0;
- else if (type.fixed)
- mask = ((unsigned long long)1 << (type.width / 2)) - 1;
- else if (type.sign)
- mask = ((unsigned long long)1 << (type.width - 1)) - 1;
- else
- mask = ((unsigned long long)1 << type.width) - 1;
- value += (double)(mask & rand());
+ if (type.floating) {
+ value *= 2.0;
+ }
+ else {
+ unsigned long long mask;
+ if (type.fixed)
+ mask = ((unsigned long long)1 << (type.width / 2)) - 1;
+ else if (type.sign)
+ mask = ((unsigned long long)1 << (type.width - 1)) - 1;
+ else
+ mask = ((unsigned long long)1 << type.width) - 1;
+ value += (double)(mask & rand());
+ }
}
if(!type.sign)
if(rand() & 1)
@@ -261,12 +264,18 @@ boolean
compare_vec_with_eps(struct lp_type type, const void *res, const void *ref, double eps)
{
unsigned i;
+ eps *= type.floating ? 8.0 : 2.0;
for (i = 0; i < type.length; ++i) {
double res_elem = read_elem(type, res, i);
double ref_elem = read_elem(type, ref, i);
- double delta = fabs(res_elem - ref_elem);
- if(delta >= 2.0*eps)
+ double delta = res_elem - ref_elem;
+ if (ref_elem < -1.0 || ref_elem > 1.0) {
+ delta /= ref_elem;
+ }
+ delta = fabs(delta);
+ if (delta >= eps) {
return FALSE;
+ }
}
return TRUE;