forked from microsoft/DirectXMath
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectXMathConvert.inl
2191 lines (2018 loc) · 77.9 KB
/
DirectXMathConvert.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-------------------------------------------------------------------------------------
// DirectXMathConvert.inl -- SIMD C++ Math library
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkID=615560
//-------------------------------------------------------------------------------------
#pragma once
/****************************************************************************
*
* Data conversion
*
****************************************************************************/
//------------------------------------------------------------------------------
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4701)
// C4701: false positives
#endif
inline XMVECTOR XM_CALLCONV XMConvertVectorIntToFloat
(
FXMVECTOR VInt,
uint32_t DivExponent
) noexcept
{
assert(DivExponent < 32);
#if defined(_XM_NO_INTRINSICS_)
float fScale = 1.0f / static_cast<float>(1U << DivExponent);
uint32_t ElementIndex = 0;
XMVECTOR Result;
do {
auto iTemp = static_cast<int32_t>(VInt.vector4_u32[ElementIndex]);
Result.vector4_f32[ElementIndex] = static_cast<float>(iTemp)* fScale;
} while (++ElementIndex < 4);
return Result;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float fScale = 1.0f / static_cast<float>(1U << DivExponent);
float32x4_t vResult = vcvtq_f32_s32(vreinterpretq_s32_f32(VInt));
return vmulq_n_f32(vResult, fScale);
#else // _XM_SSE_INTRINSICS_
// Convert to floats
XMVECTOR vResult = _mm_cvtepi32_ps(_mm_castps_si128(VInt));
// Convert DivExponent into 1.0f/(1<<DivExponent)
uint32_t uScale = 0x3F800000U - (DivExponent << 23);
// Splat the scalar value
__m128i vScale = _mm_set1_epi32(static_cast<int>(uScale));
vResult = _mm_mul_ps(vResult, _mm_castsi128_ps(vScale));
return vResult;
#endif
}
//------------------------------------------------------------------------------
inline XMVECTOR XM_CALLCONV XMConvertVectorFloatToInt
(
FXMVECTOR VFloat,
uint32_t MulExponent
) noexcept
{
assert(MulExponent < 32);
#if defined(_XM_NO_INTRINSICS_)
// Get the scalar factor.
auto fScale = static_cast<float>(1U << MulExponent);
uint32_t ElementIndex = 0;
XMVECTOR Result;
do {
int32_t iResult;
float fTemp = VFloat.vector4_f32[ElementIndex] * fScale;
if (fTemp <= -(65536.0f * 32768.0f))
{
iResult = (-0x7FFFFFFF) - 1;
}
else if (fTemp > (65536.0f * 32768.0f) - 128.0f)
{
iResult = 0x7FFFFFFF;
}
else {
iResult = static_cast<int32_t>(fTemp);
}
Result.vector4_u32[ElementIndex] = static_cast<uint32_t>(iResult);
} while (++ElementIndex < 4);
return Result;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float32x4_t vResult = vmulq_n_f32(VFloat, static_cast<float>(1U << MulExponent));
// In case of positive overflow, detect it
uint32x4_t vOverflow = vcgtq_f32(vResult, g_XMMaxInt);
// Float to int conversion
int32x4_t vResulti = vcvtq_s32_f32(vResult);
// If there was positive overflow, set to 0x7FFFFFFF
vResult = vreinterpretq_f32_u32(vandq_u32(vOverflow, g_XMAbsMask));
vOverflow = vbicq_u32(vreinterpretq_u32_s32(vResulti), vOverflow);
vOverflow = vorrq_u32(vOverflow, vreinterpretq_u32_f32(vResult));
return vreinterpretq_f32_u32(vOverflow);
#else // _XM_SSE_INTRINSICS_
XMVECTOR vResult = _mm_set_ps1(static_cast<float>(1U << MulExponent));
vResult = _mm_mul_ps(vResult, VFloat);
// In case of positive overflow, detect it
XMVECTOR vOverflow = _mm_cmpgt_ps(vResult, g_XMMaxInt);
// Float to int conversion
__m128i vResulti = _mm_cvttps_epi32(vResult);
// If there was positive overflow, set to 0x7FFFFFFF
vResult = _mm_and_ps(vOverflow, g_XMAbsMask);
vOverflow = _mm_andnot_ps(vOverflow, _mm_castsi128_ps(vResulti));
vOverflow = _mm_or_ps(vOverflow, vResult);
return vOverflow;
#endif
}
//------------------------------------------------------------------------------
inline XMVECTOR XM_CALLCONV XMConvertVectorUIntToFloat
(
FXMVECTOR VUInt,
uint32_t DivExponent
) noexcept
{
assert(DivExponent < 32);
#if defined(_XM_NO_INTRINSICS_)
float fScale = 1.0f / static_cast<float>(1U << DivExponent);
uint32_t ElementIndex = 0;
XMVECTOR Result;
do {
Result.vector4_f32[ElementIndex] = static_cast<float>(VUInt.vector4_u32[ElementIndex])* fScale;
} while (++ElementIndex < 4);
return Result;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float fScale = 1.0f / static_cast<float>(1U << DivExponent);
float32x4_t vResult = vcvtq_f32_u32(vreinterpretq_u32_f32(VUInt));
return vmulq_n_f32(vResult, fScale);
#else // _XM_SSE_INTRINSICS_
// For the values that are higher than 0x7FFFFFFF, a fixup is needed
// Determine which ones need the fix.
XMVECTOR vMask = _mm_and_ps(VUInt, g_XMNegativeZero);
// Force all values positive
XMVECTOR vResult = _mm_xor_ps(VUInt, vMask);
// Convert to floats
vResult = _mm_cvtepi32_ps(_mm_castps_si128(vResult));
// Convert 0x80000000 -> 0xFFFFFFFF
__m128i iMask = _mm_srai_epi32(_mm_castps_si128(vMask), 31);
// For only the ones that are too big, add the fixup
vMask = _mm_and_ps(_mm_castsi128_ps(iMask), g_XMFixUnsigned);
vResult = _mm_add_ps(vResult, vMask);
// Convert DivExponent into 1.0f/(1<<DivExponent)
uint32_t uScale = 0x3F800000U - (DivExponent << 23);
// Splat
iMask = _mm_set1_epi32(static_cast<int>(uScale));
vResult = _mm_mul_ps(vResult, _mm_castsi128_ps(iMask));
return vResult;
#endif
}
//------------------------------------------------------------------------------
inline XMVECTOR XM_CALLCONV XMConvertVectorFloatToUInt
(
FXMVECTOR VFloat,
uint32_t MulExponent
) noexcept
{
assert(MulExponent < 32);
#if defined(_XM_NO_INTRINSICS_)
// Get the scalar factor.
auto fScale = static_cast<float>(1U << MulExponent);
uint32_t ElementIndex = 0;
XMVECTOR Result;
do {
uint32_t uResult;
float fTemp = VFloat.vector4_f32[ElementIndex] * fScale;
if (fTemp <= 0.0f)
{
uResult = 0;
}
else if (fTemp >= (65536.0f * 65536.0f))
{
uResult = 0xFFFFFFFFU;
}
else {
uResult = static_cast<uint32_t>(fTemp);
}
Result.vector4_u32[ElementIndex] = uResult;
} while (++ElementIndex < 4);
return Result;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float32x4_t vResult = vmulq_n_f32(VFloat, static_cast<float>(1U << MulExponent));
// In case of overflow, detect it
uint32x4_t vOverflow = vcgtq_f32(vResult, g_XMMaxUInt);
// Float to int conversion
uint32x4_t vResulti = vcvtq_u32_f32(vResult);
// If there was overflow, set to 0xFFFFFFFFU
vResult = vreinterpretq_f32_u32(vbicq_u32(vResulti, vOverflow));
vOverflow = vorrq_u32(vOverflow, vreinterpretq_u32_f32(vResult));
return vreinterpretq_f32_u32(vOverflow);
#else // _XM_SSE_INTRINSICS_
XMVECTOR vResult = _mm_set_ps1(static_cast<float>(1U << MulExponent));
vResult = _mm_mul_ps(vResult, VFloat);
// Clamp to >=0
vResult = _mm_max_ps(vResult, g_XMZero);
// Any numbers that are too big, set to 0xFFFFFFFFU
XMVECTOR vOverflow = _mm_cmpgt_ps(vResult, g_XMMaxUInt);
XMVECTOR vValue = g_XMUnsignedFix;
// Too large for a signed integer?
XMVECTOR vMask = _mm_cmpge_ps(vResult, vValue);
// Zero for number's lower than 0x80000000, 32768.0f*65536.0f otherwise
vValue = _mm_and_ps(vValue, vMask);
// Perform fixup only on numbers too large (Keeps low bit precision)
vResult = _mm_sub_ps(vResult, vValue);
__m128i vResulti = _mm_cvttps_epi32(vResult);
// Convert from signed to unsigned pnly if greater than 0x80000000
vMask = _mm_and_ps(vMask, g_XMNegativeZero);
vResult = _mm_xor_ps(_mm_castsi128_ps(vResulti), vMask);
// On those that are too large, set to 0xFFFFFFFF
vResult = _mm_or_ps(vResult, vOverflow);
return vResult;
#endif
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/****************************************************************************
*
* Vector and matrix load operations
*
****************************************************************************/
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadInt(const uint32_t* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_u32[0] = *pSource;
V.vector4_u32[1] = 0;
V.vector4_u32[2] = 0;
V.vector4_u32[3] = 0;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
uint32x4_t zero = vdupq_n_u32(0);
return vreinterpretq_f32_u32(vld1q_lane_u32(pSource, zero, 0));
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_load_ss(reinterpret_cast<const float*>(pSource));
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadFloat(const float* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = *pSource;
V.vector4_f32[1] = 0.f;
V.vector4_f32[2] = 0.f;
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float32x4_t zero = vdupq_n_f32(0);
return vld1q_lane_f32(pSource, zero, 0);
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_load_ss(pSource);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadInt2(const uint32_t* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_u32[0] = pSource[0];
V.vector4_u32[1] = pSource[1];
V.vector4_u32[2] = 0;
V.vector4_u32[3] = 0;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
uint32x2_t x = vld1_u32(pSource);
uint32x2_t zero = vdup_n_u32(0);
return vreinterpretq_f32_u32(vcombine_u32(x, zero));
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadInt2A(const uint32_t* pSource) noexcept
{
assert(pSource);
assert((reinterpret_cast<uintptr_t>(pSource) & 0xF) == 0);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_u32[0] = pSource[0];
V.vector4_u32[1] = pSource[1];
V.vector4_u32[2] = 0;
V.vector4_u32[3] = 0;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_ARM64_DISTINCT_NEON_TYPES)
uint32x2_t x = vld1_u32_ex(pSource, 64);
#else
uint32x2_t x = vld1_u32(pSource);
#endif
uint32x2_t zero = vdup_n_u32(0);
return vreinterpretq_f32_u32(vcombine_u32(x, zero));
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadFloat2(const XMFLOAT2* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = pSource->x;
V.vector4_f32[1] = pSource->y;
V.vector4_f32[2] = 0.f;
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float32x2_t x = vld1_f32(reinterpret_cast<const float*>(pSource));
float32x2_t zero = vdup_n_f32(0);
return vcombine_f32(x, zero);
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadFloat2A(const XMFLOAT2A* pSource) noexcept
{
assert(pSource);
assert((reinterpret_cast<uintptr_t>(pSource) & 0xF) == 0);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = pSource->x;
V.vector4_f32[1] = pSource->y;
V.vector4_f32[2] = 0.f;
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_ARM64_DISTINCT_NEON_TYPES)
float32x2_t x = vld1_f32_ex(reinterpret_cast<const float*>(pSource), 64);
#else
float32x2_t x = vld1_f32(reinterpret_cast<const float*>(pSource));
#endif
float32x2_t zero = vdup_n_f32(0);
return vcombine_f32(x, zero);
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadSInt2(const XMINT2* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = static_cast<float>(pSource->x);
V.vector4_f32[1] = static_cast<float>(pSource->y);
V.vector4_f32[2] = 0.f;
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
int32x2_t x = vld1_s32(reinterpret_cast<const int32_t*>(pSource));
float32x2_t v = vcvt_f32_s32(x);
float32x2_t zero = vdup_n_f32(0);
return vcombine_f32(v, zero);
#elif defined(_XM_SSE_INTRINSICS_)
__m128 V = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
return _mm_cvtepi32_ps(_mm_castps_si128(V));
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadUInt2(const XMUINT2* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = static_cast<float>(pSource->x);
V.vector4_f32[1] = static_cast<float>(pSource->y);
V.vector4_f32[2] = 0.f;
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
uint32x2_t x = vld1_u32(reinterpret_cast<const uint32_t*>(pSource));
float32x2_t v = vcvt_f32_u32(x);
float32x2_t zero = vdup_n_f32(0);
return vcombine_f32(v, zero);
#elif defined(_XM_SSE_INTRINSICS_)
__m128 V = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
// For the values that are higher than 0x7FFFFFFF, a fixup is needed
// Determine which ones need the fix.
XMVECTOR vMask = _mm_and_ps(V, g_XMNegativeZero);
// Force all values positive
XMVECTOR vResult = _mm_xor_ps(V, vMask);
// Convert to floats
vResult = _mm_cvtepi32_ps(_mm_castps_si128(vResult));
// Convert 0x80000000 -> 0xFFFFFFFF
__m128i iMask = _mm_srai_epi32(_mm_castps_si128(vMask), 31);
// For only the ones that are too big, add the fixup
vMask = _mm_and_ps(_mm_castsi128_ps(iMask), g_XMFixUnsigned);
vResult = _mm_add_ps(vResult, vMask);
return vResult;
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadInt3(const uint32_t* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_u32[0] = pSource[0];
V.vector4_u32[1] = pSource[1];
V.vector4_u32[2] = pSource[2];
V.vector4_u32[3] = 0;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
uint32x2_t x = vld1_u32(pSource);
uint32x2_t zero = vdup_n_u32(0);
uint32x2_t y = vld1_lane_u32(pSource + 2, zero, 0);
return vreinterpretq_f32_u32(vcombine_u32(x, y));
#elif defined(_XM_SSE4_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(reinterpret_cast<const float*>(pSource + 2));
return _mm_insert_ps(xy, z, 0x20);
#elif defined(_XM_SSE_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(reinterpret_cast<const float*>(pSource + 2));
return _mm_movelh_ps(xy, z);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadInt3A(const uint32_t* pSource) noexcept
{
assert(pSource);
assert((reinterpret_cast<uintptr_t>(pSource) & 0xF) == 0);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_u32[0] = pSource[0];
V.vector4_u32[1] = pSource[1];
V.vector4_u32[2] = pSource[2];
V.vector4_u32[3] = 0;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
// Reads an extra integer which is zero'd
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_ARM64_DISTINCT_NEON_TYPES)
uint32x4_t V = vld1q_u32_ex(pSource, 128);
#else
uint32x4_t V = vld1q_u32(pSource);
#endif
return vreinterpretq_f32_u32(vsetq_lane_u32(0, V, 3));
#elif defined(_XM_SSE4_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(reinterpret_cast<const float*>(pSource + 2));
return _mm_insert_ps(xy, z, 0x20);
#elif defined(_XM_SSE_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(reinterpret_cast<const float*>(pSource + 2));
return _mm_movelh_ps(xy, z);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadFloat3(const XMFLOAT3* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = pSource->x;
V.vector4_f32[1] = pSource->y;
V.vector4_f32[2] = pSource->z;
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float32x2_t x = vld1_f32(reinterpret_cast<const float*>(pSource));
float32x2_t zero = vdup_n_f32(0);
float32x2_t y = vld1_lane_f32(reinterpret_cast<const float*>(pSource) + 2, zero, 0);
return vcombine_f32(x, y);
#elif defined(_XM_SSE4_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(&pSource->z);
return _mm_insert_ps(xy, z, 0x20);
#elif defined(_XM_SSE_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(&pSource->z);
return _mm_movelh_ps(xy, z);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadFloat3A(const XMFLOAT3A* pSource) noexcept
{
assert(pSource);
assert((reinterpret_cast<uintptr_t>(pSource) & 0xF) == 0);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = pSource->x;
V.vector4_f32[1] = pSource->y;
V.vector4_f32[2] = pSource->z;
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
// Reads an extra float which is zero'd
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_ARM64_DISTINCT_NEON_TYPES)
float32x4_t V = vld1q_f32_ex(reinterpret_cast<const float*>(pSource), 128);
#else
float32x4_t V = vld1q_f32(reinterpret_cast<const float*>(pSource));
#endif
return vsetq_lane_f32(0, V, 3);
#elif defined(_XM_SSE_INTRINSICS_)
// Reads an extra float which is zero'd
__m128 V = _mm_load_ps(&pSource->x);
return _mm_and_ps(V, g_XMMask3);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadSInt3(const XMINT3* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = static_cast<float>(pSource->x);
V.vector4_f32[1] = static_cast<float>(pSource->y);
V.vector4_f32[2] = static_cast<float>(pSource->z);
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
int32x2_t x = vld1_s32(reinterpret_cast<const int32_t*>(pSource));
int32x2_t zero = vdup_n_s32(0);
int32x2_t y = vld1_lane_s32(reinterpret_cast<const int32_t*>(pSource) + 2, zero, 0);
int32x4_t v = vcombine_s32(x, y);
return vcvtq_f32_s32(v);
#elif defined(_XM_SSE_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(reinterpret_cast<const float*>(&pSource->z));
__m128 V = _mm_movelh_ps(xy, z);
return _mm_cvtepi32_ps(_mm_castps_si128(V));
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadUInt3(const XMUINT3* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = static_cast<float>(pSource->x);
V.vector4_f32[1] = static_cast<float>(pSource->y);
V.vector4_f32[2] = static_cast<float>(pSource->z);
V.vector4_f32[3] = 0.f;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
uint32x2_t x = vld1_u32(reinterpret_cast<const uint32_t*>(pSource));
uint32x2_t zero = vdup_n_u32(0);
uint32x2_t y = vld1_lane_u32(reinterpret_cast<const uint32_t*>(pSource) + 2, zero, 0);
uint32x4_t v = vcombine_u32(x, y);
return vcvtq_f32_u32(v);
#elif defined(_XM_SSE_INTRINSICS_)
__m128 xy = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(pSource)));
__m128 z = _mm_load_ss(reinterpret_cast<const float*>(&pSource->z));
__m128 V = _mm_movelh_ps(xy, z);
// For the values that are higher than 0x7FFFFFFF, a fixup is needed
// Determine which ones need the fix.
XMVECTOR vMask = _mm_and_ps(V, g_XMNegativeZero);
// Force all values positive
XMVECTOR vResult = _mm_xor_ps(V, vMask);
// Convert to floats
vResult = _mm_cvtepi32_ps(_mm_castps_si128(vResult));
// Convert 0x80000000 -> 0xFFFFFFFF
__m128i iMask = _mm_srai_epi32(_mm_castps_si128(vMask), 31);
// For only the ones that are too big, add the fixup
vMask = _mm_and_ps(_mm_castsi128_ps(iMask), g_XMFixUnsigned);
vResult = _mm_add_ps(vResult, vMask);
return vResult;
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadInt4(const uint32_t* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_u32[0] = pSource[0];
V.vector4_u32[1] = pSource[1];
V.vector4_u32[2] = pSource[2];
V.vector4_u32[3] = pSource[3];
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
return vreinterpretq_f32_u32(vld1q_u32(pSource));
#elif defined(_XM_SSE_INTRINSICS_)
__m128i V = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pSource));
return _mm_castsi128_ps(V);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadInt4A(const uint32_t* pSource) noexcept
{
assert(pSource);
assert((reinterpret_cast<uintptr_t>(pSource) & 0xF) == 0);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_u32[0] = pSource[0];
V.vector4_u32[1] = pSource[1];
V.vector4_u32[2] = pSource[2];
V.vector4_u32[3] = pSource[3];
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_ARM64_DISTINCT_NEON_TYPES)
return vld1q_u32_ex(pSource, 128);
#else
return vreinterpretq_f32_u32(vld1q_u32(pSource));
#endif
#elif defined(_XM_SSE_INTRINSICS_)
__m128i V = _mm_load_si128(reinterpret_cast<const __m128i*>(pSource));
return _mm_castsi128_ps(V);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadFloat4(const XMFLOAT4* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = pSource->x;
V.vector4_f32[1] = pSource->y;
V.vector4_f32[2] = pSource->z;
V.vector4_f32[3] = pSource->w;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
return vld1q_f32(reinterpret_cast<const float*>(pSource));
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_loadu_ps(&pSource->x);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadFloat4A(const XMFLOAT4A* pSource) noexcept
{
assert(pSource);
assert((reinterpret_cast<uintptr_t>(pSource) & 0xF) == 0);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = pSource->x;
V.vector4_f32[1] = pSource->y;
V.vector4_f32[2] = pSource->z;
V.vector4_f32[3] = pSource->w;
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_ARM64_DISTINCT_NEON_TYPES)
return vld1q_f32_ex(reinterpret_cast<const float*>(pSource), 128);
#else
return vld1q_f32(reinterpret_cast<const float*>(pSource));
#endif
#elif defined(_XM_SSE_INTRINSICS_)
return _mm_load_ps(&pSource->x);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadSInt4(const XMINT4* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = static_cast<float>(pSource->x);
V.vector4_f32[1] = static_cast<float>(pSource->y);
V.vector4_f32[2] = static_cast<float>(pSource->z);
V.vector4_f32[3] = static_cast<float>(pSource->w);
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
int32x4_t v = vld1q_s32(reinterpret_cast<const int32_t*>(pSource));
return vcvtq_f32_s32(v);
#elif defined(_XM_SSE_INTRINSICS_)
__m128i V = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pSource));
return _mm_cvtepi32_ps(V);
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMVECTOR XM_CALLCONV XMLoadUInt4(const XMUINT4* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V;
V.vector4_f32[0] = static_cast<float>(pSource->x);
V.vector4_f32[1] = static_cast<float>(pSource->y);
V.vector4_f32[2] = static_cast<float>(pSource->z);
V.vector4_f32[3] = static_cast<float>(pSource->w);
return V;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
uint32x4_t v = vld1q_u32(reinterpret_cast<const uint32_t*>(pSource));
return vcvtq_f32_u32(v);
#elif defined(_XM_SSE_INTRINSICS_)
__m128i V = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pSource));
// For the values that are higher than 0x7FFFFFFF, a fixup is needed
// Determine which ones need the fix.
XMVECTOR vMask = _mm_and_ps(_mm_castsi128_ps(V), g_XMNegativeZero);
// Force all values positive
XMVECTOR vResult = _mm_xor_ps(_mm_castsi128_ps(V), vMask);
// Convert to floats
vResult = _mm_cvtepi32_ps(_mm_castps_si128(vResult));
// Convert 0x80000000 -> 0xFFFFFFFF
__m128i iMask = _mm_srai_epi32(_mm_castps_si128(vMask), 31);
// For only the ones that are too big, add the fixup
vMask = _mm_and_ps(_mm_castsi128_ps(iMask), g_XMFixUnsigned);
vResult = _mm_add_ps(vResult, vMask);
return vResult;
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMMATRIX XM_CALLCONV XMLoadFloat3x3(const XMFLOAT3X3* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.r[0].vector4_f32[0] = pSource->m[0][0];
M.r[0].vector4_f32[1] = pSource->m[0][1];
M.r[0].vector4_f32[2] = pSource->m[0][2];
M.r[0].vector4_f32[3] = 0.0f;
M.r[1].vector4_f32[0] = pSource->m[1][0];
M.r[1].vector4_f32[1] = pSource->m[1][1];
M.r[1].vector4_f32[2] = pSource->m[1][2];
M.r[1].vector4_f32[3] = 0.0f;
M.r[2].vector4_f32[0] = pSource->m[2][0];
M.r[2].vector4_f32[1] = pSource->m[2][1];
M.r[2].vector4_f32[2] = pSource->m[2][2];
M.r[2].vector4_f32[3] = 0.0f;
M.r[3].vector4_f32[0] = 0.0f;
M.r[3].vector4_f32[1] = 0.0f;
M.r[3].vector4_f32[2] = 0.0f;
M.r[3].vector4_f32[3] = 1.0f;
return M;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float32x4_t v0 = vld1q_f32(&pSource->m[0][0]);
float32x4_t v1 = vld1q_f32(&pSource->m[1][1]);
float32x2_t v2 = vcreate_f32(static_cast<uint64_t>(*reinterpret_cast<const uint32_t*>(&pSource->m[2][2])));
float32x4_t T = vextq_f32(v0, v1, 3);
XMMATRIX M;
M.r[0] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(v0), g_XMMask3));
M.r[1] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(T), g_XMMask3));
M.r[2] = vcombine_f32(vget_high_f32(v1), v2);
M.r[3] = g_XMIdentityR3;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
__m128 Z = _mm_setzero_ps();
__m128 V1 = _mm_loadu_ps(&pSource->m[0][0]);
__m128 V2 = _mm_loadu_ps(&pSource->m[1][1]);
__m128 V3 = _mm_load_ss(&pSource->m[2][2]);
__m128 T1 = _mm_unpackhi_ps(V1, Z);
__m128 T2 = _mm_unpacklo_ps(V2, Z);
__m128 T3 = _mm_shuffle_ps(V3, T2, _MM_SHUFFLE(0, 1, 0, 0));
__m128 T4 = _mm_movehl_ps(T2, T3);
__m128 T5 = _mm_movehl_ps(Z, T1);
XMMATRIX M;
M.r[0] = _mm_movelh_ps(V1, T1);
M.r[1] = _mm_add_ps(T4, T5);
M.r[2] = _mm_shuffle_ps(V2, V3, _MM_SHUFFLE(1, 0, 3, 2));
M.r[3] = g_XMIdentityR3;
return M;
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMMATRIX XM_CALLCONV XMLoadFloat4x3(const XMFLOAT4X3* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.r[0].vector4_f32[0] = pSource->m[0][0];
M.r[0].vector4_f32[1] = pSource->m[0][1];
M.r[0].vector4_f32[2] = pSource->m[0][2];
M.r[0].vector4_f32[3] = 0.0f;
M.r[1].vector4_f32[0] = pSource->m[1][0];
M.r[1].vector4_f32[1] = pSource->m[1][1];
M.r[1].vector4_f32[2] = pSource->m[1][2];
M.r[1].vector4_f32[3] = 0.0f;
M.r[2].vector4_f32[0] = pSource->m[2][0];
M.r[2].vector4_f32[1] = pSource->m[2][1];
M.r[2].vector4_f32[2] = pSource->m[2][2];
M.r[2].vector4_f32[3] = 0.0f;
M.r[3].vector4_f32[0] = pSource->m[3][0];
M.r[3].vector4_f32[1] = pSource->m[3][1];
M.r[3].vector4_f32[2] = pSource->m[3][2];
M.r[3].vector4_f32[3] = 1.0f;
return M;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
float32x4_t v0 = vld1q_f32(&pSource->m[0][0]);
float32x4_t v1 = vld1q_f32(&pSource->m[1][1]);
float32x4_t v2 = vld1q_f32(&pSource->m[2][2]);
float32x4_t T1 = vextq_f32(v0, v1, 3);
float32x4_t T2 = vcombine_f32(vget_high_f32(v1), vget_low_f32(v2));
float32x4_t T3 = vextq_f32(v2, v2, 1);
XMMATRIX M;
M.r[0] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(v0), g_XMMask3));
M.r[1] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(T1), g_XMMask3));
M.r[2] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(T2), g_XMMask3));
M.r[3] = vsetq_lane_f32(1.f, T3, 3);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
// Use unaligned load instructions to
// load the 12 floats
// vTemp1 = x1,y1,z1,x2
XMVECTOR vTemp1 = _mm_loadu_ps(&pSource->m[0][0]);
// vTemp2 = y2,z2,x3,y3
XMVECTOR vTemp2 = _mm_loadu_ps(&pSource->m[1][1]);
// vTemp4 = z3,x4,y4,z4
XMVECTOR vTemp4 = _mm_loadu_ps(&pSource->m[2][2]);
// vTemp3 = x3,y3,z3,z3
XMVECTOR vTemp3 = _mm_shuffle_ps(vTemp2, vTemp4, _MM_SHUFFLE(0, 0, 3, 2));
// vTemp2 = y2,z2,x2,x2
vTemp2 = _mm_shuffle_ps(vTemp2, vTemp1, _MM_SHUFFLE(3, 3, 1, 0));
// vTemp2 = x2,y2,z2,z2
vTemp2 = XM_PERMUTE_PS(vTemp2, _MM_SHUFFLE(1, 1, 0, 2));
// vTemp1 = x1,y1,z1,0
vTemp1 = _mm_and_ps(vTemp1, g_XMMask3);
// vTemp2 = x2,y2,z2,0
vTemp2 = _mm_and_ps(vTemp2, g_XMMask3);
// vTemp3 = x3,y3,z3,0
vTemp3 = _mm_and_ps(vTemp3, g_XMMask3);
// vTemp4i = x4,y4,z4,0
__m128i vTemp4i = _mm_srli_si128(_mm_castps_si128(vTemp4), 32 / 8);
// vTemp4i = x4,y4,z4,1.0f
vTemp4i = _mm_or_si128(vTemp4i, g_XMIdentityR3);
XMMATRIX M(vTemp1,
vTemp2,
vTemp3,
_mm_castsi128_ps(vTemp4i));
return M;
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMMATRIX XM_CALLCONV XMLoadFloat4x3A(const XMFLOAT4X3A* pSource) noexcept
{
assert(pSource);
assert((reinterpret_cast<uintptr_t>(pSource) & 0xF) == 0);
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.r[0].vector4_f32[0] = pSource->m[0][0];
M.r[0].vector4_f32[1] = pSource->m[0][1];
M.r[0].vector4_f32[2] = pSource->m[0][2];
M.r[0].vector4_f32[3] = 0.0f;
M.r[1].vector4_f32[0] = pSource->m[1][0];
M.r[1].vector4_f32[1] = pSource->m[1][1];
M.r[1].vector4_f32[2] = pSource->m[1][2];
M.r[1].vector4_f32[3] = 0.0f;
M.r[2].vector4_f32[0] = pSource->m[2][0];
M.r[2].vector4_f32[1] = pSource->m[2][1];
M.r[2].vector4_f32[2] = pSource->m[2][2];
M.r[2].vector4_f32[3] = 0.0f;
M.r[3].vector4_f32[0] = pSource->m[3][0];
M.r[3].vector4_f32[1] = pSource->m[3][1];
M.r[3].vector4_f32[2] = pSource->m[3][2];
M.r[3].vector4_f32[3] = 1.0f;
return M;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_ARM64_DISTINCT_NEON_TYPES)
float32x4_t v0 = vld1q_f32_ex(&pSource->m[0][0], 128);
float32x4_t v1 = vld1q_f32_ex(&pSource->m[1][1], 128);
float32x4_t v2 = vld1q_f32_ex(&pSource->m[2][2], 128);
#else
float32x4_t v0 = vld1q_f32(&pSource->m[0][0]);
float32x4_t v1 = vld1q_f32(&pSource->m[1][1]);
float32x4_t v2 = vld1q_f32(&pSource->m[2][2]);
#endif
float32x4_t T1 = vextq_f32(v0, v1, 3);
float32x4_t T2 = vcombine_f32(vget_high_f32(v1), vget_low_f32(v2));
float32x4_t T3 = vextq_f32(v2, v2, 1);
XMMATRIX M;
M.r[0] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(v0), g_XMMask3));
M.r[1] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(T1), g_XMMask3));
M.r[2] = vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(T2), g_XMMask3));
M.r[3] = vsetq_lane_f32(1.f, T3, 3);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
// Use aligned load instructions to
// load the 12 floats
// vTemp1 = x1,y1,z1,x2
XMVECTOR vTemp1 = _mm_load_ps(&pSource->m[0][0]);
// vTemp2 = y2,z2,x3,y3
XMVECTOR vTemp2 = _mm_load_ps(&pSource->m[1][1]);
// vTemp4 = z3,x4,y4,z4
XMVECTOR vTemp4 = _mm_load_ps(&pSource->m[2][2]);
// vTemp3 = x3,y3,z3,z3
XMVECTOR vTemp3 = _mm_shuffle_ps(vTemp2, vTemp4, _MM_SHUFFLE(0, 0, 3, 2));
// vTemp2 = y2,z2,x2,x2
vTemp2 = _mm_shuffle_ps(vTemp2, vTemp1, _MM_SHUFFLE(3, 3, 1, 0));
// vTemp2 = x2,y2,z2,z2
vTemp2 = XM_PERMUTE_PS(vTemp2, _MM_SHUFFLE(1, 1, 0, 2));
// vTemp1 = x1,y1,z1,0
vTemp1 = _mm_and_ps(vTemp1, g_XMMask3);
// vTemp2 = x2,y2,z2,0
vTemp2 = _mm_and_ps(vTemp2, g_XMMask3);
// vTemp3 = x3,y3,z3,0
vTemp3 = _mm_and_ps(vTemp3, g_XMMask3);
// vTemp4i = x4,y4,z4,0
__m128i vTemp4i = _mm_srli_si128(_mm_castps_si128(vTemp4), 32 / 8);
// vTemp4i = x4,y4,z4,1.0f
vTemp4i = _mm_or_si128(vTemp4i, g_XMIdentityR3);
XMMATRIX M(vTemp1,
vTemp2,
vTemp3,
_mm_castsi128_ps(vTemp4i));
return M;
#endif
}
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline XMMATRIX XM_CALLCONV XMLoadFloat3x4(const XMFLOAT3X4* pSource) noexcept
{
assert(pSource);
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.r[0].vector4_f32[0] = pSource->m[0][0];
M.r[0].vector4_f32[1] = pSource->m[1][0];
M.r[0].vector4_f32[2] = pSource->m[2][0];
M.r[0].vector4_f32[3] = 0.0f;
M.r[1].vector4_f32[0] = pSource->m[0][1];
M.r[1].vector4_f32[1] = pSource->m[1][1];
M.r[1].vector4_f32[2] = pSource->m[2][1];
M.r[1].vector4_f32[3] = 0.0f;
M.r[2].vector4_f32[0] = pSource->m[0][2];
M.r[2].vector4_f32[1] = pSource->m[1][2];
M.r[2].vector4_f32[2] = pSource->m[2][2];
M.r[2].vector4_f32[3] = 0.0f;
M.r[3].vector4_f32[0] = pSource->m[0][3];
M.r[3].vector4_f32[1] = pSource->m[1][3];
M.r[3].vector4_f32[2] = pSource->m[2][3];