[Bf-blender-cvs] [c6f8ea7b45a] master: Fix T69044: OpenCL fail due to bad fract function.

OmarSquircleArt noreply at git.blender.org
Thu Aug 22 13:50:42 CEST 2019


Commit: c6f8ea7b45af72fa7f7d1a47140fd946c1db3d5e
Author: OmarSquircleArt
Date:   Thu Aug 22 13:47:24 2019 +0200
Branches: master
https://developer.blender.org/rBc6f8ea7b45af72fa7f7d1a47140fd946c1db3d5e

Fix T69044: OpenCL fail due to bad fract function.

The fract function in OpenCL does more than just return the fraction.
It also writes the floor to the second argument. Which wasn't put
in consideration.

Instead, we use a simple `a - floor(a)` like the Math node.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5553

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

M	intern/cycles/kernel/svm/svm_math_util.h
M	intern/cycles/util/util_math_float3.h

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

diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h
index c87ca0defa7..c07a1e4ed98 100644
--- a/intern/cycles/kernel/svm/svm_math_util.h
+++ b/intern/cycles/kernel/svm/svm_math_util.h
@@ -69,7 +69,7 @@ ccl_device void svm_vector_math(
       *vector = make_float3(safe_modulo(a.x, b.x), safe_modulo(a.y, b.y), safe_modulo(a.z, b.z));
       break;
     case NODE_VECTOR_MATH_FRACTION:
-      *vector = fract(a);
+      *vector = a - floor(a);
       break;
     case NODE_VECTOR_MATH_ABSOLUTE:
       *vector = fabs(a);
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index 0d7588da690..c9a5b34aa58 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -61,7 +61,6 @@ ccl_device_inline float3 rcp(const float3 &a);
 ccl_device_inline float3 sqrt(const float3 &a);
 ccl_device_inline float3 floor(const float3 &a);
 ccl_device_inline float3 ceil(const float3 &a);
-ccl_device_inline float3 fract(const float3 &a);
 #endif /* !__KERNEL_OPENCL__ */
 
 ccl_device_inline float min3(float3 a);
@@ -313,11 +312,6 @@ ccl_device_inline float3 ceil(const float3 &a)
 #  endif
 }
 
-ccl_device_inline float3 fract(const float3 &a)
-{
-  return a - floor(a);
-}
-
 ccl_device_inline float3 mix(const float3 &a, const float3 &b, float t)
 {
   return a + t * (b - a);



More information about the Bf-blender-cvs mailing list