4 #ifndef __UTIL_MATH_FLOAT4_H__
5 #define __UTIL_MATH_FLOAT4_H__
7 #ifndef __UTIL_MATH_H__
8 # error "Do not include this file directly, include util/types.h instead."
17 #if !defined(__KERNEL_METAL__)
62 template<
size_t index_0,
size_t index_1,
size_t index_2,
size_t index_3>
64 template<
size_t index_0,
size_t index_1,
size_t index_2,
size_t index_3>
72 # ifdef __KERNEL_SSE3__
84 #ifndef __KERNEL_GPU__
95 return float4(_mm_setzero_ps());
106 #if !defined(__KERNEL_METAL__)
109 # ifdef __KERNEL_SSE__
110 __m128
mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
119 # ifdef __KERNEL_SSE__
120 return float4(_mm_mul_ps(
a.m128,
b.m128));
128 # if defined(__KERNEL_SSE__)
142 return a * (1.0f / f);
147 # ifdef __KERNEL_SSE__
148 return float4(_mm_div_ps(
a.m128,
b.m128));
161 # ifdef __KERNEL_SSE__
162 return float4(_mm_add_ps(
a.m128,
b.m128));
175 # ifdef __KERNEL_SSE__
176 return float4(_mm_sub_ps(
a.m128,
b.m128));
209 # ifdef __KERNEL_SSE__
210 return int4(_mm_castps_si128(_mm_cmplt_ps(
a.m128,
b.m128)));
218 # ifdef __KERNEL_SSE__
219 return int4(_mm_castps_si128(_mm_cmpge_ps(
a.m128,
b.m128)));
227 # ifdef __KERNEL_SSE__
228 return int4(_mm_castps_si128(_mm_cmple_ps(
a.m128,
b.m128)));
236 # ifdef __KERNEL_SSE__
237 return (_mm_movemask_ps(_mm_cmpeq_ps(
a.m128,
b.m128)) & 15) == 15;
239 return (
a.x ==
b.x &&
a.y ==
b.y &&
a.z ==
b.z &&
a.w ==
b.w);
250 # if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
251 # if defined(__KERNEL_NEON__)
252 __m128
t = vmulq_f32(
a,
b);
253 return vaddvq_f32(
t);
255 return _mm_cvtss_f32(_mm_dp_ps(
a,
b, 0xFF));
258 return (
a.x *
b.x +
a.y *
b.y) + (
a.z *
b.z +
a.w *
b.w);
269 # ifdef __KERNEL_SSE__
271 return float4(_mm_div_ps(_mm_set_ps1(1.0f),
a.m128));
279 # ifdef __KERNEL_SSE__
280 return float4(_mm_sqrt_ps(
a.m128));
293 # ifdef __KERNEL_SSE__
294 return (shuffle<1, 2, 0, 0>(
a) * shuffle<2, 0, 1, 0>(
b)) -
295 (shuffle<2, 0, 1, 0>(
a) * shuffle<1, 2, 0, 0>(
b));
303 # ifdef __KERNEL_SSE__
306 return (
a.x == 0.0f &&
a.y == 0.0f &&
a.z == 0.0f &&
a.w == 0.0f);
328 return (
t != 0.0f) ?
a /
t :
a;
333 # ifdef __KERNEL_SSE__
334 return float4(_mm_min_ps(
a.m128,
b.m128));
342 # ifdef __KERNEL_SSE__
343 return float4(_mm_max_ps(
a.m128,
b.m128));
356 # if defined(__KERNEL_SSE__)
357 # if defined(__KERNEL_NEON__)
360 return float4(_mm_and_ps(
a.m128, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff))));
369 # ifdef __KERNEL_SSE__
370 return float4(_mm_floor_ps(
a));
378 return a +
t * (
b -
a);
400 #if defined(__KERNEL_SSE__)
401 # if defined(__KERNEL_NEON__)
402 return vaddvq_f32(
a);
403 # elif defined(__KERNEL_SSE3__)
404 float4 h(_mm_hadd_ps(
a.m128,
a.m128));
405 return _mm_cvtss_f32(_mm_hadd_ps(h.m128, h.m128));
407 float4 h(shuffle<1, 0, 3, 2>(
a) +
a);
408 return _mm_cvtss_f32(shuffle<2, 3, 0, 1>(h) + h);
411 return a.x +
a.y +
a.z +
a.w;
417 #if defined(__KERNEL_SSE__)
418 # if defined(__KERNEL_NEON__)
419 return vminvq_f32(
a);
422 return _mm_cvtss_f32(
min(shuffle<2, 3, 0, 1>(h), h));
431 #if defined(__KERNEL_SSE__)
432 # if defined(__KERNEL_NEON__)
433 return vmaxvq_f32(
a);
436 return _mm_cvtss_f32(
max(shuffle<2, 3, 0, 1>(h), h));
445 #if defined(__KERNEL_METAL__)
452 #ifdef __KERNEL_SSE__
453 template<
size_t index_0,
size_t index_1,
size_t index_2,
size_t index_3>
456 # if defined(__KERNEL_NEON__)
457 return float4(shuffle_neon<__m128, index_0, index_1, index_2, index_3>(
b.m128));
459 return float4(_mm_castsi128_ps(
460 _mm_shuffle_epi32(_mm_castps_si128(
b), _MM_SHUFFLE(index_3, index_2, index_1, index_0))));
464 template<
size_t index_0,
size_t index_1,
size_t index_2,
size_t index_3>
467 # if defined(__KERNEL_NEON__)
468 return float4(shuffle_neon<__m128, index_0, index_1, index_2, index_3>(
a.m128,
b.m128));
470 return float4(_mm_shuffle_ps(
a.m128,
b.m128, _MM_SHUFFLE(index_3, index_2, index_1, index_0)));
476 return float4(_mm_castpd_ps(_mm_movedup_pd(_mm_castps_pd(
b))));
481 return float4(_mm_movelh_ps(
a.m128,
b.m128));
486 return float4(_mm_movehl_ps(
b.m128,
a.m128));
489 # ifdef __KERNEL_SSE3__
492 return float4(_mm_moveldup_ps(
b));
497 return float4(_mm_movehdup_ps(
b));
502 #ifndef __KERNEL_GPU__
505 # ifdef __KERNEL_SSE__
506 return float4(_mm_blendv_ps(
b.m128,
a.m128, _mm_castsi128_ps(
mask.m128)));
521 # ifdef __KERNEL_SSE__
522 return float4(_mm_loadu_ps(
v));
538 (
b.y != 0.0f) ?
a.y /
b.y : 0.0f,
539 (
b.z != 0.0f) ?
a.z /
b.z : 0.0f,
540 (
b.w != 0.0f) ?
a.w /
b.w : 0.0f);
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
__forceinline bool all(const avxb &b)
__forceinline const avxi shuffle< 0, 0, 2, 2 >(const avxi &b)
__forceinline const avxi shuffle< 0, 1, 0, 1 >(const avxi &b)
__forceinline const avxi shuffle< 1, 1, 3, 3 >(const avxi &b)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
#define ccl_device_inline
#define CCL_NAMESPACE_END
static void shuffle(float2 points[], int size, int rng_seed)
ccl_device_inline float len_squared(const float4 &a)
ccl_device_inline float4 operator+=(float4 &a, const float4 &b)
ccl_device_inline bool operator==(const float4 &a, const float4 &b)
ccl_device_inline float4 safe_normalize(const float4 &a)
ccl_device_inline float4 normalize(const float4 &a)
ccl_device_inline float4 one_float4()
ccl_device_inline float4 pow(float4 v, float e)
ccl_device_inline float reduce_add(const float4 a)
ccl_device_inline int4 operator<(const float4 &a, const float4 &b)
ccl_device_inline float4 rcp(const float4 &a)
ccl_device_inline float4 operator+(const float4 &a, const float f)
CCL_NAMESPACE_BEGIN ccl_device_inline float4 operator-(const float4 &a)
ccl_device_inline bool isfinite_safe(float4 v)
ccl_device_inline float4 saturate(const float4 &a)
ccl_device_inline int4 operator>=(const float4 &a, const float4 &b)
ccl_device_inline int4 operator<=(const float4 &a, const float4 &b)
ccl_device_inline float4 zero_float4()
ccl_device_inline float distance(const float4 &a, const float4 &b)
ccl_device_inline float4 floor(const float4 &a)
ccl_device_inline float4 load_float4(ccl_private const float *v)
ccl_device_inline float len(const float4 &a)
ccl_device_inline float4 operator*(const float4 &a, const float4 &b)
ccl_device_inline float4 sqrt(const float4 &a)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
ccl_device_inline float4 sqr(const float4 &a)
ccl_device_inline float4 fabs(const float4 &a)
ccl_device_inline float average(const float4 &a)
ccl_device_inline bool isequal(const float4 a, const float4 b)
ccl_device_inline float4 mix(const float4 &a, const float4 &b, float t)
ccl_device_inline float4 safe_divide(const float4 a, const float4 b)
ccl_device_inline float reduce_max(const float4 a)
ccl_device_inline float4 ensure_finite(float4 v)
ccl_device_inline float4 min(const float4 &a, const float4 &b)
ccl_device_inline float4 exp(float4 v)
ccl_device_inline float dot(const float4 &a, const float4 &b)
ccl_device_inline bool is_zero(const float4 &a)
ccl_device_inline float4 select(const int4 &mask, const float4 &a, const float4 &b)
ccl_device_inline float4 operator*=(float4 &a, const float4 &b)
ccl_device_inline float4 operator-=(float4 &a, const float4 &b)
ccl_device_inline float4 cross(const float4 &a, const float4 &b)
ccl_device_inline float reduce_min(const float4 a)
ccl_device_inline float4 log(float4 v)
ccl_device_inline float4 clamp(const float4 &a, const float4 &mn, const float4 &mx)
ccl_device_inline float4 max(const float4 &a, const float4 &b)
ccl_device_inline float4 operator/=(float4 &a, float f)
ccl_device_inline float4 operator/(const float4 &a, float f)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
ccl_device_inline float saturatef(float a)