1#![allow(clippy::useless_conversion)]
4
5use crate::{Vec2, Vec3A, Vec3Swizzles, Vec4, sealed::Sealed};
6
7#[cfg(target_arch = "x86")]
8use core::arch::x86::*;
9#[cfg(target_arch = "x86_64")]
10use core::arch::x86_64::*;
11
12impl Sealed for Vec3A {}
13
14impl Vec3Swizzles for Vec3A {
15 type Vec2 = Vec2;
16
17 type Vec4 = Vec4;
18
19 #[inline]
20 fn xx(self) -> Vec2 {
21 Vec2 {
22 x: self.x,
23 y: self.x,
24 }
25 }
26
27 #[inline]
28 fn xy(self) -> Vec2 {
29 Vec2 {
30 x: self.x,
31 y: self.y,
32 }
33 }
34
35 #[inline]
36 fn with_xy(self, rhs: Vec2) -> Self {
37 Self::new(rhs.x, rhs.y, self.z)
38 }
39
40 #[inline]
41 fn xz(self) -> Vec2 {
42 Vec2 {
43 x: self.x,
44 y: self.z,
45 }
46 }
47
48 #[inline]
49 fn with_xz(self, rhs: Vec2) -> Self {
50 Self::new(rhs.x, self.y, rhs.y)
51 }
52
53 #[inline]
54 fn yx(self) -> Vec2 {
55 Vec2 {
56 x: self.y,
57 y: self.x,
58 }
59 }
60
61 #[inline]
62 fn with_yx(self, rhs: Vec2) -> Self {
63 Self::new(rhs.y, rhs.x, self.z)
64 }
65
66 #[inline]
67 fn yy(self) -> Vec2 {
68 Vec2 {
69 x: self.y,
70 y: self.y,
71 }
72 }
73
74 #[inline]
75 fn yz(self) -> Vec2 {
76 Vec2 {
77 x: self.y,
78 y: self.z,
79 }
80 }
81
82 #[inline]
83 fn with_yz(self, rhs: Vec2) -> Self {
84 Self::new(self.x, rhs.x, rhs.y)
85 }
86
87 #[inline]
88 fn zx(self) -> Vec2 {
89 Vec2 {
90 x: self.z,
91 y: self.x,
92 }
93 }
94
95 #[inline]
96 fn with_zx(self, rhs: Vec2) -> Self {
97 Self::new(rhs.y, self.y, rhs.x)
98 }
99
100 #[inline]
101 fn zy(self) -> Vec2 {
102 Vec2 {
103 x: self.z,
104 y: self.y,
105 }
106 }
107
108 #[inline]
109 fn with_zy(self, rhs: Vec2) -> Self {
110 Self::new(self.x, rhs.y, rhs.x)
111 }
112
113 #[inline]
114 fn zz(self) -> Vec2 {
115 Vec2 {
116 x: self.z,
117 y: self.z,
118 }
119 }
120
121 #[inline]
122 fn xxx(self) -> Self {
123 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_00_00) }).into())
124 }
125
126 #[inline]
127 fn xxy(self) -> Self {
128 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_00_00) }).into())
129 }
130
131 #[inline]
132 fn xxz(self) -> Self {
133 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_00_00) }).into())
134 }
135
136 #[inline]
137 fn xyx(self) -> Self {
138 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_01_00) }).into())
139 }
140
141 #[inline]
142 fn xyy(self) -> Self {
143 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_01_00) }).into())
144 }
145
146 #[inline]
147 fn xzx(self) -> Self {
148 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_10_00) }).into())
149 }
150
151 #[inline]
152 fn xzy(self) -> Self {
153 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_10_00) }).into())
154 }
155
156 #[inline]
157 fn xzz(self) -> Self {
158 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_10_00) }).into())
159 }
160
161 #[inline]
162 fn yxx(self) -> Self {
163 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_00_01) }).into())
164 }
165
166 #[inline]
167 fn yxy(self) -> Self {
168 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_00_01) }).into())
169 }
170
171 #[inline]
172 fn yxz(self) -> Self {
173 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_00_01) }).into())
174 }
175
176 #[inline]
177 fn yyx(self) -> Self {
178 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_01_01) }).into())
179 }
180
181 #[inline]
182 fn yyy(self) -> Self {
183 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_01_01) }).into())
184 }
185
186 #[inline]
187 fn yyz(self) -> Self {
188 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_01_01) }).into())
189 }
190
191 #[inline]
192 fn yzx(self) -> Self {
193 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_10_01) }).into())
194 }
195
196 #[inline]
197 fn yzy(self) -> Self {
198 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_10_01) }).into())
199 }
200
201 #[inline]
202 fn yzz(self) -> Self {
203 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_10_01) }).into())
204 }
205
206 #[inline]
207 fn zxx(self) -> Self {
208 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_00_10) }).into())
209 }
210
211 #[inline]
212 fn zxy(self) -> Self {
213 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_00_10) }).into())
214 }
215
216 #[inline]
217 fn zxz(self) -> Self {
218 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_00_10) }).into())
219 }
220
221 #[inline]
222 fn zyx(self) -> Self {
223 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_01_10) }).into())
224 }
225
226 #[inline]
227 fn zyy(self) -> Self {
228 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_01_10) }).into())
229 }
230
231 #[inline]
232 fn zyz(self) -> Self {
233 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_01_10) }).into())
234 }
235
236 #[inline]
237 fn zzx(self) -> Self {
238 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_10_10) }).into())
239 }
240
241 #[inline]
242 fn zzy(self) -> Self {
243 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_10_10) }).into())
244 }
245
246 #[inline]
247 fn zzz(self) -> Self {
248 Self((unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_10_10) }).into())
249 }
250
251 #[inline]
252 fn xxxx(self) -> Vec4 {
253 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_00_00) })
254 }
255
256 #[inline]
257 fn xxxy(self) -> Vec4 {
258 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_00_00) })
259 }
260
261 #[inline]
262 fn xxxz(self) -> Vec4 {
263 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_00_00) })
264 }
265
266 #[inline]
267 fn xxyx(self) -> Vec4 {
268 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_00_00) })
269 }
270
271 #[inline]
272 fn xxyy(self) -> Vec4 {
273 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_00_00) })
274 }
275
276 #[inline]
277 fn xxyz(self) -> Vec4 {
278 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_00_00) })
279 }
280
281 #[inline]
282 fn xxzx(self) -> Vec4 {
283 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_00_00) })
284 }
285
286 #[inline]
287 fn xxzy(self) -> Vec4 {
288 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_00_00) })
289 }
290
291 #[inline]
292 fn xxzz(self) -> Vec4 {
293 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_00_00) })
294 }
295
296 #[inline]
297 fn xyxx(self) -> Vec4 {
298 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_01_00) })
299 }
300
301 #[inline]
302 fn xyxy(self) -> Vec4 {
303 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_01_00) })
304 }
305
306 #[inline]
307 fn xyxz(self) -> Vec4 {
308 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_01_00) })
309 }
310
311 #[inline]
312 fn xyyx(self) -> Vec4 {
313 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_01_00) })
314 }
315
316 #[inline]
317 fn xyyy(self) -> Vec4 {
318 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_01_00) })
319 }
320
321 #[inline]
322 fn xyyz(self) -> Vec4 {
323 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_01_00) })
324 }
325
326 #[inline]
327 fn xyzx(self) -> Vec4 {
328 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_01_00) })
329 }
330
331 #[inline]
332 fn xyzy(self) -> Vec4 {
333 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_01_00) })
334 }
335
336 #[inline]
337 fn xyzz(self) -> Vec4 {
338 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_01_00) })
339 }
340
341 #[inline]
342 fn xzxx(self) -> Vec4 {
343 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_10_00) })
344 }
345
346 #[inline]
347 fn xzxy(self) -> Vec4 {
348 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_10_00) })
349 }
350
351 #[inline]
352 fn xzxz(self) -> Vec4 {
353 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_10_00) })
354 }
355
356 #[inline]
357 fn xzyx(self) -> Vec4 {
358 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_10_00) })
359 }
360
361 #[inline]
362 fn xzyy(self) -> Vec4 {
363 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_10_00) })
364 }
365
366 #[inline]
367 fn xzyz(self) -> Vec4 {
368 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_10_00) })
369 }
370
371 #[inline]
372 fn xzzx(self) -> Vec4 {
373 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_10_00) })
374 }
375
376 #[inline]
377 fn xzzy(self) -> Vec4 {
378 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_10_00) })
379 }
380
381 #[inline]
382 fn xzzz(self) -> Vec4 {
383 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_10_00) })
384 }
385
386 #[inline]
387 fn yxxx(self) -> Vec4 {
388 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_00_01) })
389 }
390
391 #[inline]
392 fn yxxy(self) -> Vec4 {
393 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_00_01) })
394 }
395
396 #[inline]
397 fn yxxz(self) -> Vec4 {
398 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_00_01) })
399 }
400
401 #[inline]
402 fn yxyx(self) -> Vec4 {
403 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_00_01) })
404 }
405
406 #[inline]
407 fn yxyy(self) -> Vec4 {
408 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_00_01) })
409 }
410
411 #[inline]
412 fn yxyz(self) -> Vec4 {
413 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_00_01) })
414 }
415
416 #[inline]
417 fn yxzx(self) -> Vec4 {
418 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_00_01) })
419 }
420
421 #[inline]
422 fn yxzy(self) -> Vec4 {
423 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_00_01) })
424 }
425
426 #[inline]
427 fn yxzz(self) -> Vec4 {
428 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_00_01) })
429 }
430
431 #[inline]
432 fn yyxx(self) -> Vec4 {
433 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_01_01) })
434 }
435
436 #[inline]
437 fn yyxy(self) -> Vec4 {
438 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_01_01) })
439 }
440
441 #[inline]
442 fn yyxz(self) -> Vec4 {
443 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_01_01) })
444 }
445
446 #[inline]
447 fn yyyx(self) -> Vec4 {
448 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_01_01) })
449 }
450
451 #[inline]
452 fn yyyy(self) -> Vec4 {
453 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_01_01) })
454 }
455
456 #[inline]
457 fn yyyz(self) -> Vec4 {
458 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_01_01) })
459 }
460
461 #[inline]
462 fn yyzx(self) -> Vec4 {
463 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_01_01) })
464 }
465
466 #[inline]
467 fn yyzy(self) -> Vec4 {
468 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_01_01) })
469 }
470
471 #[inline]
472 fn yyzz(self) -> Vec4 {
473 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_01_01) })
474 }
475
476 #[inline]
477 fn yzxx(self) -> Vec4 {
478 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_10_01) })
479 }
480
481 #[inline]
482 fn yzxy(self) -> Vec4 {
483 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_10_01) })
484 }
485
486 #[inline]
487 fn yzxz(self) -> Vec4 {
488 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_10_01) })
489 }
490
491 #[inline]
492 fn yzyx(self) -> Vec4 {
493 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_10_01) })
494 }
495
496 #[inline]
497 fn yzyy(self) -> Vec4 {
498 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_10_01) })
499 }
500
501 #[inline]
502 fn yzyz(self) -> Vec4 {
503 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_10_01) })
504 }
505
506 #[inline]
507 fn yzzx(self) -> Vec4 {
508 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_10_01) })
509 }
510
511 #[inline]
512 fn yzzy(self) -> Vec4 {
513 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_10_01) })
514 }
515
516 #[inline]
517 fn yzzz(self) -> Vec4 {
518 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_10_01) })
519 }
520
521 #[inline]
522 fn zxxx(self) -> Vec4 {
523 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_00_10) })
524 }
525
526 #[inline]
527 fn zxxy(self) -> Vec4 {
528 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_00_10) })
529 }
530
531 #[inline]
532 fn zxxz(self) -> Vec4 {
533 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_00_10) })
534 }
535
536 #[inline]
537 fn zxyx(self) -> Vec4 {
538 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_00_10) })
539 }
540
541 #[inline]
542 fn zxyy(self) -> Vec4 {
543 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_00_10) })
544 }
545
546 #[inline]
547 fn zxyz(self) -> Vec4 {
548 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_00_10) })
549 }
550
551 #[inline]
552 fn zxzx(self) -> Vec4 {
553 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_00_10) })
554 }
555
556 #[inline]
557 fn zxzy(self) -> Vec4 {
558 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_00_10) })
559 }
560
561 #[inline]
562 fn zxzz(self) -> Vec4 {
563 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_00_10) })
564 }
565
566 #[inline]
567 fn zyxx(self) -> Vec4 {
568 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_01_10) })
569 }
570
571 #[inline]
572 fn zyxy(self) -> Vec4 {
573 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_01_10) })
574 }
575
576 #[inline]
577 fn zyxz(self) -> Vec4 {
578 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_01_10) })
579 }
580
581 #[inline]
582 fn zyyx(self) -> Vec4 {
583 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_01_10) })
584 }
585
586 #[inline]
587 fn zyyy(self) -> Vec4 {
588 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_01_10) })
589 }
590
591 #[inline]
592 fn zyyz(self) -> Vec4 {
593 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_01_10) })
594 }
595
596 #[inline]
597 fn zyzx(self) -> Vec4 {
598 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_01_10) })
599 }
600
601 #[inline]
602 fn zyzy(self) -> Vec4 {
603 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_01_10) })
604 }
605
606 #[inline]
607 fn zyzz(self) -> Vec4 {
608 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_01_10) })
609 }
610
611 #[inline]
612 fn zzxx(self) -> Vec4 {
613 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_00_10_10) })
614 }
615
616 #[inline]
617 fn zzxy(self) -> Vec4 {
618 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_00_10_10) })
619 }
620
621 #[inline]
622 fn zzxz(self) -> Vec4 {
623 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_00_10_10) })
624 }
625
626 #[inline]
627 fn zzyx(self) -> Vec4 {
628 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_01_10_10) })
629 }
630
631 #[inline]
632 fn zzyy(self) -> Vec4 {
633 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_01_10_10) })
634 }
635
636 #[inline]
637 fn zzyz(self) -> Vec4 {
638 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_01_10_10) })
639 }
640
641 #[inline]
642 fn zzzx(self) -> Vec4 {
643 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b00_10_10_10) })
644 }
645
646 #[inline]
647 fn zzzy(self) -> Vec4 {
648 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b01_10_10_10) })
649 }
650
651 #[inline]
652 fn zzzz(self) -> Vec4 {
653 Vec4(unsafe { _mm_shuffle_ps(self.0, self.0, 0b10_10_10_10) })
654 }
655}