47#ifdef __KERNEL_METAL__
52 return (a *
b).xyz +
make_float3(t->x.w, t->y.w, t->z.w);
58#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
63 float4 w(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f));
64 _MM_TRANSPOSE4_PS(
x.m128,
y.m128,
z.m128,
w.m128);
66 tmp =
madd(shuffle<2>(aa),
z, tmp);
67 tmp =
madd(shuffle<1>(aa),
y, tmp);
68 tmp =
madd(shuffle<0>(aa),
x, tmp);
70#elif defined(__KERNEL_METAL__)
72 return (a *
b).xyz +
make_float3(t->x.w, t->y.w, t->z.w);
81#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
88 float4 w(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f));
89 _MM_TRANSPOSE4_PS(
x.m128,
y.m128,
z.m128,
w.m128);
95 tmp =
madd(shuffle<2>(aa),
z, tmp);
96 tmp =
madd(shuffle<1>(aa),
y, tmp);
97 tmp =
madd(shuffle<0>(aa),
x, tmp);
103 tmp = shuffle<2>(dx) *
z;
104 tmp =
madd(shuffle<1>(dx),
y, tmp);
105 tmp =
madd(shuffle<0>(dx),
x, tmp);
111 tmp = shuffle<2>(dy) *
z;
112 tmp =
madd(shuffle<1>(dy),
y, tmp);
113 tmp =
madd(shuffle<0>(dy),
x, tmp);
118#elif defined(__KERNEL_METAL__)
129#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
135 _MM_TRANSPOSE4_PS(
x.m128,
y.m128,
z.m128,
w.m128);
136 float4 tmp = shuffle<2>(aa) *
z;
137 tmp =
madd(shuffle<1>(aa),
y, tmp);
138 tmp =
madd(shuffle<0>(aa),
x, tmp);
140#elif defined(__KERNEL_METAL__)
203 const float cx =
cosf(euler.
x);
204 const float cy =
cosf(euler.
y);
205 const float cz =
cosf(euler.
z);
206 const float sx =
sinf(euler.
x);
207 const float sy =
sinf(euler.
y);
208 const float sz =
sinf(euler.
z);
215 t.
x.
y = sy * sx * cz - cx * sz;
216 t.
y.
y = sy * sx * sz + cx * cz;
219 t.
x.
z = sy * cx * cz + sx * sz;
220 t.
y.
z = sy * cx * sz - sx * cz;
223 t.
x.
w = t.
y.
w = t.
z.
w = 0.0f;
234 return make_transform(dx.
x, dx.
y, dx.
z, 0.0f, dy.
x, dy.
y, dy.
z, 0.0f,
N.x,
N.y,
N.z, 0.0f);
237#if !defined(__KERNEL_METAL__)
260#ifndef __KERNEL_GPU__
272 return make_transform(1, 0, 0, t.
x, 0, 1, 0, t.
y, 0, 0, 1, t.
z);
282 return make_transform(s.
x, 0, 0, 0, 0, s.
y, 0, 0, 0, 0, s.
z, 0);
294 const float t = 1.0f - c;
299 axis.
x * axis.
y * t - s * axis.
z,
300 axis.
x * axis.
z * t + s * axis.
y,
303 axis.
y * axis.
x * t + s * axis.
z,
304 axis.
y * axis.
y * t + c,
305 axis.
y * axis.
z * t - s * axis.
x,
308 axis.
z * axis.
x * t - s * axis.
y,
309 axis.
z * axis.
y * t + s * axis.
x,
310 axis.
z * axis.
z * t + c,
341 const float threshold)
343 for (
int x = 0;
x < 3;
x++) {
344 for (
int y = 0;
y < 4;
y++) {
361 t->
x[column] = value.
x;
362 t->
y[column] = value.
y;
363 t->
z[column] = value.
z;
372 const float eps = 1e-6f;
397 return (
dot(
cross(c0, c1), c2) < 0.0f);
413 return make_transform(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
423#if defined(__KERNEL_GPU_RAYTRACING__)
424 return normalize((1.0f - t) * q1 + t * q2);
428 const float costheta =
dot(q1, q2);
432 if (costheta > 0.9995f) {
434 return normalize((1.0f - t) * q1 + t * q2);
437 const float theta =
acosf(
clamp(costheta, -1.0f, 1.0f));
439 const float thetap = theta * t;
440 return q1 *
cosf(thetap) + qperp *
sinf(thetap);
445#ifndef __KERNEL_GPU__
455#if defined(__AVX2__) && defined(__KERNEL_SSE2__)
456 const __m128 a = (
const __m128 &)a_;
457 const __m128
b = (
const __m128 &)b_;
458 const __m128 a_shuffle = _mm_castsi128_ps(
459 _mm_shuffle_epi32(_mm_castps_si128(a), _MM_SHUFFLE(3, 0, 2, 1)));
460 const __m128 b_shuffle = _mm_castsi128_ps(
461 _mm_shuffle_epi32(_mm_castps_si128(
b), _MM_SHUFFLE(3, 0, 2, 1)));
462 const __m128 r = _mm_castsi128_ps(
463 _mm_shuffle_epi32(_mm_castps_si128(_mm_fmsub_ps(a, b_shuffle, _mm_mul_ps(a_shuffle,
b))),
464 _MM_SHUFFLE(3, 0, 2, 1)));
468 return cross(a_, b_);
473#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__)
474 const __m128 a = (
const __m128 &)a_;
475 const __m128
b = (
const __m128 &)b_;
476 return _mm_cvtss_f32(_mm_dp_ps(a,
b, 0x7F));
528#ifndef __KERNEL_GPU__
583 dot(rotation_x, scale_x),
dot(rotation_x, scale_y),
dot(rotation_x, scale_z), decomp->y.x);
585 dot(rotation_y, scale_x),
dot(rotation_y, scale_y),
dot(rotation_y, scale_z), decomp->y.y);
587 dot(rotation_z, scale_x),
dot(rotation_z, scale_y),
dot(rotation_z, scale_z), decomp->y.z);
597 const int maxstep = numsteps - 1;
598 const int step =
min((
int)(time * maxstep), maxstep - 1);
599 const float t = time * maxstep -
step;
607 decomp.
y = (1.0f - t) * a->
y + t *
b->y;
608 decomp.
z = (1.0f - t) * a->
z + t *
b->z;
609 decomp.
w = (1.0f - t) * a->
w + t *
b->w;
626#ifndef __KERNEL_GPU__
646#define transform_point_auto transform_point
647#define transform_direction_auto transform_direction
648#define transform_direction_transposed_auto transform_direction_transposed
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
#define ccl_device_forceinline
#define ccl_device_inline
#define CCL_NAMESPACE_END
VecBase< float, D > normalize(VecOp< float, D >) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
constexpr T clamp(T, U, U) RET
VecBase< float, 3 > float3
ccl_device_inline bool isfinite_safe(const float f)
CCL_NAMESPACE_BEGIN ccl_device_inline float madd(const float a, const float b, const float c)
ccl_device_inline float len_squared(const float2 a)
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
bool system_cpu_support_avx2()
ccl_device_inline dual4 make_homogeneous(const dual3 a)
ccl_device_inline void print_float4(const ccl_private char *label, const float4 a)