[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56303] trunk/blender/intern/cycles/bvh/ bvh_sort.cpp: Fix #34172: cycles BVH build crashing in some rare circumstances on 32 bit linux.
Brecht Van Lommel
brechtvanlommel at pandora.be
Fri Apr 26 04:18:31 CEST 2013
Revision: 56303
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56303
Author: blendix
Date: 2013-04-26 02:18:29 +0000 (Fri, 26 Apr 2013)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/intern/cycles/bvh/bvh_sort.cpp
Modified: trunk/blender/intern/cycles/bvh/bvh_sort.cpp
===================================================================
--- trunk/blender/intern/cycles/bvh/bvh_sort.cpp 2013-04-25 19:50:54 UTC (rev 56302)
+++ trunk/blender/intern/cycles/bvh/bvh_sort.cpp 2013-04-26 02:18:29 UTC (rev 56303)
@@ -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 @@
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 @@
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
More information about the Bf-blender-cvs
mailing list