diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-10-26 15:27:31 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-10-26 15:30:25 +0300 |
commit | 7c7d23691fc8583967a17dc501b9fb94f101990b (patch) | |
tree | 9fd6074d816fa20bb4bb0391470f7481721f8d80 /intern | |
parent | 72921a1e43033d7fea998dd607a68250da5d93bd (diff) |
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.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/util/util_transform.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h index 771a9442cb3..1bac3c150cb 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 |