23 return p.
x *
X + p.
y *
Y;
29 return p.
x *
X + p.
y *
Y + p.
z *
Z;
77#ifdef __KERNEL_METAL__
82 return (a *
b).xyz +
make_float3(t->x.w, t->y.w, t->z.w);
88#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
93 float4 w(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f));
94 _MM_TRANSPOSE4_PS(
x.m128,
y.m128,
z.m128,
w.m128);
96 tmp =
madd(shuffle<2>(aa),
z, tmp);
97 tmp =
madd(shuffle<1>(aa),
y, tmp);
98 tmp =
madd(shuffle<0>(aa),
x, tmp);
108#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
115 float4 w(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f));
116 _MM_TRANSPOSE4_PS(
x.m128,
y.m128,
z.m128,
w.m128);
122 tmp =
madd(shuffle<2>(aa),
z, tmp);
123 tmp =
madd(shuffle<1>(aa),
y, tmp);
124 tmp =
madd(shuffle<0>(aa),
x, tmp);
125 result.val =
float3(tmp.m128);
130 tmp = shuffle<2>(dx) *
z;
131 tmp =
madd(shuffle<1>(dx),
y, tmp);
132 tmp =
madd(shuffle<0>(dx),
x, tmp);
133 result.dx =
float3(tmp.m128);
138 tmp = shuffle<2>(dy) *
z;
139 tmp =
madd(shuffle<1>(dy),
y, tmp);
140 tmp =
madd(shuffle<0>(dy),
x, tmp);
141 result.dy =
float3(tmp.m128);
153#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
159 _MM_TRANSPOSE4_PS(
x.m128,
y.m128,
z.m128,
w.m128);
160 float4 tmp = shuffle<2>(aa) *
z;
161 tmp =
madd(shuffle<1>(aa),
y, tmp);
162 tmp =
madd(shuffle<0>(aa),
x, tmp);
229 const float cx =
cosf(euler.
x);
230 const float cy =
cosf(euler.
y);
231 const float cz =
cosf(euler.
z);
232 const float sx =
sinf(euler.
x);
233 const float sy =
sinf(euler.
y);
234 const float sz =
sinf(euler.
z);
241 t.
x.
y = sy * sx * cz - cx * sz;
242 t.
y.
y = sy * sx * sz + cx * cz;
245 t.
x.
z = sy * cx * cz + sx * sz;
246 t.
y.
z = sy * cx * sz - sx * cz;
249 t.
x.
w = t.
y.
w = t.
z.
w = 0.0f;
260 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);
263#if !defined(__KERNEL_METAL__)
286#ifndef __KERNEL_GPU__
298 return make_transform(1, 0, 0, t.
x, 0, 1, 0, t.
y, 0, 0, 1, t.
z);
315 return make_transform(s.
x, 0, 0, 0, 0, s.
y, 0, 0, 0, 0, s.
z, 0);
327 const float t = 1.0f - c;
332 axis.
x * axis.
y * t - s * axis.
z,
333 axis.
x * axis.
z * t + s * axis.
y,
336 axis.
y * axis.
x * t + s * axis.
z,
337 axis.
y * axis.
y * t + c,
338 axis.
y * axis.
z * t - s * axis.
x,
341 axis.
z * axis.
x * t - s * axis.
y,
342 axis.
z * axis.
y * t + s * axis.
x,
343 axis.
z * axis.
z * t + c,
374 const float threshold)
376 for (
int x = 0;
x < 3;
x++) {
377 for (
int y = 0;
y < 4;
y++) {
394 t->
x[column] = value.
x;
395 t->
y[column] = value.
y;
396 t->
z[column] = value.
z;
410 const float eps = 1e-6f;
435 return (
dot(
cross(c0, c1), c2) < 0.0f);
451 return make_transform(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
461#if defined(__KERNEL_GPU_RAYTRACING__)
462 return normalize((1.0f - t) * q1 + t * q2);
466 const float costheta =
dot(q1, q2);
470 if (costheta > 0.9995f) {
472 return normalize((1.0f - t) * q1 + t * q2);
475 const float theta =
acosf(
clamp(costheta, -1.0f, 1.0f));
477 const float thetap = theta * t;
478 return q1 *
cosf(thetap) + qperp *
sinf(thetap);
483#ifndef __KERNEL_GPU__
493#if defined(__AVX2__) && defined(__KERNEL_SSE2__)
494 const __m128 a = (
const __m128 &)a_;
495 const __m128
b = (
const __m128 &)b_;
496 const __m128 a_shuffle = _mm_castsi128_ps(
497 _mm_shuffle_epi32(_mm_castps_si128(a), _MM_SHUFFLE(3, 0, 2, 1)));
498 const __m128 b_shuffle = _mm_castsi128_ps(
499 _mm_shuffle_epi32(_mm_castps_si128(
b), _MM_SHUFFLE(3, 0, 2, 1)));
500 const __m128 r = _mm_castsi128_ps(
501 _mm_shuffle_epi32(_mm_castps_si128(_mm_fmsub_ps(a, b_shuffle, _mm_mul_ps(a_shuffle,
b))),
502 _MM_SHUFFLE(3, 0, 2, 1)));
506 return cross(a_, b_);
511#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__)
512 const __m128 a = (
const __m128 &)a_;
513 const __m128
b = (
const __m128 &)b_;
514 return _mm_cvtss_f32(_mm_dp_ps(a,
b, 0x7F));
566#ifndef __KERNEL_GPU__
621 dot(rotation_x, scale_x),
dot(rotation_x, scale_y),
dot(rotation_x, scale_z), decomp->y.x);
623 dot(rotation_y, scale_x),
dot(rotation_y, scale_y),
dot(rotation_y, scale_z), decomp->y.y);
625 dot(rotation_z, scale_x),
dot(rotation_z, scale_y),
dot(rotation_z, scale_z), decomp->y.z);
635 const int maxstep = numsteps - 1;
636 const int step =
min((
int)(time * maxstep), maxstep - 1);
637 const float t = time * maxstep -
step;
645 decomp.
y = (1.0f - t) * a->
y + t *
b->y;
646 decomp.
z = (1.0f - t) * a->
z + t *
b->z;
647 decomp.
w = (1.0f - t) * a->
w + t *
b->w;
664#ifndef __KERNEL_GPU__
703 "PackedTransform expected to have the same alignment as float");
704static_assert(
sizeof(
PackedTransform) == 48,
"packed_float4 expected to be exactly 48 bytes");
709 tfm.
x = packed_tfm.
x;
710 tfm.
y = packed_tfm.
y;
711 tfm.
z = packed_tfm.
z;
718#define transform_point_auto transform_point
719#define transform_direction_auto transform_direction
720#define transform_direction_transposed_auto transform_direction_transposed
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.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
#define ccl_device_forceinline
#define ccl_device_inline
#define ccl_device_inline_method
#define CCL_NAMESPACE_END
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, 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
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline Extrema< T > operator*(const Extrema< T > a, const T b)
ccl_device_inline bool isfinite_safe(const float f)
ccl_device_inline dual1 len_squared(const ccl_private dual< T > &a)
CCL_NAMESPACE_BEGIN ccl_device_inline float madd(const float a, const float b, const float c)
ccl_device_inline bool operator!=(const float2 a, const float2 b)
ccl_device_inline bool operator==(const float2 a, const float2 b)
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ccl_device_inline_method dual< float > x() const
ccl_device_inline_method dual< float > y() const
ccl_device_inline_method dual< float > z() const
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)