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