summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2013-01-31 11:27:49 -0800
committerRoland Scheidegger <[email protected]>2013-02-16 02:40:44 +0100
commitc25ae5d27b114e23d5734f846002df1a05759658 (patch)
tree313509d2635332be6764b7f6549c73cac80b45af /src/gallium/drivers/llvmpipe
parent70daad6a99c9815fd55ffa016d35684e4414f257 (diff)
gallivm: fix issues with trunc/round/floor/ceil with no arch rounding
The emulation of these if there's no rounding instruction available is a bit more complicated than what the code did. In particular, doing fp-to-int/int-to-fp will not work if the exponent is large enough (and with NaNs, Infs). Hence such values need to be filtered out and the original value returned in this case (which fortunately should always be exact). This comes at the expense of performance (if your cpu doesn't support rounding instructions). Furthermore, floor/ifloor/ceil/iceil were affected by precision issues for values near negative (for floor) or positive (for ceil) zero, fix that as well (fixing this issue might not actually be slower except for ceil/iceil if the type is not signed which is probably rare - note iceil has no callers left in any case). Also add some new rounding test values in lp_test_arit to actually test for that stuff (which previously would have failed without sse41). This fixes https://bugs.freedesktop.org/show_bug.cgi?id=59701.
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_arit.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c
index 99928b8ab6e..f14e4b36320 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_arit.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c
@@ -207,6 +207,18 @@ const float round_values[] = {
-10.0, -1, 0.0, 12.0,
-1.49, -0.25, 1.25, 2.51,
-0.99, -0.01, 0.01, 0.99,
+ 1.401298464324817e-45f, // smallest denormal
+ -1.401298464324817e-45f,
+ 1.62981451e-08f,
+ -1.62981451e-08f,
+ 1.62981451e15f, // large number not representable as 32bit int
+ -1.62981451e15f,
+ FLT_EPSILON,
+ -FLT_EPSILON,
+ 1.0f - 0.5f*FLT_EPSILON,
+ -1.0f + FLT_EPSILON,
+ FLT_MAX,
+ -FLT_MAX
};
static float fractf(float x)