Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-26 06:18:29 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-26 06:18:29 +0400
commit48a6fe86cab42d8417bf77f481fd131dd6cb0899 (patch)
treeebff96e51bd59d68d2d938f918e7aaeb5fd69a7f /intern/cycles/bvh/bvh_sort.cpp
parentb0d6c93ab6c23dcdf9d052a20b4730b902359952 (diff)
Fix #34172: cycles BVH build crashing in some rare circumstances on 32 bit linux.
The problem was (again) the x86 extended precision float register being used for one float value while the other was rounded to lower precision. This caused the strictly weak order requirement for std::sort to be broken.
Diffstat (limited to 'intern/cycles/bvh/bvh_sort.cpp')
-rw-r--r--intern/cycles/bvh/bvh_sort.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/intern/cycles/bvh/bvh_sort.cpp b/intern/cycles/bvh/bvh_sort.cpp
index 91994be5b96..d7dbae36336 100644
--- a/intern/cycles/bvh/bvh_sort.cpp
+++ b/intern/cycles/bvh/bvh_sort.cpp
@@ -23,6 +23,15 @@
CCL_NAMESPACE_BEGIN
+/* silly workaround for float extended precision that happens when compiling
+ * on x86, due to one float staying in 80 bit precision register and the other
+ * not, which causes the strictly weak ordering to break */
+#if !defined(__i386__)
+#define NO_EXTENDED_PRECISION
+#else
+#define NO_EXTENDED_PRECISION volatile
+#endif
+
struct BVHReferenceCompare {
public:
int dim;
@@ -34,8 +43,8 @@ public:
bool operator()(const BVHReference& ra, const BVHReference& rb)
{
- float ca = ra.bounds().min[dim] + ra.bounds().max[dim];
- float cb = rb.bounds().min[dim] + rb.bounds().max[dim];
+ NO_EXTENDED_PRECISION float ca = ra.bounds().min[dim] + ra.bounds().max[dim];
+ NO_EXTENDED_PRECISION float cb = rb.bounds().min[dim] + rb.bounds().max[dim];
if(ca < cb) return true;
else if(ca > cb) return false;
@@ -52,7 +61,8 @@ public:
void bvh_reference_sort(int start, int end, BVHReference *data, int dim)
{
- sort(data+start, data+end, BVHReferenceCompare(dim));
+ BVHReferenceCompare compare(dim);
+ sort(data+start, data+end, compare);
}
CCL_NAMESPACE_END