Plasma Engine  2.0
Loading...
Searching...
No Matches
FPUVec4u_inl.h
1#pragma once
2
3PL_ALWAYS_INLINE plSimdVec4u::plSimdVec4u()
4{
5#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
6 m_v.Set(0xCDCDCDCD);
7#endif
8}
9
10PL_ALWAYS_INLINE plSimdVec4u::plSimdVec4u(plUInt32 xyzw)
11{
12 m_v.Set(xyzw);
13}
14
15PL_ALWAYS_INLINE plSimdVec4u::plSimdVec4u(plUInt32 x, plUInt32 y, plUInt32 z, plUInt32 w)
16{
17 m_v.Set(x, y, z, w);
18}
19
20PL_ALWAYS_INLINE plSimdVec4u::plSimdVec4u(plInternal::QuadUInt v)
21{
22 m_v = v;
23}
24
25PL_ALWAYS_INLINE void plSimdVec4u::Set(plUInt32 xyzw)
26{
27 m_v.Set(xyzw);
28}
29
30PL_ALWAYS_INLINE void plSimdVec4u::Set(plUInt32 x, plUInt32 y, plUInt32 z, plUInt32 w)
31{
32 m_v.Set(x, y, z, w);
33}
34
35PL_ALWAYS_INLINE void plSimdVec4u::SetZero()
36{
37 m_v.SetZero();
38}
39
40// needs to be implemented here because of include dependencies
41PL_ALWAYS_INLINE plSimdVec4i::plSimdVec4i(const plSimdVec4u& u)
42 : m_v(u.m_v.x, u.m_v.y, u.m_v.z, u.m_v.w)
43{
44}
45
46PL_ALWAYS_INLINE plSimdVec4u::plSimdVec4u(const plSimdVec4i& i)
47 : m_v(i.m_v.x, i.m_v.y, i.m_v.z, i.m_v.w)
48{
49}
50
51PL_ALWAYS_INLINE plSimdVec4f plSimdVec4u::ToFloat() const
52{
53 plSimdVec4f result;
54 result.m_v.x = (float)m_v.x;
55 result.m_v.y = (float)m_v.y;
56 result.m_v.z = (float)m_v.z;
57 result.m_v.w = (float)m_v.w;
58
59 return result;
60}
61
62// static
63PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::Truncate(const plSimdVec4f& f)
64{
65 plSimdVec4f clampedF = f.CompMax(plSimdVec4f::MakeZero());
66
67 plSimdVec4u result;
68 result.m_v.x = (plUInt32)clampedF.m_v.x;
69 result.m_v.y = (plUInt32)clampedF.m_v.y;
70 result.m_v.z = (plUInt32)clampedF.m_v.z;
71 result.m_v.w = (plUInt32)clampedF.m_v.w;
72
73 return result;
74}
75
76template <int N>
77PL_ALWAYS_INLINE plUInt32 plSimdVec4u::GetComponent() const
78{
79 return (&m_v.x)[N];
80}
81
82PL_ALWAYS_INLINE plUInt32 plSimdVec4u::x() const
83{
84 return m_v.x;
85}
86
87PL_ALWAYS_INLINE plUInt32 plSimdVec4u::y() const
88{
89 return m_v.y;
90}
91
92PL_ALWAYS_INLINE plUInt32 plSimdVec4u::z() const
93{
94 return m_v.z;
95}
96
97PL_ALWAYS_INLINE plUInt32 plSimdVec4u::w() const
98{
99 return m_v.w;
100}
101
102template <plSwizzle::Enum s>
103PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::Get() const
104{
105 plSimdVec4u result;
106
107 const plUInt32* v = &m_v.x;
108 result.m_v.x = v[(s & 0x3000) >> 12];
109 result.m_v.y = v[(s & 0x0300) >> 8];
110 result.m_v.z = v[(s & 0x0030) >> 4];
111 result.m_v.w = v[(s & 0x0003)];
112
113 return result;
114}
115
116PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator+(const plSimdVec4u& v) const
117{
118 return m_v + v.m_v;
119}
120
121PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator-(const plSimdVec4u& v) const
122{
123 return m_v - v.m_v;
124}
125
126PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::CompMul(const plSimdVec4u& v) const
127{
128 return m_v.CompMul(v.m_v);
129}
130
131PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator|(const plSimdVec4u& v) const
132{
133 plSimdVec4u result;
134 result.m_v.x = m_v.x | v.m_v.x;
135 result.m_v.y = m_v.y | v.m_v.y;
136 result.m_v.z = m_v.z | v.m_v.z;
137 result.m_v.w = m_v.w | v.m_v.w;
138
139 return result;
140}
141
142PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator&(const plSimdVec4u& v) const
143{
144 plSimdVec4u result;
145 result.m_v.x = m_v.x & v.m_v.x;
146 result.m_v.y = m_v.y & v.m_v.y;
147 result.m_v.z = m_v.z & v.m_v.z;
148 result.m_v.w = m_v.w & v.m_v.w;
149
150 return result;
151}
152
153PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator^(const plSimdVec4u& v) const
154{
155 plSimdVec4u result;
156 result.m_v.x = m_v.x ^ v.m_v.x;
157 result.m_v.y = m_v.y ^ v.m_v.y;
158 result.m_v.z = m_v.z ^ v.m_v.z;
159 result.m_v.w = m_v.w ^ v.m_v.w;
160
161 return result;
162}
163
164PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator~() const
165{
166 plSimdVec4u result;
167 result.m_v.x = ~m_v.x;
168 result.m_v.y = ~m_v.y;
169 result.m_v.z = ~m_v.z;
170 result.m_v.w = ~m_v.w;
171
172 return result;
173}
174
175PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator<<(plUInt32 uiShift) const
176{
177 plSimdVec4u result;
178 result.m_v.x = m_v.x << uiShift;
179 result.m_v.y = m_v.y << uiShift;
180 result.m_v.z = m_v.z << uiShift;
181 result.m_v.w = m_v.w << uiShift;
182
183 return result;
184}
185
186PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::operator>>(plUInt32 uiShift) const
187{
188 plSimdVec4u result;
189 result.m_v.x = m_v.x >> uiShift;
190 result.m_v.y = m_v.y >> uiShift;
191 result.m_v.z = m_v.z >> uiShift;
192 result.m_v.w = m_v.w >> uiShift;
193
194 return result;
195}
196
197PL_ALWAYS_INLINE plSimdVec4u& plSimdVec4u::operator+=(const plSimdVec4u& v)
198{
199 m_v += v.m_v;
200 return *this;
201}
202
203PL_ALWAYS_INLINE plSimdVec4u& plSimdVec4u::operator-=(const plSimdVec4u& v)
204{
205 m_v -= v.m_v;
206 return *this;
207}
208
209PL_ALWAYS_INLINE plSimdVec4u& plSimdVec4u::operator|=(const plSimdVec4u& v)
210{
211 m_v.x |= v.m_v.x;
212 m_v.y |= v.m_v.y;
213 m_v.z |= v.m_v.z;
214 m_v.w |= v.m_v.w;
215 return *this;
216}
217
218PL_ALWAYS_INLINE plSimdVec4u& plSimdVec4u::operator&=(const plSimdVec4u& v)
219{
220 m_v.x &= v.m_v.x;
221 m_v.y &= v.m_v.y;
222 m_v.z &= v.m_v.z;
223 m_v.w &= v.m_v.w;
224 return *this;
225}
226
227PL_ALWAYS_INLINE plSimdVec4u& plSimdVec4u::operator^=(const plSimdVec4u& v)
228{
229 m_v.x ^= v.m_v.x;
230 m_v.y ^= v.m_v.y;
231 m_v.z ^= v.m_v.z;
232 m_v.w ^= v.m_v.w;
233 return *this;
234}
235
236PL_ALWAYS_INLINE plSimdVec4u& plSimdVec4u::operator<<=(plUInt32 uiShift)
237{
238 m_v.x <<= uiShift;
239 m_v.y <<= uiShift;
240 m_v.z <<= uiShift;
241 m_v.w <<= uiShift;
242 return *this;
243}
244
245PL_ALWAYS_INLINE plSimdVec4u& plSimdVec4u::operator>>=(plUInt32 uiShift)
246{
247 m_v.x >>= uiShift;
248 m_v.y >>= uiShift;
249 m_v.z >>= uiShift;
250 m_v.w >>= uiShift;
251 return *this;
252}
253
254PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::CompMin(const plSimdVec4u& v) const
255{
256 return m_v.CompMin(v.m_v);
257}
258
259PL_ALWAYS_INLINE plSimdVec4u plSimdVec4u::CompMax(const plSimdVec4u& v) const
260{
261 return m_v.CompMax(v.m_v);
262}
263
264PL_ALWAYS_INLINE plSimdVec4b plSimdVec4u::operator==(const plSimdVec4u& v) const
265{
266 bool result[4];
267 result[0] = m_v.x == v.m_v.x;
268 result[1] = m_v.y == v.m_v.y;
269 result[2] = m_v.z == v.m_v.z;
270 result[3] = m_v.w == v.m_v.w;
271
272 return plSimdVec4b(result[0], result[1], result[2], result[3]);
273}
274
275PL_ALWAYS_INLINE plSimdVec4b plSimdVec4u::operator!=(const plSimdVec4u& v) const
276{
277 return !(*this == v);
278}
279
280PL_ALWAYS_INLINE plSimdVec4b plSimdVec4u::operator<=(const plSimdVec4u& v) const
281{
282 return !(*this > v);
283}
284
285PL_ALWAYS_INLINE plSimdVec4b plSimdVec4u::operator<(const plSimdVec4u& v) const
286{
287 bool result[4];
288 result[0] = m_v.x < v.m_v.x;
289 result[1] = m_v.y < v.m_v.y;
290 result[2] = m_v.z < v.m_v.z;
291 result[3] = m_v.w < v.m_v.w;
292
293 return plSimdVec4b(result[0], result[1], result[2], result[3]);
294}
295
296PL_ALWAYS_INLINE plSimdVec4b plSimdVec4u::operator>=(const plSimdVec4u& v) const
297{
298 return !(*this < v);
299}
300
301PL_ALWAYS_INLINE plSimdVec4b plSimdVec4u::operator>(const plSimdVec4u& v) const
302{
303 bool result[4];
304 result[0] = m_v.x > v.m_v.x;
305 result[1] = m_v.y > v.m_v.y;
306 result[2] = m_v.z > v.m_v.z;
307 result[3] = m_v.w > v.m_v.w;
308
309 return plSimdVec4b(result[0], result[1], result[2], result[3]);
310}
311
312// static
314{
315 return plVec4U32::MakeZero();
316}
Definition SimdVec4b.h:7
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
static plSimdVec4f MakeZero()
Creates an plSimdVec4f that is initialized to zero.
Definition SimdVec4f_inl.h:8
A SIMD 4-component vector class of signed 32b integers.
Definition SimdVec4i.h:9
A SIMD 4-component vector class of unsigned 32b integers.
Definition SimdVec4u.h:7
static plSimdVec4u MakeZero()
Creates an plSimdVec4u that is initialized to zero.
Definition FPUVec4u_inl.h:313
A 4-component vector class.
Definition Vec4.h:9
const plVec4Template< Type > CompMin(const plVec4Template< Type > &rhs) const
Returns the component-wise minimum of *this and rhs.
Definition Vec4_inl.h:327
void SetZero()
Sets the vector to all zero.
Definition Vec4_inl.h:139
static plVec4Template< Type > MakeZero()
Returns a vector with all components set to zero.
Definition Vec4.h:41
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