Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
UVec8.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
6
8 mValue(_mm256_insertf128_si256(_mm256_castsi128_si256(inLo.mValue), inHi.mValue, 1))
9{
10}
11
13{
14 return sEquals(*this, inV2).TestAllTrue();
15}
16
18{
19 return _mm256_set1_epi32(int(inV));
20}
21
23{
24 return _mm256_set1_epi32(inV.GetX());
25}
26
28{
29 return _mm256_set1_epi32(inV.GetY());
30}
31
33{
34 return _mm256_set1_epi32(inV.GetZ());
35}
36
38{
39#ifdef JPH_USE_AVX2
40 return _mm256_cmpeq_epi32(inV1.mValue, inV2.mValue);
41#else
42 return UVec8(UVec4::sEquals(inV1.LowerVec4(), inV2.LowerVec4()), UVec4::sEquals(inV1.UpperVec4(), inV2.UpperVec4()));
43#endif
44}
45
47{
48 return _mm256_castps_si256(_mm256_blendv_ps(_mm256_castsi256_ps(inV1.mValue), _mm256_castsi256_ps(inV2.mValue), _mm256_castsi256_ps(inControl.mValue)));
49}
50
52{
53 return _mm256_castps_si256(_mm256_or_ps(_mm256_castsi256_ps(inV1.mValue), _mm256_castsi256_ps(inV2.mValue)));
54}
55
57{
58 return _mm256_castps_si256(_mm256_xor_ps(_mm256_castsi256_ps(inV1.mValue), _mm256_castsi256_ps(inV2.mValue)));
59}
60
62{
63 return _mm256_castps_si256(_mm256_and_ps(_mm256_castsi256_ps(inV1.mValue), _mm256_castsi256_ps(inV2.mValue)));
64}
65
66template<uint32 SwizzleX, uint32 SwizzleY, uint32 SwizzleZ, uint32 SwizzleW>
68{
69 static_assert(SwizzleX <= 3, "SwizzleX template parameter out of range");
70 static_assert(SwizzleY <= 3, "SwizzleY template parameter out of range");
71 static_assert(SwizzleZ <= 3, "SwizzleZ template parameter out of range");
72 static_assert(SwizzleW <= 3, "SwizzleW template parameter out of range");
73
74 return _mm256_castps_si256(_mm256_shuffle_ps(_mm256_castsi256_ps(mValue), _mm256_castsi256_ps(mValue), _MM_SHUFFLE(SwizzleW, SwizzleZ, SwizzleY, SwizzleX)));
75}
76
78{
79 return _mm256_movemask_ps(_mm256_castsi256_ps(mValue)) != 0;
80}
81
83{
84 return _mm256_movemask_ps(_mm256_castsi256_ps(mValue)) == 0xff;
85}
86
88{
89 return _mm256_castsi256_si128(mValue);
90}
91
93{
94 return _mm_castps_si128(_mm256_extractf128_ps(_mm256_castsi256_ps(mValue), 1));
95}
96
98{
99 return _mm256_cvtepi32_ps(mValue);
100}
101
102template <const uint Count>
104{
105 static_assert(Count <= 31, "Invalid shift");
106
107#ifdef JPH_USE_AVX2
108 return _mm256_slli_epi32(mValue, Count);
109#else
110 return UVec8(LowerVec4().LogicalShiftLeft<Count>(), UpperVec4().LogicalShiftLeft<Count>());
111#endif
112}
113
114template <const uint Count>
116{
117 static_assert(Count <= 31, "Invalid shift");
118
119#ifdef JPH_USE_AVX2
120 return _mm256_srli_epi32(mValue, Count);
121#else
122 return UVec8(LowerVec4().LogicalShiftRight<Count>(), UpperVec4().LogicalShiftRight<Count>());
123#endif
124}
125
126template <const uint Count>
128{
129 static_assert(Count <= 31, "Invalid shift");
130
131#ifdef JPH_USE_AVX2
132 return _mm256_srai_epi32(mValue, Count);
133#else
134 return UVec8(LowerVec4().ArithmeticShiftRight<Count>(), UpperVec4().ArithmeticShiftRight<Count>());
135#endif
136}
137
#define JPH_NAMESPACE_END
Definition Core.h:354
std::uint32_t uint32
Definition Core.h:429
#define JPH_NAMESPACE_BEGIN
Definition Core.h:348
Definition UVec4.h:12
JPH_INLINE uint32 GetZ() const
Definition UVec4.h:104
JPH_INLINE uint32 GetY() const
Definition UVec4.h:103
static JPH_INLINE UVec4 sEquals(UVec4Arg inV1, UVec4Arg inV2)
Equals (component wise)
Definition UVec4.inl:138
JPH_INLINE uint32 GetX() const
Get individual components.
Definition UVec4.h:102
Definition UVec8.h:12
JPH_OVERRIDE_NEW_DELETE UVec8()=default
Intentionally not initialized for performance reasons.
JPH_INLINE UVec4 UpperVec4() const
Fetch the higher 128 bit from a 256 bit variable.
Definition UVec8.inl:92
static JPH_INLINE UVec8 sEquals(UVec8Arg inV1, UVec8Arg inV2)
Equals (component wise)
Definition UVec8.inl:37
static JPH_INLINE UVec8 sSplatZ(UVec4Arg inV)
Replicate the Z component of inV to all components.
Definition UVec8.inl:32
JPH_INLINE UVec8 Swizzle() const
256 bit variant of Vec::Swizzle (no cross 128 bit lane swizzle)
JPH_INLINE bool TestAllTrue() const
Test if all components are true (true is when highest bit of component is set)
Definition UVec8.inl:82
JPH_INLINE bool operator==(UVec8Arg inV2) const
Comparison.
Definition UVec8.inl:12
JPH_INLINE UVec8 ArithmeticShiftRight() const
Shift all components by Count bits to the right (shifting in the value of the highest bit)
JPH_INLINE UVec8 LogicalShiftRight() const
Shift all components by Count bits to the right (filling with zeros from the right)
static JPH_INLINE UVec8 sAnd(UVec8Arg inV1, UVec8Arg inV2)
Logical and.
Definition UVec8.inl:61
JPH_INLINE bool TestAnyTrue() const
Test if any of the components are true (true is when highest bit of component is set)
Definition UVec8.inl:77
static JPH_INLINE UVec8 sSplatY(UVec4Arg inV)
Replicate the Y component of inV to all components.
Definition UVec8.inl:27
static JPH_INLINE UVec8 sSplatX(UVec4Arg inV)
Replicate the X component of inV to all components.
Definition UVec8.inl:22
static JPH_INLINE UVec8 sReplicate(uint32 inV)
Replicate int across all components.
Definition UVec8.inl:17
__m256i mValue
Definition UVec8.h:91
static JPH_INLINE UVec8 sOr(UVec8Arg inV1, UVec8Arg inV2)
Logical or.
Definition UVec8.inl:51
JPH_INLINE UVec4 LowerVec4() const
Fetch the lower 128 bit from a 256 bit variable.
Definition UVec8.inl:87
static JPH_INLINE UVec8 sXor(UVec8Arg inV1, UVec8Arg inV2)
Logical xor.
Definition UVec8.inl:56
JPH_INLINE Vec8 ToFloat() const
Converts int to float.
Definition UVec8.inl:97
JPH_INLINE UVec8 LogicalShiftLeft() const
Shift all components by Count bits to the left (filling with zeros from the left)
static JPH_INLINE UVec8 sSelect(UVec8Arg inV1, UVec8Arg inV2, UVec8Arg inControl)
Component wise select, returns inV1 when highest bit of inControl = 0 and inV2 when highest bit of in...
Definition UVec8.inl:46
Definition Vec8.h:12