From b98ccf699878d70b7cbfdd7863440c34326a5569 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 10 Aug 2011 14:26:51 +0000 Subject: Cycles: amd opencl compatibility fixes. --- intern/cycles/kernel/svm/svm_math.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'intern/cycles/kernel/svm/svm_math.h') diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h index 401bd22b45a..bc2f774097e 100644 --- a/intern/cycles/kernel/svm/svm_math.h +++ b/intern/cycles/kernel/svm/svm_math.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN __device float safe_asinf(float a) { if(a <= -1.0f) - return -M_PI_2; + return -M_PI_2_F; else if(a >= 1.0f) return M_PI_2_F; @@ -114,15 +114,20 @@ __device float svm_math(NodeMath type, float Fac1, float Fac2) return Fac; } +__device float average_fac(float3 v) +{ + return (fabsf(v.x) + fabsf(v.y) + fabsf(v.z))/3.0f; +} + __device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, float3 Vector1, float3 Vector2) { if(type == NODE_VECTOR_MATH_ADD) { *Vector = Vector1 + Vector2; - *Fac = (fabsf(Vector->x) + fabsf(Vector->y) + fabsf(Vector->z))/3.0f; + *Fac = average_fac(*Vector); } else if(type == NODE_VECTOR_MATH_SUBTRACT) { *Vector = Vector1 - Vector2; - *Fac = (fabsf(Vector->x) + fabsf(Vector->y) + fabsf(Vector->z))/3.0f; + *Fac = average_fac(*Vector); } else if(type == NODE_VECTOR_MATH_AVERAGE) { *Fac = len(Vector1 + Vector2); -- cgit v1.2.3