Plasma Engine  2.0
Loading...
Searching...
No Matches
FPUVec4i_inl.h
1#pragma once
2
3PL_ALWAYS_INLINE plSimdVec4i::plSimdVec4i()
4{
5#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
6 m_v.Set(0xCDCDCDCD);
7#endif
8}
9
10PL_ALWAYS_INLINE plSimdVec4i::plSimdVec4i(plInt32 xyzw)
11{
12 m_v.Set(xyzw);
13}
14
15PL_ALWAYS_INLINE plSimdVec4i::plSimdVec4i(plInt32 x, plInt32 y, plInt32 z, plInt32 w)
16{
17 m_v.Set(x, y, z, w);
18}
19
20PL_ALWAYS_INLINE plSimdVec4i::plSimdVec4i(plInternal::QuadInt v)
21{
22 m_v = v;
23}
24
26{
27 return plSimdVec4i(0);
28}
29
30PL_ALWAYS_INLINE void plSimdVec4i::Set(plInt32 xyzw)
31{
32 m_v.Set(xyzw);
33}
34
35PL_ALWAYS_INLINE void plSimdVec4i::Set(plInt32 x, plInt32 y, plInt32 z, plInt32 w)
36{
37 m_v.Set(x, y, z, w);
38}
39
40PL_ALWAYS_INLINE void plSimdVec4i::SetZero()
41{
42 m_v.SetZero();
43}
44
45template <int N>
46PL_ALWAYS_INLINE void plSimdVec4i::Load(const plInt32* pInts)
47{
48 m_v.SetZero();
49 for (int i = 0; i < N; ++i)
50 {
51 (&m_v.x)[i] = pInts[i];
52 }
53}
54
55template <int N>
56PL_ALWAYS_INLINE void plSimdVec4i::Store(plInt32* pInts) const
57{
58 for (int i = 0; i < N; ++i)
59 {
60 pInts[i] = (&m_v.x)[i];
61 }
62}
63
64PL_ALWAYS_INLINE plSimdVec4f plSimdVec4i::ToFloat() const
65{
66 plSimdVec4f result;
67 result.m_v.x = (float)m_v.x;
68 result.m_v.y = (float)m_v.y;
69 result.m_v.z = (float)m_v.z;
70 result.m_v.w = (float)m_v.w;
71
72 return result;
73}
74
75// static
76PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::Truncate(const plSimdVec4f& f)
77{
78 plSimdVec4i result;
79 result.m_v.x = (plInt32)f.m_v.x;
80 result.m_v.y = (plInt32)f.m_v.y;
81 result.m_v.z = (plInt32)f.m_v.z;
82 result.m_v.w = (plInt32)f.m_v.w;
83
84 return result;
85}
86
87template <int N>
88PL_ALWAYS_INLINE plInt32 plSimdVec4i::GetComponent() const
89{
90 return (&m_v.x)[N];
91}
92
93PL_ALWAYS_INLINE plInt32 plSimdVec4i::x() const
94{
95 return m_v.x;
96}
97
98PL_ALWAYS_INLINE plInt32 plSimdVec4i::y() const
99{
100 return m_v.y;
101}
102
103PL_ALWAYS_INLINE plInt32 plSimdVec4i::z() const
104{
105 return m_v.z;
106}
107
108PL_ALWAYS_INLINE plInt32 plSimdVec4i::w() const
109{
110 return m_v.w;
111}
112
113template <plSwizzle::Enum s>
114PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::Get() const
115{
116 plSimdVec4i result;
117
118 const plInt32* v = &m_v.x;
119 result.m_v.x = v[(s & 0x3000) >> 12];
120 result.m_v.y = v[(s & 0x0300) >> 8];
121 result.m_v.z = v[(s & 0x0030) >> 4];
122 result.m_v.w = v[(s & 0x0003)];
123
124 return result;
125}
126
127template <plSwizzle::Enum s>
128PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::GetCombined(const plSimdVec4i& other) const
129{
130 plSimdVec4i result;
131
132 const plInt32* v = &m_v.x;
133 const plInt32* o = &other.m_v.x;
134 result.m_v.x = v[(s & 0x3000) >> 12];
135 result.m_v.y = v[(s & 0x0300) >> 8];
136 result.m_v.z = o[(s & 0x0030) >> 4];
137 result.m_v.w = o[(s & 0x0003)];
138
139 return result;
140}
141
142PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator-() const
143{
144 return -m_v;
145}
146
147PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator+(const plSimdVec4i& v) const
148{
149 return m_v + v.m_v;
150}
151
152PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator-(const plSimdVec4i& v) const
153{
154 return m_v - v.m_v;
155}
156
157PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::CompMul(const plSimdVec4i& v) const
158{
159 return m_v.CompMul(v.m_v);
160}
161
162PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::CompDiv(const plSimdVec4i& v) const
163{
164 return m_v.CompDiv(v.m_v);
165}
166
167PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator|(const plSimdVec4i& v) const
168{
169 plSimdVec4i result;
170 result.m_v.x = m_v.x | v.m_v.x;
171 result.m_v.y = m_v.y | v.m_v.y;
172 result.m_v.z = m_v.z | v.m_v.z;
173 result.m_v.w = m_v.w | v.m_v.w;
174
175 return result;
176}
177
178PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator&(const plSimdVec4i& v) const
179{
180 plSimdVec4i result;
181 result.m_v.x = m_v.x & v.m_v.x;
182 result.m_v.y = m_v.y & v.m_v.y;
183 result.m_v.z = m_v.z & v.m_v.z;
184 result.m_v.w = m_v.w & v.m_v.w;
185
186 return result;
187}
188
189PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator^(const plSimdVec4i& v) const
190{
191 plSimdVec4i result;
192 result.m_v.x = m_v.x ^ v.m_v.x;
193 result.m_v.y = m_v.y ^ v.m_v.y;
194 result.m_v.z = m_v.z ^ v.m_v.z;
195 result.m_v.w = m_v.w ^ v.m_v.w;
196
197 return result;
198}
199
200PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator~() const
201{
202 plSimdVec4i result;
203 result.m_v.x = ~m_v.x;
204 result.m_v.y = ~m_v.y;
205 result.m_v.z = ~m_v.z;
206 result.m_v.w = ~m_v.w;
207
208 return result;
209}
210
211PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator<<(plUInt32 uiShift) const
212{
213 plSimdVec4i result;
214 result.m_v.x = m_v.x << uiShift;
215 result.m_v.y = m_v.y << uiShift;
216 result.m_v.z = m_v.z << uiShift;
217 result.m_v.w = m_v.w << uiShift;
218
219 return result;
220}
221
222PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator>>(plUInt32 uiShift) const
223{
224 plSimdVec4i result;
225 result.m_v.x = m_v.x >> uiShift;
226 result.m_v.y = m_v.y >> uiShift;
227 result.m_v.z = m_v.z >> uiShift;
228 result.m_v.w = m_v.w >> uiShift;
229
230 return result;
231}
232
233PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator<<(const plSimdVec4i& v) const
234{
235 plSimdVec4i result;
236 result.m_v.x = m_v.x << v.m_v.x;
237 result.m_v.y = m_v.y << v.m_v.y;
238 result.m_v.z = m_v.z << v.m_v.z;
239 result.m_v.w = m_v.w << v.m_v.w;
240
241 return result;
242}
243
244PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::operator>>(const plSimdVec4i& v) const
245{
246 plSimdVec4i result;
247 result.m_v.x = m_v.x >> v.m_v.x;
248 result.m_v.y = m_v.y >> v.m_v.y;
249 result.m_v.z = m_v.z >> v.m_v.z;
250 result.m_v.w = m_v.w >> v.m_v.w;
251
252 return result;
253}
254
255PL_ALWAYS_INLINE plSimdVec4i& plSimdVec4i::operator+=(const plSimdVec4i& v)
256{
257 m_v += v.m_v;
258 return *this;
259}
260
261PL_ALWAYS_INLINE plSimdVec4i& plSimdVec4i::operator-=(const plSimdVec4i& v)
262{
263 m_v -= v.m_v;
264 return *this;
265}
266
267PL_ALWAYS_INLINE plSimdVec4i& plSimdVec4i::operator|=(const plSimdVec4i& v)
268{
269 m_v.x |= v.m_v.x;
270 m_v.y |= v.m_v.y;
271 m_v.z |= v.m_v.z;
272 m_v.w |= v.m_v.w;
273 return *this;
274}
275
276PL_ALWAYS_INLINE plSimdVec4i& plSimdVec4i::operator&=(const plSimdVec4i& v)
277{
278 m_v.x &= v.m_v.x;
279 m_v.y &= v.m_v.y;
280 m_v.z &= v.m_v.z;
281 m_v.w &= v.m_v.w;
282 return *this;
283}
284
285PL_ALWAYS_INLINE plSimdVec4i& plSimdVec4i::operator^=(const plSimdVec4i& v)
286{
287 m_v.x ^= v.m_v.x;
288 m_v.y ^= v.m_v.y;
289 m_v.z ^= v.m_v.z;
290 m_v.w ^= v.m_v.w;
291 return *this;
292}
293
294PL_ALWAYS_INLINE plSimdVec4i& plSimdVec4i::operator<<=(plUInt32 uiShift)
295{
296 m_v.x <<= uiShift;
297 m_v.y <<= uiShift;
298 m_v.z <<= uiShift;
299 m_v.w <<= uiShift;
300 return *this;
301}
302
303PL_ALWAYS_INLINE plSimdVec4i& plSimdVec4i::operator>>=(plUInt32 uiShift)
304{
305 m_v.x >>= uiShift;
306 m_v.y >>= uiShift;
307 m_v.z >>= uiShift;
308 m_v.w >>= uiShift;
309 return *this;
310}
311
312PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::CompMin(const plSimdVec4i& v) const
313{
314 return m_v.CompMin(v.m_v);
315}
316
317PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::CompMax(const plSimdVec4i& v) const
318{
319 return m_v.CompMax(v.m_v);
320}
321
322PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::Abs() const
323{
324 plSimdVec4i result;
325 result.m_v.x = plMath::Abs(m_v.x);
326 result.m_v.y = plMath::Abs(m_v.y);
327 result.m_v.z = plMath::Abs(m_v.z);
328 result.m_v.w = plMath::Abs(m_v.w);
329
330 return result;
331}
332
333PL_ALWAYS_INLINE plSimdVec4b plSimdVec4i::operator==(const plSimdVec4i& v) const
334{
335 bool result[4];
336 result[0] = m_v.x == v.m_v.x;
337 result[1] = m_v.y == v.m_v.y;
338 result[2] = m_v.z == v.m_v.z;
339 result[3] = m_v.w == v.m_v.w;
340
341 return plSimdVec4b(result[0], result[1], result[2], result[3]);
342}
343
344PL_ALWAYS_INLINE plSimdVec4b plSimdVec4i::operator!=(const plSimdVec4i& v) const
345{
346 return !(*this == v);
347}
348
349PL_ALWAYS_INLINE plSimdVec4b plSimdVec4i::operator<=(const plSimdVec4i& v) const
350{
351 return !(*this > v);
352}
353
354PL_ALWAYS_INLINE plSimdVec4b plSimdVec4i::operator<(const plSimdVec4i& v) const
355{
356 bool result[4];
357 result[0] = m_v.x < v.m_v.x;
358 result[1] = m_v.y < v.m_v.y;
359 result[2] = m_v.z < v.m_v.z;
360 result[3] = m_v.w < v.m_v.w;
361
362 return plSimdVec4b(result[0], result[1], result[2], result[3]);
363}
364
365PL_ALWAYS_INLINE plSimdVec4b plSimdVec4i::operator>=(const plSimdVec4i& v) const
366{
367 return !(*this < v);
368}
369
370PL_ALWAYS_INLINE plSimdVec4b plSimdVec4i::operator>(const plSimdVec4i& v) const
371{
372 bool result[4];
373 result[0] = m_v.x > v.m_v.x;
374 result[1] = m_v.y > v.m_v.y;
375 result[2] = m_v.z > v.m_v.z;
376 result[3] = m_v.w > v.m_v.w;
377
378 return plSimdVec4b(result[0], result[1], result[2], result[3]);
379}
380
381// static
382PL_ALWAYS_INLINE plSimdVec4i plSimdVec4i::Select(const plSimdVec4b& cmp, const plSimdVec4i& ifTrue, const plSimdVec4i& ifFalse)
383{
384 plSimdVec4i result;
385 result.m_v.x = cmp.m_v.x ? ifTrue.m_v.x : ifFalse.m_v.x;
386 result.m_v.y = cmp.m_v.y ? ifTrue.m_v.y : ifFalse.m_v.y;
387 result.m_v.z = cmp.m_v.z ? ifTrue.m_v.z : ifFalse.m_v.z;
388 result.m_v.w = cmp.m_v.w ? ifTrue.m_v.w : ifFalse.m_v.w;
389
390 return result;
391}
Definition SimdVec4b.h:7
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
A SIMD 4-component vector class of signed 32b integers.
Definition SimdVec4i.h:9
plSimdVec4i GetCombined(const plSimdVec4i &other) const
x = this[s0], y = this[s1], z = other[s2], w = other[s3]
static plSimdVec4i MakeZero()
Creates an plSimdVec4i that is initialized to zero.
Definition FPUVec4i_inl.h:25
const plVec4Template< Type > CompMin(const plVec4Template< Type > &rhs) const
Returns the component-wise minimum of *this and rhs.
Definition Vec4_inl.h:327
const plVec4Template< Type > CompDiv(const plVec4Template< Type > &rhs) const
Returns the component-wise division of *this and rhs.
Definition Vec4_inl.h:366
void SetZero()
Sets the vector to all zero.
Definition Vec4_inl.h:139
void Set(Type xyzw)
Sets all 4 components to this value.
Definition Vec4_inl.h:121
const plVec4Template< Type > CompMul(const plVec4Template< Type > &rhs) const
Returns the component-wise multiplication of *this and rhs.
Definition Vec4_inl.h:355
const plVec4Template< Type > CompMax(const plVec4Template< Type > &rhs) const
Returns the component-wise maximum of *this and rhs.
Definition Vec4_inl.h:336
constexpr PL_ALWAYS_INLINE T Abs(T f)
Returns the absolute value of f.
Definition Math_inl.h:21