Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Vec8.inl
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#include <Jolt/Math/UVec8.h>
6
8
10 mValue(_mm256_insertf128_ps(_mm256_castps128_ps256(inLo.mValue), inHi.mValue, 1))
11{
12}
13
15{
16 return _mm256_setzero_ps();
17}
18
20{
21 return _mm256_set1_ps(inV);
22}
23
25{
26 return _mm256_set1_ps(inV.GetX());
27}
28
30{
31 return _mm256_set1_ps(inV.GetY());
32}
33
35{
36 return _mm256_set1_ps(inV.GetZ());
37}
38
40{
41#ifdef JPH_USE_FMADD
42 return _mm256_fmadd_ps(inMul1.mValue, inMul2.mValue, inAdd.mValue);
43#else
44 return _mm256_add_ps(_mm256_mul_ps(inMul1.mValue, inMul2.mValue), inAdd.mValue);
45#endif
46}
47
49{
50 return _mm256_blendv_ps(inV1.mValue, inV2.mValue, _mm256_castsi256_ps(inControl.mValue));
51}
52
54{
55 return _mm256_min_ps(inV1.mValue, inV2.mValue);
56}
57
59{
60 return _mm256_max_ps(inV1.mValue, inV2.mValue);
61}
62
64{
65 return _mm256_castps_si256(_mm256_cmp_ps(inV1.mValue, inV2.mValue, _CMP_LT_OQ));
66}
67
69{
70 return _mm256_castps_si256(_mm256_cmp_ps(inV1.mValue, inV2.mValue, _CMP_GT_OQ));
71}
72
73Vec8 Vec8::sLoadFloat8(const float *inV)
74{
75 return _mm256_loadu_ps(inV);
76}
77
79{
80 return _mm256_load_ps(inV);
81}
82
84{
85 return _mm256_mul_ps(mValue, inV2.mValue);
86}
87
88Vec8 Vec8::operator * (float inV2) const
89{
90 return _mm256_mul_ps(mValue, _mm256_set1_ps(inV2));
91}
92
94{
95 return _mm256_add_ps(mValue, inV2.mValue);
96}
97
99{
100 return _mm256_sub_ps(mValue, inV2.mValue);
101}
102
104{
105 return _mm256_div_ps(mValue, inV2.mValue);
106}
107
109{
110 return Vec8::sReplicate(1.0f) / mValue;
111}
112
113template<uint32 SwizzleX, uint32 SwizzleY, uint32 SwizzleZ, uint32 SwizzleW>
115{
116 static_assert(SwizzleX <= 3, "SwizzleX template parameter out of range");
117 static_assert(SwizzleY <= 3, "SwizzleY template parameter out of range");
118 static_assert(SwizzleZ <= 3, "SwizzleZ template parameter out of range");
119 static_assert(SwizzleW <= 3, "SwizzleW template parameter out of range");
120
121 return _mm256_shuffle_ps(mValue, mValue, _MM_SHUFFLE(SwizzleW, SwizzleZ, SwizzleY, SwizzleX));
122}
123
125{
126#if defined(JPH_USE_AVX512)
127 return _mm256_range_ps(mValue, mValue, 0b1000);
128#else
129 return _mm256_max_ps(_mm256_sub_ps(_mm256_setzero_ps(), mValue), mValue);
130#endif
131}
132
134{
135 return _mm256_castps256_ps128(mValue);
136}
137
139{
140 return _mm256_extractf128_ps(mValue, 1);
141}
142
143float Vec8::ReduceMin() const
144{
146}
147
#define JPH_NAMESPACE_END
Definition Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
Definition UVec8.h:12
__m256i mValue
Definition UVec8.h:91
Definition Vec4.h:14
static JPH_INLINE Vec4 sMin(Vec4Arg inV1, Vec4Arg inV2)
Return the minimum value of each of the components.
Definition Vec4.inl:138
JPH_INLINE float GetX() const
Get individual components.
Definition Vec4.h:112
JPH_INLINE float ReduceMin() const
Get the minimum of X, Y, Z and W.
Definition Vec4.inl:758
JPH_INLINE float GetZ() const
Definition Vec4.h:114
JPH_INLINE float GetY() const
Definition Vec4.h:113
Definition Vec8.h:12
static JPH_INLINE Vec8 sFusedMultiplyAdd(Vec8Arg inMul1, Vec8Arg inMul2, Vec8Arg inAdd)
Calculates inMul1 * inMul2 + inAdd.
Definition Vec8.inl:39
JPH_INLINE float ReduceMin() const
Get the minimum value of the 8 floats.
Definition Vec8.inl:143
JPH_INLINE Vec4 UpperVec4() const
Fetch the higher 128 bit from a 256 bit variable.
Definition Vec8.inl:138
static JPH_INLINE UVec8 sLess(Vec8Arg inV1, Vec8Arg inV2)
Less than.
Definition Vec8.inl:63
JPH_INLINE Vec8 Reciprocal() const
Reciprocal vector.
Definition Vec8.inl:108
static JPH_INLINE Vec8 sSplatX(Vec4Arg inV)
Replicate the X component of inV to all components.
Definition Vec8.inl:24
JPH_INLINE Vec8 operator-(Vec8Arg inV2) const
Subtract two float vectors.
Definition Vec8.inl:98
JPH_INLINE Vec8 Abs() const
Get absolute value of all components.
Definition Vec8.inl:124
static JPH_INLINE Vec8 sSplatY(Vec4Arg inV)
Replicate the Y component of inV to all components.
Definition Vec8.inl:29
static JPH_INLINE Vec8 sMax(Vec8Arg inV1, Vec8Arg inV2)
Component wise max.
Definition Vec8.inl:58
JPH_INLINE Vec8 operator/(Vec8Arg inV2) const
Divide.
Definition Vec8.inl:103
JPH_INLINE Vec8 operator*(Vec8Arg inV2) const
Multiply two float vectors.
Definition Vec8.inl:83
static JPH_INLINE Vec8 sLoadFloat8Aligned(const float *inV)
Load 8 floats from memory, 32 bytes aligned.
Definition Vec8.inl:78
static JPH_INLINE UVec8 sGreater(Vec8Arg inV1, Vec8Arg inV2)
Greater than.
Definition Vec8.inl:68
static JPH_INLINE Vec8 sZero()
Vector with all zeros.
Definition Vec8.inl:14
JPH_OVERRIDE_NEW_DELETE Vec8()=default
Constructor.
JPH_INLINE Vec4 LowerVec4() const
Fetch the lower 128 bit from a 256 bit variable.
Definition Vec8.inl:133
static JPH_INLINE Vec8 sSelect(Vec8Arg inV1, Vec8Arg inV2, UVec8Arg inControl)
Component wise select, returns inV1 when highest bit of inControl = 0 and inV2 when highest bit of in...
Definition Vec8.inl:48
static JPH_INLINE Vec8 sMin(Vec8Arg inV1, Vec8Arg inV2)
Component wise min.
Definition Vec8.inl:53
static JPH_INLINE Vec8 sSplatZ(Vec4Arg inV)
Replicate the Z component of inV to all components.
Definition Vec8.inl:34
__m256 mValue
Definition Vec8.h:103
JPH_INLINE Vec8 operator+(Vec8Arg inV2) const
Add two float vectors.
Definition Vec8.inl:93
static JPH_INLINE Vec8 sLoadFloat8(const float *inV)
Load from memory.
Definition Vec8.inl:73
JPH_INLINE Vec8 Swizzle() const
256 bit variant of Vec::Swizzle (no cross 128 bit lane swizzle)
static JPH_INLINE Vec8 sReplicate(float inV)
Replicate across all components.
Definition Vec8.inl:19