6#ifndef __UTIL_MATH_FLOAT3_H__
7#define __UTIL_MATH_FLOAT3_H__
10# error "Do not include this file directly, include util/types.h instead."
18 return float3(_mm_setzero_ps());
29#if defined(__KERNEL_METAL__)
41 return float3(_mm_xor_ps(a.m128, _mm_castsi128_ps(_mm_set1_epi32(0x80000000))));
50 return float3(_mm_mul_ps(a.m128,
b.m128));
59 return float3(_mm_mul_ps(a.m128, _mm_set1_ps(f)));
67# if defined(__KERNEL_SSE__)
68 return float3(_mm_mul_ps(_mm_set1_ps(f), a.m128));
76# if defined(__KERNEL_SSE__)
77 return float3(_mm_div_ps(_mm_set1_ps(f), a.m128));
85# if defined(__KERNEL_SSE__)
86 return float3(_mm_div_ps(a.m128, _mm_set1_ps(f)));
88 float invf = 1.0f / f;
95# if defined(__KERNEL_SSE__)
96 return float3(_mm_div_ps(a.m128,
b.m128));
104# ifdef __KERNEL_SSE__
105 return float3(_mm_add_ps(a.m128,
b.m128));
118# ifdef __KERNEL_SSE__
119 return float3(_mm_sub_ps(a.m128,
b.m128));
157 float invf = 1.0f / f;
161# if !(defined(__KERNEL_METAL__) || defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__) || \
162 defined(__KERNEL_ONEAPI__))
190# ifdef __KERNEL_SSE__
191 return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128,
b.m128)) & 7) == 7;
193 return (a.
x ==
b.x && a.
y ==
b.y && a.
z ==
b.z);
204# if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
205 return _mm_cvtss_f32(_mm_dp_ps(a,
b, 0x7F));
207 return a.
x *
b.x + a.
y *
b.y + a.
z *
b.z;
215#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
216 return _mm_cvtss_f32(_mm_hadd_ps(_mm_mul_ps(a,
b),
b));
218 return a.
x *
b.x + a.
y *
b.y;
224#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
225 return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(a.m128, a.m128, 0x7F)));
246#ifndef __KERNEL_METAL__
255# ifdef __KERNEL_SSE__
268# if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
269 __m128
norm = _mm_sqrt_ps(_mm_dp_ps(a.m128, a.m128, 0x7F));
278# ifdef __KERNEL_SSE__
279 return float3(_mm_min_ps(a.m128,
b.m128));
287# ifdef __KERNEL_SSE__
288 return float3(_mm_max_ps(a.m128,
b.m128));
296 return min(
max(a, mn), mx);
301# ifdef __KERNEL_SSE__
302# ifdef __KERNEL_NEON__
303 return float3(vabsq_f32(a.m128));
305 __m128
mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));
320# ifdef __KERNEL_SSE__
321 return float3(_mm_sqrt_ps(a));
329# ifdef __KERNEL_SSE__
330 return float3(_mm_floor_ps(a));
338# ifdef __KERNEL_SSE__
339 return float3(_mm_ceil_ps(a));
347 return a + t * (
b - a);
352# ifdef __KERNEL_SSE__
354 return float3(_mm_div_ps(_mm_set_ps1(1.0f), a.m128));
382 return incident - 2.0f * unit_normal *
dot(incident, unit_normal);
387 float k = 1.0f - eta * eta * (1.0f -
dot(normal, incident) *
dot(normal, incident));
391 return eta * incident - (eta *
dot(normal, incident) +
sqrt(k)) * normal;
418 return (t != 0.0f) ? a * (1.0f / t) : a;
424 return (t != 0.0f) ? a * (1.0f / t) : fallback;
430 return (*t != 0.0f) ? a / (*t) : a;
436 (
b.y != 0.0f) ? a.
y /
b.y : 0.0f,
437 (
b.z != 0.0f) ? a.
z /
b.z : 0.0f);
447 return a + t * (
b - a);
460 return (a.
x == 0.0f && a.
y == 0.0f && a.
z == 0.0f);
466#if defined(__KERNEL_SSE__) && defined(__KERNEL_NEON__)
468 t = vsetq_lane_f32(0.0f, t, 3);
469 return vaddvq_f32(t);
471 return (a.
x + a.
y + a.
z);
482#if defined(__KERNEL_METAL__)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
VecBase< float, 3 > float3
local_group_size(16, 16) .push_constant(Type b
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_device_inline float len_squared(const float2 a)
ccl_device_inline float3 sqrt(const float3 a)
ccl_device_inline float3 safe_normalize(const float3 a)
ccl_device_inline bool is_zero(const float3 a)
ccl_device_inline float3 floor(const float3 a)
ccl_device_inline float3 operator*(const float3 a, const float3 b)
ccl_device_inline bool isequal(const float3 a, const float3 b)
ccl_device_inline float3 safe_normalize_fallback(const float3 a, const float3 fallback)
ccl_device_inline float3 reflect(const float3 incident, const float3 unit_normal)
ccl_device_inline float3 refract(const float3 incident, const float3 normal, const float eta)
ccl_device_inline float3 cross(const float3 a, const float3 b)
ccl_device_inline float3 one_float3()
ccl_device_inline float3 exp(float3 v)
ccl_device_inline float reduce_min(float3 a)
ccl_device_inline float3 faceforward(const float3 vector, const float3 incident, const float3 reference)
ccl_device_inline float3 normalize_len(const float3 a, ccl_private float *t)
ccl_device_inline float3 clamp(const float3 a, const float3 mn, const float3 mx)
ccl_device_inline float3 project(const float3 v, const float3 v_proj)
ccl_device_inline float3 sqr(float3 a)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
ccl_device_inline float3 power(float3 v, float e)
ccl_device_inline float3 operator/=(float3 &a, const float3 b)
ccl_device_inline float dot_xy(const float3 a, const float3 b)
ccl_device_inline float3 fmod(const float3 a, const float b)
ccl_device_inline float3 fabs(const float3 a)
ccl_device_inline float reduce_add(const float3 a)
ccl_device_inline float reduce_max(float3 a)
ccl_device_inline float3 ceil(const float3 a)
ccl_device_inline float3 operator+(const float3 a, const float3 b)
ccl_device_inline float3 rcp(const float3 a)
ccl_device_inline float average(const float3 a)
ccl_device_inline float3 operator*=(float3 &a, const float3 b)
ccl_device_inline float3 operator/(const float f, const float3 a)
ccl_device_inline bool operator==(const float3 a, const float3 b)
ccl_device_inline float distance(const float3 a, const float3 b)
ccl_device_inline float3 safe_divide(const float3 a, const float3 b)
ccl_device_inline float3 operator-(const float3 &a)
ccl_device_inline bool isfinite_safe(float3 v)
ccl_device_inline float3 safe_normalize_len(const float3 a, ccl_private float *t)
ccl_device_inline float3 interp(float3 a, float3 b, float t)
ccl_device_inline float3 operator-=(float3 &a, const float3 b)
ccl_device_inline float3 cos(float3 v)
ccl_device_inline bool operator!=(const float3 a, const float3 b)
ccl_device_inline float3 operator+=(float3 &a, const float3 b)
ccl_device_inline float3 log(float3 v)
ccl_device_inline float dot(const float3 a, const float3 b)
ccl_device_inline float len_squared(const float3 a)
ccl_device_inline float3 ensure_finite(float3 v)
ccl_device_inline float4 msub(const float4 a, const float4 b, const float4 c)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
VecBase< float, 4 > float4