[Bf-blender-cvs] [7c7d236] master: Cycles: Fix crashes after recent optimization commits

Sergey Sharybin noreply at git.blender.org
Wed Oct 26 14:30:28 CEST 2016


Commit: 7c7d23691fc8583967a17dc501b9fb94f101990b
Author: Sergey Sharybin
Date:   Wed Oct 26 14:27:31 2016 +0200
Branches: master
https://developer.blender.org/rB7c7d23691fc8583967a17dc501b9fb94f101990b

Cycles: Fix crashes after recent optimization commits

There is some precision issues for big magnitude coordinates which started
to give weird behavior of release builds. Some weird memory usage in BVH
which is tricky to nail down because only happens in release builds and GDB
reports all variables as optimized out when trying to use RelWithDebInfo.

There are two things in this commit:

- Attempt to make vectorized code closer to original one, hoping that it'll
  eliminate precision issue.
  This seems to work for transform_point().
- Similar trick did not work for transform_direction() even tho absolute
  error here is much smaller. For now disabled that function, need a more
  careful look here.

===================================================================

M	intern/cycles/util/util_transform.h

===================================================================

diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index 771a944..1bac3c1 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -84,9 +84,10 @@ ccl_device_inline float3 transform_point(const Transform *t, const float3 a)
 
 	_MM_TRANSPOSE4_PS(x, y, z, w);
 
-	ssef tmp = madd(x, shuffle<0>(aa), w);
-	tmp = madd(y, shuffle<1>(aa), tmp);
-	tmp = madd(z, shuffle<2>(aa), tmp);
+	ssef tmp = shuffle<0>(aa) * x;
+	tmp = madd(shuffle<1>(aa), y, tmp);
+	tmp = madd(shuffle<2>(aa), z, tmp);
+	tmp += w;
 
 	return float3(tmp.m128);
 #else
@@ -101,7 +102,8 @@ ccl_device_inline float3 transform_point(const Transform *t, const float3 a)
 
 ccl_device_inline float3 transform_direction(const Transform *t, const float3 a)
 {
-#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
+	/* TODO(sergey): Disabled for now, causes crashes in certain cases. */
+#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__) && 0
 	ssef x, y, z, w, aa;
 	aa = a.m128;
 	x = _mm_loadu_ps(&t->x.x);
@@ -111,9 +113,9 @@ ccl_device_inline float3 transform_direction(const Transform *t, const float3 a)
 
 	_MM_TRANSPOSE4_PS(x, y, z, w);
 
-	ssef tmp = x * shuffle<0>(aa);
-	tmp = madd(y, shuffle<1>(aa), tmp);
-	tmp = madd(z, shuffle<2>(aa), tmp);
+	ssef tmp = shuffle<0>(aa) * x;
+	tmp = madd(shuffle<1>(aa), y, tmp);
+	tmp = madd(shuffle<2>(aa), z, tmp);
 
 	return float3(tmp.m128);
 #else




More information about the Bf-blender-cvs mailing list