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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
|
//-------------------------------------------------------------------------------------
// DirectXMath.h -- SIMD C++ Math library
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//-------------------------------------------------------------------------------------
// MGH -------------------
#define _XM_BIGENDIAN_
#define _XM_NO_INTRINSICS_
// -----------------------
#ifdef _MSC_VER
#pragma once
#endif
#ifndef __cplusplus
#error DirectX Math requires C++
#endif
#define DIRECTX_MATH_VERSION 303
#if !defined(_XM_BIGENDIAN_) && !defined(_XM_LITTLEENDIAN_)
#if defined(_M_AMD64) || defined(_M_IX86) || defined(_M_ARM)
#define _XM_LITTLEENDIAN_
#elif defined(_M_PPCBE)
#define _XM_BIGENDIAN_
#else
#error DirectX Math does not support this target
#endif
#endif // !_XM_BIGENDIAN_ && !_XM_LITTLEENDIAN_
#if !defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_SSE_INTRINSICS_) && !defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
#if defined(_M_IX86) || defined(_M_AMD64)
#define _XM_SSE_INTRINSICS_
#elif defined(_M_PPCBE)
#define _XM_VMX128_INTRINSICS_
#elif defined(_M_ARM)
#define _XM_ARM_NEON_INTRINSICS_
#elif !defined(_XM_NO_INTRINSICS_)
#error DirectX Math does not support this target
#endif
#endif // !_XM_ARM_NEON_INTRINSICS_ && !_XM_SSE_INTRINSICS_ && !_XM_VMX128_INTRINSICS_ && !_XM_NO_INTRINSICS_
#pragma warning(push)
#pragma warning(disable:4514 4820 4985)
#include <cmath>
#include <float.h>
// MGH - #include <malloc.h>
#pragma warning(pop)
#if defined(_XM_SSE_INTRINSICS_)
#ifndef _XM_NO_INTRINSICS_
#include <xmmintrin.h>
#include <emmintrin.h>
#endif
#elif defined(_XM_VMX128_INTRINSICS_)
#error This version of DirectX Math does not support Xbox 360
#elif defined(_XM_ARM_NEON_INTRINSICS_)
#ifndef _XM_NO_INTRINSICS_
#include <arm_neon.h>
#endif
#endif
#include <DirectX/no_sal2.h>
#include <assert.h>
#pragma warning(push)
#pragma warning(disable : 4005 4668)
#include <stdint.h>
#pragma warning(pop)
namespace DirectX
{
/****************************************************************************
*
* Constant definitions
*
****************************************************************************/
#if defined(__XNAMATH_H__) && defined(XM_PI)
#undef XM_PI
#undef XM_2PI
#undef XM_1DIVPI
#undef XM_1DIV2PI
#undef XM_PIDIV2
#undef XM_PIDIV4
#undef XM_SELECT_0
#undef XM_SELECT_1
#undef XM_PERMUTE_0X
#undef XM_PERMUTE_0Y
#undef XM_PERMUTE_0Z
#undef XM_PERMUTE_0W
#undef XM_PERMUTE_1X
#undef XM_PERMUTE_1Y
#undef XM_PERMUTE_1Z
#undef XM_PERMUTE_1W
#undef XM_CRMASK_CR6
#undef XM_CRMASK_CR6TRUE
#undef XM_CRMASK_CR6FALSE
#undef XM_CRMASK_CR6BOUNDS
#undef XM_CACHE_LINE_SIZE
#endif
const float XM_PI = 3.141592654f;
const float XM_2PI = 6.283185307f;
const float XM_1DIVPI = 0.318309886f;
const float XM_1DIV2PI = 0.159154943f;
const float XM_PIDIV2 = 1.570796327f;
const float XM_PIDIV4 = 0.785398163f;
const uint32_t XM_SELECT_0 = 0x00000000;
const uint32_t XM_SELECT_1 = 0xFFFFFFFF;
const uint32_t XM_PERMUTE_0X = 0;
const uint32_t XM_PERMUTE_0Y = 1;
const uint32_t XM_PERMUTE_0Z = 2;
const uint32_t XM_PERMUTE_0W = 3;
const uint32_t XM_PERMUTE_1X = 4;
const uint32_t XM_PERMUTE_1Y = 5;
const uint32_t XM_PERMUTE_1Z = 6;
const uint32_t XM_PERMUTE_1W = 7;
const uint32_t XM_SWIZZLE_X = 0;
const uint32_t XM_SWIZZLE_Y = 1;
const uint32_t XM_SWIZZLE_Z = 2;
const uint32_t XM_SWIZZLE_W = 3;
const uint32_t XM_CRMASK_CR6 = 0x000000F0;
const uint32_t XM_CRMASK_CR6TRUE = 0x00000080;
const uint32_t XM_CRMASK_CR6FALSE = 0x00000020;
const uint32_t XM_CRMASK_CR6BOUNDS = XM_CRMASK_CR6FALSE;
/****************************************************************************
*
* Macros
*
****************************************************************************/
#if defined(__XNAMATH_H__) && defined(XMComparisonAllTrue)
#undef XMComparisonAllTrue
#undef XMComparisonAnyTrue
#undef XMComparisonAllFalse
#undef XMComparisonAnyFalse
#undef XMComparisonMixed
#undef XMComparisonAllInBounds
#undef XMComparisonAnyOutOfBounds
#endif
// Unit conversion
inline float XMConvertToRadians(float fDegrees) { return fDegrees * (XM_PI / 180.0f); }
inline float XMConvertToDegrees(float fRadians) { return fRadians * (180.0f / XM_PI); }
// Condition register evaluation proceeding a recording (R) comparison
inline bool XMComparisonAllTrue(uint32_t CR) { return (((CR) & XM_CRMASK_CR6TRUE) == XM_CRMASK_CR6TRUE); }
inline bool XMComparisonAnyTrue(uint32_t CR) { return (((CR) & XM_CRMASK_CR6FALSE) != XM_CRMASK_CR6FALSE); }
inline bool XMComparisonAllFalse(uint32_t CR) { return (((CR) & XM_CRMASK_CR6FALSE) == XM_CRMASK_CR6FALSE); }
inline bool XMComparisonAnyFalse(uint32_t CR) { return (((CR) & XM_CRMASK_CR6TRUE) != XM_CRMASK_CR6TRUE); }
inline bool XMComparisonMixed(uint32_t CR) { return (((CR) & XM_CRMASK_CR6) == 0); }
inline bool XMComparisonAllInBounds(uint32_t CR) { return (((CR) & XM_CRMASK_CR6BOUNDS) == XM_CRMASK_CR6BOUNDS); }
inline bool XMComparisonAnyOutOfBounds(uint32_t CR) { return (((CR) & XM_CRMASK_CR6BOUNDS) != XM_CRMASK_CR6BOUNDS); }
/****************************************************************************
*
* Data types
*
****************************************************************************/
#pragma warning(push)
#pragma warning(disable:4068 4201 4365 4324 4820)
#pragma prefast(push)
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")
#ifdef _XM_BIGENDIAN_
#pragma bitfield_order(push)
#pragma bitfield_order(lsb_to_msb)
#endif
//------------------------------------------------------------------------------
#if defined(_XM_NO_INTRINSICS_) && !defined(_M_PPCBE)
// The __vector4 structure is an intrinsic on Xbox but must be separately defined
// for x86/x64
struct __vector4
{
union
{
float vector4_f32[4];
uint32_t vector4_u32[4];
// MGH - added to match 360 version
//----------------------
struct
{
float x;
float y;
float z;
float w;
};
float v[4];
uint32_t u[4];
//----------------------
};
};
#endif // _XM_NO_INTRINSICS_
//------------------------------------------------------------------------------
#if (defined (_M_IX86) || defined(_M_AMD64) || defined(_M_ARM)) && defined(_XM_NO_INTRINSICS_)
typedef uint32_t __vector4i[4];
#else
typedef __declspec(align(16)) uint32_t __vector4i[4];
#endif
//------------------------------------------------------------------------------
// Vector intrinsic: Four 32 bit floating point components aligned on a 16 byte
// boundary and mapped to hardware vector registers
#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
typedef __m128 XMVECTOR;
#elif defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
typedef __n128 XMVECTOR;
#else
typedef __vector4 XMVECTOR;
#endif
// Fix-up for (1st-3rd) XMVECTOR parameters that are pass-in-register for x86, ARM, and Xbox 360; by reference otherwise
#if ( defined(_M_IX86) || defined(_M_ARM) || defined(_XM_VMX128_INTRINSICS_) ) && !defined(_XM_NO_INTRINSICS_)
typedef const XMVECTOR FXMVECTOR;
#else
typedef const XMVECTOR& FXMVECTOR;
#endif
// Fix-up for (4th) XMVECTOR parameter to pass in-register for ARM and Xbox 360; by reference otherwise
#if ( defined(_M_ARM) || defined(_XM_VMX128_INTRINSICS_) ) && !defined(_XM_NO_INTRINSICS_)
typedef const XMVECTOR GXMVECTOR;
#else
typedef const XMVECTOR& GXMVECTOR;
#endif
// Fix-up for (5th+) XMVECTOR parameters to pass in-register for Xbox 360 and by reference otherwise
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
typedef const XMVECTOR CXMVECTOR;
#else
typedef const XMVECTOR& CXMVECTOR;
#endif
//------------------------------------------------------------------------------
// Conversion types for constants
__declspec(align(16)) struct XMVECTORF32
{
union
{
float f[4];
XMVECTOR v;
};
inline operator XMVECTOR() const { return v; }
inline operator const float*() const { return f; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return _mm_castps_si128(v); }
inline operator __m128d() const { return _mm_castps_pd(v); }
#endif
};
__declspec(align(16)) struct XMVECTORI32
{
union
{
int32_t i[4];
XMVECTOR v;
};
inline operator XMVECTOR() const { return v; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return _mm_castps_si128(v); }
inline operator __m128d() const { return _mm_castps_pd(v); }
#endif
};
__declspec(align(16)) struct XMVECTORU8
{
union
{
uint8_t u[16];
XMVECTOR v;
};
inline operator XMVECTOR() const { return v; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return _mm_castps_si128(v); }
inline operator __m128d() const { return _mm_castps_pd(v); }
#endif
};
__declspec(align(16)) struct XMVECTORU32
{
union
{
uint32_t u[4];
XMVECTOR v;
};
inline operator XMVECTOR() const { return v; }
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
inline operator __m128i() const { return _mm_castps_si128(v); }
inline operator __m128d() const { return _mm_castps_pd(v); }
#endif
};
//------------------------------------------------------------------------------
// Vector operators
XMVECTOR operator+ (FXMVECTOR V);
XMVECTOR operator- (FXMVECTOR V);
XMVECTOR& operator+= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator-= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator*= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator/= (XMVECTOR& V1, FXMVECTOR V2);
XMVECTOR& operator*= (XMVECTOR& V, float S);
XMVECTOR& operator/= (XMVECTOR& V, float S);
XMVECTOR operator+ (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator- (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator* (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator/ (FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR operator* (FXMVECTOR V, float S);
XMVECTOR operator* (float S, FXMVECTOR V);
XMVECTOR operator/ (FXMVECTOR V, float S);
//------------------------------------------------------------------------------
// Matrix type: Sixteen 32 bit floating point components aligned on a
// 16 byte boundary and mapped to four hardware vector registers
struct XMMATRIX;
// Fix-up for XMMATRIX parameters to pass in-register on Xbox 360, by reference otherwise
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
typedef const XMMATRIX CXMMATRIX;
#else
typedef const XMMATRIX& CXMMATRIX;
#endif
#if (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM)) && defined(_XM_NO_INTRINSICS_)
struct XMMATRIX
#else
__declspec(align(16)) struct XMMATRIX
#endif
{
#ifdef _XM_NO_INTRINSICS_
union
{
XMVECTOR r[4];
struct
{
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
};
float m[4][4];
};
#else
XMVECTOR r[4];
#endif
XMMATRIX() {}
XMMATRIX(FXMVECTOR R0, FXMVECTOR R1, FXMVECTOR R2, GXMVECTOR R3) { r[0] = R0; r[1] = R1; r[2] = R2; r[3] = R3; }
XMMATRIX(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33);
explicit XMMATRIX(_In_reads_(16) const float *pArray);
#ifdef _XM_NO_INTRINSICS_
float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
#endif
XMMATRIX& operator= (const XMMATRIX& M) { r[0] = M.r[0]; r[1] = M.r[1]; r[2] = M.r[2]; r[3] = M.r[3]; return *this; }
XMMATRIX operator+ () const { return *this; }
XMMATRIX operator- () const;
XMMATRIX& operator+= (CXMMATRIX M);
XMMATRIX& operator-= (CXMMATRIX M);
XMMATRIX& operator*= (CXMMATRIX M);
XMMATRIX& operator*= (float S);
XMMATRIX& operator/= (float S);
XMMATRIX operator+ (CXMMATRIX M) const;
XMMATRIX operator- (CXMMATRIX M) const;
XMMATRIX operator* (CXMMATRIX M) const;
XMMATRIX operator* (float S) const;
XMMATRIX operator/ (float S) const;
friend XMMATRIX operator* (float S, CXMMATRIX M);
};
//------------------------------------------------------------------------------
// 2D Vector; 32 bit floating point components
struct XMFLOAT2
{
float x;
float y;
XMFLOAT2() {}
XMFLOAT2(float _x, float _y) : x(_x), y(_y) {}
explicit XMFLOAT2(_In_reads_(2) const float *pArray) : x(pArray[0]), y(pArray[1]) {}
XMFLOAT2& operator= (const XMFLOAT2& Float2) { x = Float2.x; y = Float2.y; return *this; }
};
// 2D Vector; 32 bit floating point components aligned on a 16 byte boundary
__declspec(align(16)) struct XMFLOAT2A : public XMFLOAT2
{
XMFLOAT2A() : XMFLOAT2() {}
XMFLOAT2A(float _x, float _y) : XMFLOAT2(_x, _y) {}
explicit XMFLOAT2A(_In_reads_(2) const float *pArray) : XMFLOAT2(pArray) {}
XMFLOAT2A& operator= (const XMFLOAT2A& Float2) { x = Float2.x; y = Float2.y; return *this; }
};
//------------------------------------------------------------------------------
// 2D Vector; 32 bit signed integer components
struct XMINT2
{
int32_t x;
int32_t y;
XMINT2() {}
XMINT2(int32_t _x, int32_t _y) : x(_x), y(_y) {}
explicit XMINT2(_In_reads_(2) const int32_t *pArray) : x(pArray[0]), y(pArray[1]) {}
XMINT2& operator= (const XMINT2& Int2) { x = Int2.x; y = Int2.y; return *this; }
};
// 2D Vector; 32 bit unsigned integer components
struct XMUINT2
{
uint32_t x;
uint32_t y;
XMUINT2() {}
XMUINT2(uint32_t _x, uint32_t _y) : x(_x), y(_y) {}
explicit XMUINT2(_In_reads_(2) const uint32_t *pArray) : x(pArray[0]), y(pArray[1]) {}
XMUINT2& operator= (const XMUINT2& UInt2) { x = UInt2.x; y = UInt2.y; return *this; }
};
//------------------------------------------------------------------------------
// 3D Vector; 32 bit floating point components
struct XMFLOAT3
{
float x;
float y;
float z;
XMFLOAT3() {}
XMFLOAT3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
explicit XMFLOAT3(_In_reads_(3) const float *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {}
XMFLOAT3& operator= (const XMFLOAT3& Float3) { x = Float3.x; y = Float3.y; z = Float3.z; return *this; }
};
// 3D Vector; 32 bit floating point components aligned on a 16 byte boundary
__declspec(align(16)) struct XMFLOAT3A : public XMFLOAT3
{
XMFLOAT3A() : XMFLOAT3() {}
XMFLOAT3A(float _x, float _y, float _z) : XMFLOAT3(_x, _y, _z) {}
explicit XMFLOAT3A(_In_reads_(3) const float *pArray) : XMFLOAT3(pArray) {}
XMFLOAT3A& operator= (const XMFLOAT3A& Float3) { x = Float3.x; y = Float3.y; z = Float3.z; return *this; }
};
//------------------------------------------------------------------------------
// 3D Vector; 32 bit signed integer components
struct XMINT3
{
int32_t x;
int32_t y;
int32_t z;
XMINT3() {}
XMINT3(int32_t _x, int32_t _y, int32_t _z) : x(_x), y(_y), z(_z) {}
explicit XMINT3(_In_reads_(3) const int32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {}
XMINT3& operator= (const XMINT3& i3) { x = i3.x; y = i3.y; z = i3.z; return *this; }
};
// 3D Vector; 32 bit unsigned integer components
struct XMUINT3
{
uint32_t x;
uint32_t y;
uint32_t z;
XMUINT3() {}
XMUINT3(uint32_t _x, uint32_t _y, uint32_t _z) : x(_x), y(_y), z(_z) {}
explicit XMUINT3(_In_reads_(3) const uint32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {}
XMUINT3& operator= (const XMUINT3& u3) { x = u3.x; y = u3.y; z = u3.z; return *this; }
};
//------------------------------------------------------------------------------
// 4D Vector; 32 bit floating point components
struct XMFLOAT4
{
float x;
float y;
float z;
float w;
XMFLOAT4() {}
XMFLOAT4(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) {}
explicit XMFLOAT4(_In_reads_(4) const float *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMFLOAT4& operator= (const XMFLOAT4& Float4) { x = Float4.x; y = Float4.y; z = Float4.z; w = Float4.w; return *this; }
};
// 4D Vector; 32 bit floating point components aligned on a 16 byte boundary
__declspec(align(16)) struct XMFLOAT4A : public XMFLOAT4
{
XMFLOAT4A() : XMFLOAT4() {}
XMFLOAT4A(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {}
explicit XMFLOAT4A(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {}
XMFLOAT4A& operator= (const XMFLOAT4A& Float4) { x = Float4.x; y = Float4.y; z = Float4.z; w = Float4.w; return *this; }
};
//------------------------------------------------------------------------------
// 4D Vector; 32 bit signed integer components
struct XMINT4
{
int32_t x;
int32_t y;
int32_t z;
int32_t w;
XMINT4() {}
XMINT4(int32_t _x, int32_t _y, int32_t _z, int32_t _w) : x(_x), y(_y), z(_z), w(_w) {}
explicit XMINT4(_In_reads_(4) const int32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMINT4& operator= (const XMINT4& Int4) { x = Int4.x; y = Int4.y; z = Int4.z; w = Int4.w; return *this; }
};
// 4D Vector; 32 bit unsigned integer components
struct XMUINT4
{
uint32_t x;
uint32_t y;
uint32_t z;
uint32_t w;
XMUINT4() {}
XMUINT4(uint32_t _x, uint32_t _y, uint32_t _z, uint32_t _w) : x(_x), y(_y), z(_z), w(_w) {}
explicit XMUINT4(_In_reads_(4) const uint32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMUINT4& operator= (const XMUINT4& UInt4) { x = UInt4.x; y = UInt4.y; z = UInt4.z; w = UInt4.w; return *this; }
};
//------------------------------------------------------------------------------
// 3x3 Matrix: 32 bit floating point components
struct XMFLOAT3X3
{
union
{
struct
{
float _11, _12, _13;
float _21, _22, _23;
float _31, _32, _33;
};
float m[3][3];
};
XMFLOAT3X3() {}
XMFLOAT3X3(float m00, float m01, float m02,
float m10, float m11, float m12,
float m20, float m21, float m22);
explicit XMFLOAT3X3(_In_reads_(9) const float *pArray);
float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
XMFLOAT3X3& operator= (const XMFLOAT3X3& Float3x3);
};
//------------------------------------------------------------------------------
// 4x3 Matrix: 32 bit floating point components
struct XMFLOAT4X3
{
union
{
struct
{
float _11, _12, _13;
float _21, _22, _23;
float _31, _32, _33;
float _41, _42, _43;
};
float m[4][3];
};
XMFLOAT4X3() {}
XMFLOAT4X3(float m00, float m01, float m02,
float m10, float m11, float m12,
float m20, float m21, float m22,
float m30, float m31, float m32);
explicit XMFLOAT4X3(_In_reads_(12) const float *pArray);
float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
XMFLOAT4X3& operator= (const XMFLOAT4X3& Float4x3);
};
// 4x3 Matrix: 32 bit floating point components aligned on a 16 byte boundary
__declspec(align(16)) struct XMFLOAT4X3A : public XMFLOAT4X3
{
XMFLOAT4X3A() : XMFLOAT4X3() {}
XMFLOAT4X3A(float m00, float m01, float m02,
float m10, float m11, float m12,
float m20, float m21, float m22,
float m30, float m31, float m32) :
XMFLOAT4X3(m00,m01,m02,m10,m11,m12,m20,m21,m22,m30,m31,m32) {}
explicit XMFLOAT4X3A(_In_reads_(12) const float *pArray) : XMFLOAT4X3(pArray) {}
float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
XMFLOAT4X3A& operator= (const XMFLOAT4X3A& Float4x3);
};
//------------------------------------------------------------------------------
// 4x4 Matrix: 32 bit floating point components
struct XMFLOAT4X4
{
union
{
struct
{
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
};
float m[4][4];
};
XMFLOAT4X4() {}
XMFLOAT4X4(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33);
explicit XMFLOAT4X4(_In_reads_(16) const float *pArray);
float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
XMFLOAT4X4& operator= (const XMFLOAT4X4& Float4x4);
};
// 4x4 Matrix: 32 bit floating point components aligned on a 16 byte boundary
__declspec(align(16)) struct XMFLOAT4X4A : public XMFLOAT4X4
{
XMFLOAT4X4A() : XMFLOAT4X4() {}
XMFLOAT4X4A(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33)
: XMFLOAT4X4(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33) {}
explicit XMFLOAT4X4A(_In_reads_(16) const float *pArray) : XMFLOAT4X4(pArray) {}
float operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
float& operator() (size_t Row, size_t Column) { return m[Row][Column]; }
XMFLOAT4X4A& operator= (const XMFLOAT4X4A& Float4x4);
};
////////////////////////////////////////////////////////////////////////////////
#ifdef _XM_BIGENDIAN_
#pragma bitfield_order(pop)
#endif
#pragma prefast(pop)
#pragma warning(pop)
/****************************************************************************
*
* Data conversion operations
*
****************************************************************************/
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_VMX128_INTRINSICS_)
#else
XMVECTOR XMConvertVectorIntToFloat(FXMVECTOR VInt, uint32_t DivExponent);
XMVECTOR XMConvertVectorFloatToInt(FXMVECTOR VFloat, uint32_t MulExponent);
XMVECTOR XMConvertVectorUIntToFloat(FXMVECTOR VUInt, uint32_t DivExponent);
XMVECTOR XMConvertVectorFloatToUInt(FXMVECTOR VFloat, uint32_t MulExponent);
#endif
#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_VMX128_INTRINSICS_)
#else
#if defined(__XNAMATH_H__) && defined(XMVectorSetBinaryConstant)
#undef XMVectorSetBinaryConstant
#undef XMVectorSplatConstant
#undef XMVectorSplatConstantInt
#endif
XMVECTOR XMVectorSetBinaryConstant(uint32_t C0, uint32_t C1, uint32_t C2, uint32_t C3);
XMVECTOR XMVectorSplatConstant(int32_t IntConstant, uint32_t DivExponent);
XMVECTOR XMVectorSplatConstantInt(int32_t IntConstant);
#endif
/****************************************************************************
*
* Load operations
*
****************************************************************************/
XMVECTOR XMLoadInt(_In_ const uint32_t* pSource);
XMVECTOR XMLoadFloat(_In_ const float* pSource);
XMVECTOR XMLoadInt2(_In_reads_(2) const uint32_t* pSource);
XMVECTOR XMLoadInt2A(_In_reads_(2) const uint32_t* PSource);
XMVECTOR XMLoadFloat2(_In_ const XMFLOAT2* pSource);
XMVECTOR XMLoadFloat2A(_In_ const XMFLOAT2A* pSource);
XMVECTOR XMLoadSInt2(_In_ const XMINT2* pSource);
XMVECTOR XMLoadUInt2(_In_ const XMUINT2* pSource);
XMVECTOR XMLoadInt3(_In_reads_(3) const uint32_t* pSource);
XMVECTOR XMLoadInt3A(_In_reads_(3) const uint32_t* pSource);
XMVECTOR XMLoadFloat3(_In_ const XMFLOAT3* pSource);
XMVECTOR XMLoadFloat3A(_In_ const XMFLOAT3A* pSource);
XMVECTOR XMLoadSInt3(_In_ const XMINT3* pSource);
XMVECTOR XMLoadUInt3(_In_ const XMUINT3* pSource);
XMVECTOR XMLoadInt4(_In_reads_(4) const uint32_t* pSource);
XMVECTOR XMLoadInt4A(_In_reads_(4) const uint32_t* pSource);
XMVECTOR XMLoadFloat4(_In_ const XMFLOAT4* pSource);
XMVECTOR XMLoadFloat4A(_In_ const XMFLOAT4A* pSource);
XMVECTOR XMLoadSInt4(_In_ const XMINT4* pSource);
XMVECTOR XMLoadUInt4(_In_ const XMUINT4* pSource);
XMMATRIX XMLoadFloat3x3(_In_ const XMFLOAT3X3* pSource);
XMMATRIX XMLoadFloat4x3(_In_ const XMFLOAT4X3* pSource);
XMMATRIX XMLoadFloat4x3A(_In_ const XMFLOAT4X3A* pSource);
XMMATRIX XMLoadFloat4x4(_In_ const XMFLOAT4X4* pSource);
XMMATRIX XMLoadFloat4x4A(_In_ const XMFLOAT4X4A* pSource);
/****************************************************************************
*
* Store operations
*
****************************************************************************/
void XMStoreInt(_Out_ uint32_t* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat(_Out_ float* pDestination, _In_ FXMVECTOR V);
void XMStoreInt2(_Out_writes_(2) uint32_t* pDestination, _In_ FXMVECTOR V);
void XMStoreInt2A(_Out_writes_(2) uint32_t* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat2(_Out_ XMFLOAT2* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat2A(_Out_ XMFLOAT2A* pDestination, _In_ FXMVECTOR V);
void XMStoreSInt2(_Out_ XMINT2* pDestination, _In_ FXMVECTOR V);
void XMStoreUInt2(_Out_ XMUINT2* pDestination, _In_ FXMVECTOR V);
void XMStoreInt3(_Out_writes_(3) uint32_t* pDestination, _In_ FXMVECTOR V);
void XMStoreInt3A(_Out_writes_(3) uint32_t* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat3(_Out_ XMFLOAT3* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat3A(_Out_ XMFLOAT3A* pDestination, _In_ FXMVECTOR V);
void XMStoreSInt3(_Out_ XMINT3* pDestination, _In_ FXMVECTOR V);
void XMStoreUInt3(_Out_ XMUINT3* pDestination, _In_ FXMVECTOR V);
void XMStoreInt4(_Out_writes_(4) uint32_t* pDestination, _In_ FXMVECTOR V);
void XMStoreInt4A(_Out_writes_(4) uint32_t* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat4(_Out_ XMFLOAT4* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat4A(_Out_ XMFLOAT4A* pDestination, _In_ FXMVECTOR V);
void XMStoreSInt4(_Out_ XMINT4* pDestination, _In_ FXMVECTOR V);
void XMStoreUInt4(_Out_ XMUINT4* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat3x3(_Out_ XMFLOAT3X3* pDestination, _In_ CXMMATRIX M);
void XMStoreFloat4x3(_Out_ XMFLOAT4X3* pDestination, _In_ CXMMATRIX M);
void XMStoreFloat4x3A(_Out_ XMFLOAT4X3A* pDestination, _In_ CXMMATRIX M);
void XMStoreFloat4x4(_Out_ XMFLOAT4X4* pDestination, _In_ CXMMATRIX M);
void XMStoreFloat4x4A(_Out_ XMFLOAT4X4A* pDestination, _In_ CXMMATRIX M);
/****************************************************************************
*
* General vector operations
*
****************************************************************************/
XMVECTOR XMVectorZero();
XMVECTOR XMVectorSet(float x, float y, float z, float w);
XMVECTOR XMVectorSetInt(uint32_t x, uint32_t y, uint32_t z, uint32_t w);
XMVECTOR XMVectorReplicate(float Value);
XMVECTOR XMVectorReplicatePtr(_In_ const float *pValue);
XMVECTOR XMVectorReplicateInt(uint32_t Value);
XMVECTOR XMVectorReplicateIntPtr(_In_ const uint32_t *pValue);
XMVECTOR XMVectorTrueInt();
XMVECTOR XMVectorFalseInt();
XMVECTOR XMVectorSplatX(FXMVECTOR V);
XMVECTOR XMVectorSplatY(FXMVECTOR V);
XMVECTOR XMVectorSplatZ(FXMVECTOR V);
XMVECTOR XMVectorSplatW(FXMVECTOR V);
XMVECTOR XMVectorSplatOne();
XMVECTOR XMVectorSplatInfinity();
XMVECTOR XMVectorSplatQNaN();
XMVECTOR XMVectorSplatEpsilon();
XMVECTOR XMVectorSplatSignMask();
float XMVectorGetByIndex(FXMVECTOR V, size_t i);
float XMVectorGetX(FXMVECTOR V);
float XMVectorGetY(FXMVECTOR V);
float XMVectorGetZ(FXMVECTOR V);
float XMVectorGetW(FXMVECTOR V);
void XMVectorGetByIndexPtr(_Out_ float *f, _In_ FXMVECTOR V, _In_ size_t i);
void XMVectorGetXPtr(_Out_ float *x, _In_ FXMVECTOR V);
void XMVectorGetYPtr(_Out_ float *y, _In_ FXMVECTOR V);
void XMVectorGetZPtr(_Out_ float *z, _In_ FXMVECTOR V);
void XMVectorGetWPtr(_Out_ float *w, _In_ FXMVECTOR V);
uint32_t XMVectorGetIntByIndex(FXMVECTOR V, size_t i);
uint32_t XMVectorGetIntX(FXMVECTOR V);
uint32_t XMVectorGetIntY(FXMVECTOR V);
uint32_t XMVectorGetIntZ(FXMVECTOR V);
uint32_t XMVectorGetIntW(FXMVECTOR V);
void XMVectorGetIntByIndexPtr(_Out_ uint32_t *x, _In_ FXMVECTOR V, _In_ size_t i);
void XMVectorGetIntXPtr(_Out_ uint32_t *x, _In_ FXMVECTOR V);
void XMVectorGetIntYPtr(_Out_ uint32_t *y, _In_ FXMVECTOR V);
void XMVectorGetIntZPtr(_Out_ uint32_t *z, _In_ FXMVECTOR V);
void XMVectorGetIntWPtr(_Out_ uint32_t *w, _In_ FXMVECTOR V);
XMVECTOR XMVectorSetByIndex(FXMVECTOR V,float f, size_t i);
XMVECTOR XMVectorSetX(FXMVECTOR V, float x);
XMVECTOR XMVectorSetY(FXMVECTOR V, float y);
XMVECTOR XMVectorSetZ(FXMVECTOR V, float z);
XMVECTOR XMVectorSetW(FXMVECTOR V, float w);
XMVECTOR XMVectorSetByIndexPtr(_In_ FXMVECTOR V, _In_ const float *f, _In_ size_t i);
XMVECTOR XMVectorSetXPtr(_In_ FXMVECTOR V, _In_ const float *x);
XMVECTOR XMVectorSetYPtr(_In_ FXMVECTOR V, _In_ const float *y);
XMVECTOR XMVectorSetZPtr(_In_ FXMVECTOR V, _In_ const float *z);
XMVECTOR XMVectorSetWPtr(_In_ FXMVECTOR V, _In_ const float *w);
XMVECTOR XMVectorSetIntByIndex(FXMVECTOR V, uint32_t x, size_t i);
XMVECTOR XMVectorSetIntX(FXMVECTOR V, uint32_t x);
XMVECTOR XMVectorSetIntY(FXMVECTOR V, uint32_t y);
XMVECTOR XMVectorSetIntZ(FXMVECTOR V, uint32_t z);
XMVECTOR XMVectorSetIntW(FXMVECTOR V, uint32_t w);
XMVECTOR XMVectorSetIntByIndexPtr(_In_ FXMVECTOR V, _In_ const uint32_t *x, _In_ size_t i);
XMVECTOR XMVectorSetIntXPtr(_In_ FXMVECTOR V, _In_ const uint32_t *x);
XMVECTOR XMVectorSetIntYPtr(_In_ FXMVECTOR V, _In_ const uint32_t *y);
XMVECTOR XMVectorSetIntZPtr(_In_ FXMVECTOR V, _In_ const uint32_t *z);
XMVECTOR XMVectorSetIntWPtr(_In_ FXMVECTOR V, _In_ const uint32_t *w);
#if defined(__XNAMATH_H__) && defined(XMVectorSwizzle)
#undef XMVectorSwizzle
#endif
XMVECTOR XMVectorSwizzle(FXMVECTOR V, uint32_t E0, uint32_t E1, uint32_t E2, uint32_t E3);
XMVECTOR XMVectorPermute(FXMVECTOR V1, FXMVECTOR V2, uint32_t PermuteX, uint32_t PermuteY, uint32_t PermuteZ, uint32_t PermuteW);
XMVECTOR XMVectorSelectControl(uint32_t VectorIndex0, uint32_t VectorIndex1, uint32_t VectorIndex2, uint32_t VectorIndex3);
XMVECTOR XMVectorSelect(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Control);
XMVECTOR XMVectorMergeXY(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorMergeZW(FXMVECTOR V1, FXMVECTOR V2);
#if defined(__XNAMATH_H__) && defined(XMVectorShiftLeft)
#undef XMVectorShiftLeft
#undef XMVectorRotateLeft
#undef XMVectorRotateRight
#undef XMVectorInsert
#endif
XMVECTOR XMVectorShiftLeft(FXMVECTOR V1, FXMVECTOR V2, uint32_t Elements);
XMVECTOR XMVectorRotateLeft(FXMVECTOR V, uint32_t Elements);
XMVECTOR XMVectorRotateRight(FXMVECTOR V, uint32_t Elements);
XMVECTOR XMVectorInsert(FXMVECTOR VD, FXMVECTOR VS, uint32_t VSLeftRotateElements,
uint32_t Select0, uint32_t Select1, uint32_t Select2, uint32_t Select3);
XMVECTOR XMVectorEqual(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorEqualR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2);
XMVECTOR XMVectorEqualInt(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorEqualIntR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V, _In_ FXMVECTOR V2);
XMVECTOR XMVectorNearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
XMVECTOR XMVectorNotEqual(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorNotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorGreater(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorGreaterR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2);
XMVECTOR XMVectorGreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorGreaterOrEqualR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2);
XMVECTOR XMVectorLess(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorLessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorInBounds(FXMVECTOR V, FXMVECTOR Bounds);
XMVECTOR XMVectorInBoundsR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V, _In_ FXMVECTOR Bounds);
XMVECTOR XMVectorIsNaN(FXMVECTOR V);
XMVECTOR XMVectorIsInfinite(FXMVECTOR V);
XMVECTOR XMVectorMin(FXMVECTOR V1,FXMVECTOR V2);
XMVECTOR XMVectorMax(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorRound(FXMVECTOR V);
XMVECTOR XMVectorTruncate(FXMVECTOR V);
XMVECTOR XMVectorFloor(FXMVECTOR V);
XMVECTOR XMVectorCeiling(FXMVECTOR V);
XMVECTOR XMVectorClamp(FXMVECTOR V, FXMVECTOR Min, FXMVECTOR Max);
XMVECTOR XMVectorSaturate(FXMVECTOR V);
XMVECTOR XMVectorAndInt(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorAndCInt(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorOrInt(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorNorInt(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorXorInt(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorNegate(FXMVECTOR V);
XMVECTOR XMVectorAdd(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorAddAngles(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorSubtract(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorSubtractAngles(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorMultiply(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorMultiplyAdd(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3);
XMVECTOR XMVectorDivide(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorNegativeMultiplySubtract(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3);
XMVECTOR XMVectorScale(FXMVECTOR V, float ScaleFactor);
XMVECTOR XMVectorReciprocalEst(FXMVECTOR V);
XMVECTOR XMVectorReciprocal(FXMVECTOR V);
XMVECTOR XMVectorSqrtEst(FXMVECTOR V);
XMVECTOR XMVectorSqrt(FXMVECTOR V);
XMVECTOR XMVectorReciprocalSqrtEst(FXMVECTOR V);
XMVECTOR XMVectorReciprocalSqrt(FXMVECTOR V);
XMVECTOR XMVectorExp(FXMVECTOR V);
XMVECTOR XMVectorLog(FXMVECTOR V);
XMVECTOR XMVectorPow(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorAbs(FXMVECTOR V);
XMVECTOR XMVectorMod(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVectorModAngles(FXMVECTOR Angles);
XMVECTOR XMVectorSin(FXMVECTOR V);
XMVECTOR XMVectorSinEst(FXMVECTOR V);
XMVECTOR XMVectorCos(FXMVECTOR V);
XMVECTOR XMVectorCosEst(FXMVECTOR V);
void XMVectorSinCos(_Out_ XMVECTOR* pSin, _Out_ XMVECTOR* pCos, _In_ FXMVECTOR V);
void XMVectorSinCosEst(_Out_ XMVECTOR* pSin, _Out_ XMVECTOR* pCos, _In_ FXMVECTOR V);
XMVECTOR XMVectorTan(FXMVECTOR V);
XMVECTOR XMVectorTanEst(FXMVECTOR V);
XMVECTOR XMVectorSinH(FXMVECTOR V);
XMVECTOR XMVectorCosH(FXMVECTOR V);
XMVECTOR XMVectorTanH(FXMVECTOR V);
XMVECTOR XMVectorASin(FXMVECTOR V);
XMVECTOR XMVectorASinEst(FXMVECTOR V);
XMVECTOR XMVectorACos(FXMVECTOR V);
XMVECTOR XMVectorACosEst(FXMVECTOR V);
XMVECTOR XMVectorATan(FXMVECTOR V);
XMVECTOR XMVectorATanEst(FXMVECTOR V);
XMVECTOR XMVectorATan2(FXMVECTOR Y, FXMVECTOR X);
XMVECTOR XMVectorATan2Est(FXMVECTOR Y, FXMVECTOR X);
XMVECTOR XMVectorLerp(FXMVECTOR V0, FXMVECTOR V1, float t);
XMVECTOR XMVectorLerpV(FXMVECTOR V0, FXMVECTOR V1, FXMVECTOR T);
XMVECTOR XMVectorHermite(FXMVECTOR Position0, FXMVECTOR Tangent0, FXMVECTOR Position1, GXMVECTOR Tangent1, float t);
XMVECTOR XMVectorHermiteV(FXMVECTOR Position0, FXMVECTOR Tangent0, FXMVECTOR Position1, GXMVECTOR Tangent1, CXMVECTOR T);
XMVECTOR XMVectorCatmullRom(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, GXMVECTOR Position3, float t);
XMVECTOR XMVectorCatmullRomV(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, GXMVECTOR Position3, CXMVECTOR T);
XMVECTOR XMVectorBaryCentric(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, float f, float g);
XMVECTOR XMVectorBaryCentricV(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, GXMVECTOR F, CXMVECTOR G);
/****************************************************************************
*
* 2D vector operations
*
****************************************************************************/
bool XMVector2Equal(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector2EqualR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2EqualInt(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector2EqualIntR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
bool XMVector2NotEqual(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2NotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2Greater(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector2GreaterR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector2GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2Less(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2LessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector2InBounds(FXMVECTOR V, FXMVECTOR Bounds);
bool XMVector2IsNaN(FXMVECTOR V);
bool XMVector2IsInfinite(FXMVECTOR V);
XMVECTOR XMVector2Dot(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector2Cross(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector2LengthSq(FXMVECTOR V);
XMVECTOR XMVector2ReciprocalLengthEst(FXMVECTOR V);
XMVECTOR XMVector2ReciprocalLength(FXMVECTOR V);
XMVECTOR XMVector2LengthEst(FXMVECTOR V);
XMVECTOR XMVector2Length(FXMVECTOR V);
XMVECTOR XMVector2NormalizeEst(FXMVECTOR V);
XMVECTOR XMVector2Normalize(FXMVECTOR V);
XMVECTOR XMVector2ClampLength(FXMVECTOR V, float LengthMin, float LengthMax);
XMVECTOR XMVector2ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax);
XMVECTOR XMVector2Reflect(FXMVECTOR Incident, FXMVECTOR Normal);
XMVECTOR XMVector2Refract(FXMVECTOR Incident, FXMVECTOR Normal, float RefractionIndex);
XMVECTOR XMVector2RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex);
XMVECTOR XMVector2Orthogonal(FXMVECTOR V);
XMVECTOR XMVector2AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2);
XMVECTOR XMVector2AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2);
XMVECTOR XMVector2AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector2LinePointDistance(FXMVECTOR LinePoint1, FXMVECTOR LinePoint2, FXMVECTOR Point);
XMVECTOR XMVector2IntersectLine(FXMVECTOR Line1Point1, FXMVECTOR Line1Point2, FXMVECTOR Line2Point1, GXMVECTOR Line2Point2);
XMVECTOR XMVector2Transform(FXMVECTOR V, CXMMATRIX M);
XMFLOAT4* XMVector2TransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) const XMFLOAT2* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M);
XMVECTOR XMVector2TransformCoord(FXMVECTOR V, CXMMATRIX M);
XMFLOAT2* XMVector2TransformCoordStream(_Out_writes_bytes_(sizeof(XMFLOAT2)+OutputStride*(VectorCount-1)) XMFLOAT2* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) const XMFLOAT2* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M);
XMVECTOR XMVector2TransformNormal(FXMVECTOR V, CXMMATRIX M);
XMFLOAT2* XMVector2TransformNormalStream(_Out_writes_bytes_(sizeof(XMFLOAT2)+OutputStride*(VectorCount-1)) XMFLOAT2* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) const XMFLOAT2* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M);
/****************************************************************************
*
* 3D vector operations
*
****************************************************************************/
bool XMVector3Equal(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector3EqualR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3EqualInt(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector3EqualIntR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
bool XMVector3NotEqual(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3NotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3Greater(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector3GreaterR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector3GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3Less(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3LessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector3InBounds(FXMVECTOR V, FXMVECTOR Bounds);
bool XMVector3IsNaN(FXMVECTOR V);
bool XMVector3IsInfinite(FXMVECTOR V);
XMVECTOR XMVector3Dot(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector3Cross(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector3LengthSq(FXMVECTOR V);
XMVECTOR XMVector3ReciprocalLengthEst(FXMVECTOR V);
XMVECTOR XMVector3ReciprocalLength(FXMVECTOR V);
XMVECTOR XMVector3LengthEst(FXMVECTOR V);
XMVECTOR XMVector3Length(FXMVECTOR V);
XMVECTOR XMVector3NormalizeEst(FXMVECTOR V);
XMVECTOR XMVector3Normalize(FXMVECTOR V);
XMVECTOR XMVector3ClampLength(FXMVECTOR V, float LengthMin, float LengthMax);
XMVECTOR XMVector3ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax);
XMVECTOR XMVector3Reflect(FXMVECTOR Incident, FXMVECTOR Normal);
XMVECTOR XMVector3Refract(FXMVECTOR Incident, FXMVECTOR Normal, float RefractionIndex);
XMVECTOR XMVector3RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex);
XMVECTOR XMVector3Orthogonal(FXMVECTOR V);
XMVECTOR XMVector3AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2);
XMVECTOR XMVector3AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2);
XMVECTOR XMVector3AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector3LinePointDistance(FXMVECTOR LinePoint1, FXMVECTOR LinePoint2, FXMVECTOR Point);
void XMVector3ComponentsFromNormal(_Out_ XMVECTOR* pParallel, _Out_ XMVECTOR* pPerpendicular, _In_ FXMVECTOR V, _In_ FXMVECTOR Normal);
XMVECTOR XMVector3Rotate(FXMVECTOR V, FXMVECTOR RotationQuaternion);
XMVECTOR XMVector3InverseRotate(FXMVECTOR V, FXMVECTOR RotationQuaternion);
XMVECTOR XMVector3Transform(FXMVECTOR V, CXMMATRIX M);
XMFLOAT4* XMVector3TransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M);
XMVECTOR XMVector3TransformCoord(FXMVECTOR V, CXMMATRIX M);
XMFLOAT3* XMVector3TransformCoordStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M);
XMVECTOR XMVector3TransformNormal(FXMVECTOR V, CXMMATRIX M);
XMFLOAT3* XMVector3TransformNormalStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M);
XMVECTOR XMVector3Project(FXMVECTOR V, float ViewportX, float ViewportY, float ViewportWidth, float ViewportHeight, float ViewportMinZ, float ViewportMaxZ,
CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World);
XMFLOAT3* XMVector3ProjectStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount,
_In_ float ViewportX, _In_ float ViewportY, _In_ float ViewportWidth, _In_ float ViewportHeight, _In_ float ViewportMinZ, _In_ float ViewportMaxZ,
_In_ CXMMATRIX Projection, _In_ CXMMATRIX View, _In_ CXMMATRIX World);
XMVECTOR XMVector3Unproject(FXMVECTOR V, float ViewportX, float ViewportY, float ViewportWidth, float ViewportHeight, float ViewportMinZ, float ViewportMaxZ,
CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World);
XMFLOAT3* XMVector3UnprojectStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount,
_In_ float ViewportX, _In_ float ViewportY, _In_ float ViewportWidth, _In_ float ViewportHeight, _In_ float ViewportMinZ, _In_ float ViewportMaxZ,
_In_ CXMMATRIX Projection, _In_ CXMMATRIX View, _In_ CXMMATRIX World);
/****************************************************************************
*
* 4D vector operations
*
****************************************************************************/
bool XMVector4Equal(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector4EqualR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4EqualInt(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector4EqualIntR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
bool XMVector4NotEqual(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4NotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4Greater(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector4GreaterR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
uint32_t XMVector4GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4Less(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4LessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
bool XMVector4InBounds(FXMVECTOR V, FXMVECTOR Bounds);
bool XMVector4IsNaN(FXMVECTOR V);
bool XMVector4IsInfinite(FXMVECTOR V);
XMVECTOR XMVector4Dot(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector4Cross(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3);
XMVECTOR XMVector4LengthSq(FXMVECTOR V);
XMVECTOR XMVector4ReciprocalLengthEst(FXMVECTOR V);
XMVECTOR XMVector4ReciprocalLength(FXMVECTOR V);
XMVECTOR XMVector4LengthEst(FXMVECTOR V);
XMVECTOR XMVector4Length(FXMVECTOR V);
XMVECTOR XMVector4NormalizeEst(FXMVECTOR V);
XMVECTOR XMVector4Normalize(FXMVECTOR V);
XMVECTOR XMVector4ClampLength(FXMVECTOR V, float LengthMin, float LengthMax);
XMVECTOR XMVector4ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax);
XMVECTOR XMVector4Reflect(FXMVECTOR Incident, FXMVECTOR Normal);
XMVECTOR XMVector4Refract(FXMVECTOR Incident, FXMVECTOR Normal, float RefractionIndex);
XMVECTOR XMVector4RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex);
XMVECTOR XMVector4Orthogonal(FXMVECTOR V);
XMVECTOR XMVector4AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2);
XMVECTOR XMVector4AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2);
XMVECTOR XMVector4AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2);
XMVECTOR XMVector4Transform(FXMVECTOR V, CXMMATRIX M);
XMFLOAT4* XMVector4TransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT4)+InputStride*(VectorCount-1)) const XMFLOAT4* pInputStream,
_In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M);
/****************************************************************************
*
* Matrix operations
*
****************************************************************************/
bool XMMatrixIsNaN(CXMMATRIX M);
bool XMMatrixIsInfinite(CXMMATRIX M);
bool XMMatrixIsIdentity(CXMMATRIX M);
XMMATRIX XMMatrixMultiply(CXMMATRIX M1, CXMMATRIX M2);
XMMATRIX XMMatrixMultiplyTranspose(CXMMATRIX M1, CXMMATRIX M2);
XMMATRIX XMMatrixTranspose(CXMMATRIX M);
XMMATRIX XMMatrixInverse(_Out_opt_ XMVECTOR* pDeterminant, _In_ CXMMATRIX M);
XMVECTOR XMMatrixDeterminant(CXMMATRIX M);
_Success_(return)
bool XMMatrixDecompose(_Out_ XMVECTOR *outScale, _Out_ XMVECTOR *outRotQuat, _Out_ XMVECTOR *outTrans, _In_ CXMMATRIX M);
XMMATRIX XMMatrixIdentity();
XMMATRIX XMMatrixSet(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33);
XMMATRIX XMMatrixTranslation(float OffsetX, float OffsetY, float OffsetZ);
XMMATRIX XMMatrixTranslationFromVector(FXMVECTOR Offset);
XMMATRIX XMMatrixScaling(float ScaleX, float ScaleY, float ScaleZ);
XMMATRIX XMMatrixScalingFromVector(FXMVECTOR Scale);
XMMATRIX XMMatrixRotationX(float Angle);
XMMATRIX XMMatrixRotationY(float Angle);
XMMATRIX XMMatrixRotationZ(float Angle);
XMMATRIX XMMatrixRotationRollPitchYaw(float Pitch, float Yaw, float Roll);
XMMATRIX XMMatrixRotationRollPitchYawFromVector(FXMVECTOR Angles);
XMMATRIX XMMatrixRotationNormal(FXMVECTOR NormalAxis, float Angle);
XMMATRIX XMMatrixRotationAxis(FXMVECTOR Axis, float Angle);
XMMATRIX XMMatrixRotationQuaternion(FXMVECTOR Quaternion);
XMMATRIX XMMatrixTransformation2D(FXMVECTOR ScalingOrigin, float ScalingOrientation, FXMVECTOR Scaling,
FXMVECTOR RotationOrigin, float Rotation, GXMVECTOR Translation);
XMMATRIX XMMatrixTransformation(FXMVECTOR ScalingOrigin, FXMVECTOR ScalingOrientationQuaternion, FXMVECTOR Scaling,
GXMVECTOR RotationOrigin, CXMVECTOR RotationQuaternion, CXMVECTOR Translation);
XMMATRIX XMMatrixAffineTransformation2D(FXMVECTOR Scaling, FXMVECTOR RotationOrigin, float Rotation, FXMVECTOR Translation);
XMMATRIX XMMatrixAffineTransformation(FXMVECTOR Scaling, FXMVECTOR RotationOrigin, FXMVECTOR RotationQuaternion, GXMVECTOR Translation);
XMMATRIX XMMatrixReflect(FXMVECTOR ReflectionPlane);
XMMATRIX XMMatrixShadow(FXMVECTOR ShadowPlane, FXMVECTOR LightPosition);
XMMATRIX XMMatrixLookAtLH(FXMVECTOR EyePosition, FXMVECTOR FocusPosition, FXMVECTOR UpDirection);
XMMATRIX XMMatrixLookAtRH(FXMVECTOR EyePosition, FXMVECTOR FocusPosition, FXMVECTOR UpDirection);
XMMATRIX XMMatrixLookToLH(FXMVECTOR EyePosition, FXMVECTOR EyeDirection, FXMVECTOR UpDirection);
XMMATRIX XMMatrixLookToRH(FXMVECTOR EyePosition, FXMVECTOR EyeDirection, FXMVECTOR UpDirection);
XMMATRIX XMMatrixPerspectiveLH(float ViewWidth, float ViewHeight, float NearZ, float FarZ);
XMMATRIX XMMatrixPerspectiveRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ);
XMMATRIX XMMatrixPerspectiveFovLH(float FovAngleY, float AspectHByW, float NearZ, float FarZ);
XMMATRIX XMMatrixPerspectiveFovRH(float FovAngleY, float AspectHByW, float NearZ, float FarZ);
XMMATRIX XMMatrixPerspectiveOffCenterLH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ);
XMMATRIX XMMatrixPerspectiveOffCenterRH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ);
XMMATRIX XMMatrixOrthographicLH(float ViewWidth, float ViewHeight, float NearZ, float FarZ);
XMMATRIX XMMatrixOrthographicRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ);
XMMATRIX XMMatrixOrthographicOffCenterLH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ);
XMMATRIX XMMatrixOrthographicOffCenterRH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ);
/****************************************************************************
*
* Quaternion operations
*
****************************************************************************/
bool XMQuaternionEqual(FXMVECTOR Q1, FXMVECTOR Q2);
bool XMQuaternionNotEqual(FXMVECTOR Q1, FXMVECTOR Q2);
bool XMQuaternionIsNaN(FXMVECTOR Q);
bool XMQuaternionIsInfinite(FXMVECTOR Q);
bool XMQuaternionIsIdentity(FXMVECTOR Q);
XMVECTOR XMQuaternionDot(FXMVECTOR Q1, FXMVECTOR Q2);
XMVECTOR XMQuaternionMultiply(FXMVECTOR Q1, FXMVECTOR Q2);
XMVECTOR XMQuaternionLengthSq(FXMVECTOR Q);
XMVECTOR XMQuaternionReciprocalLength(FXMVECTOR Q);
XMVECTOR XMQuaternionLength(FXMVECTOR Q);
XMVECTOR XMQuaternionNormalizeEst(FXMVECTOR Q);
XMVECTOR XMQuaternionNormalize(FXMVECTOR Q);
XMVECTOR XMQuaternionConjugate(FXMVECTOR Q);
XMVECTOR XMQuaternionInverse(FXMVECTOR Q);
XMVECTOR XMQuaternionLn(FXMVECTOR Q);
XMVECTOR XMQuaternionExp(FXMVECTOR Q);
XMVECTOR XMQuaternionSlerp(FXMVECTOR Q0, FXMVECTOR Q1, float t);
XMVECTOR XMQuaternionSlerpV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR T);
XMVECTOR XMQuaternionSquad(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, GXMVECTOR Q3, float t);
XMVECTOR XMQuaternionSquadV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, GXMVECTOR Q3, CXMVECTOR T);
void XMQuaternionSquadSetup(_Out_ XMVECTOR* pA, _Out_ XMVECTOR* pB, _Out_ XMVECTOR* pC, _In_ FXMVECTOR Q0, _In_ FXMVECTOR Q1, _In_ FXMVECTOR Q2, _In_ GXMVECTOR Q3);
XMVECTOR XMQuaternionBaryCentric(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, float f, float g);
XMVECTOR XMQuaternionBaryCentricV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, GXMVECTOR F, CXMVECTOR G);
XMVECTOR XMQuaternionIdentity();
XMVECTOR XMQuaternionRotationRollPitchYaw(float Pitch, float Yaw, float Roll);
XMVECTOR XMQuaternionRotationRollPitchYawFromVector(FXMVECTOR Angles);
XMVECTOR XMQuaternionRotationNormal(FXMVECTOR NormalAxis, float Angle);
XMVECTOR XMQuaternionRotationAxis(FXMVECTOR Axis, float Angle);
XMVECTOR XMQuaternionRotationMatrix(CXMMATRIX M);
void XMQuaternionToAxisAngle(_Out_ XMVECTOR* pAxis, _Out_ float* pAngle, _In_ FXMVECTOR Q);
/****************************************************************************
*
* Plane operations
*
****************************************************************************/
bool XMPlaneEqual(FXMVECTOR P1, FXMVECTOR P2);
bool XMPlaneNearEqual(FXMVECTOR P1, FXMVECTOR P2, FXMVECTOR Epsilon);
bool XMPlaneNotEqual(FXMVECTOR P1, FXMVECTOR P2);
bool XMPlaneIsNaN(FXMVECTOR P);
bool XMPlaneIsInfinite(FXMVECTOR P);
XMVECTOR XMPlaneDot(FXMVECTOR P, FXMVECTOR V);
XMVECTOR XMPlaneDotCoord(FXMVECTOR P, FXMVECTOR V);
XMVECTOR XMPlaneDotNormal(FXMVECTOR P, FXMVECTOR V);
XMVECTOR XMPlaneNormalizeEst(FXMVECTOR P);
XMVECTOR XMPlaneNormalize(FXMVECTOR P);
XMVECTOR XMPlaneIntersectLine(FXMVECTOR P, FXMVECTOR LinePoint1, FXMVECTOR LinePoint2);
void XMPlaneIntersectPlane(_Out_ XMVECTOR* pLinePoint1, _Out_ XMVECTOR* pLinePoint2, _In_ FXMVECTOR P1, _In_ FXMVECTOR P2);
XMVECTOR XMPlaneTransform(FXMVECTOR P, CXMMATRIX M);
XMFLOAT4* XMPlaneTransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(PlaneCount-1)) XMFLOAT4* pOutputStream,
_In_ size_t OutputStride,
_In_reads_bytes_(sizeof(XMFLOAT4)+InputStride*(PlaneCount-1)) const XMFLOAT4* pInputStream,
_In_ size_t InputStride, _In_ size_t PlaneCount, _In_ CXMMATRIX M);
XMVECTOR XMPlaneFromPointNormal(FXMVECTOR Point, FXMVECTOR Normal);
XMVECTOR XMPlaneFromPoints(FXMVECTOR Point1, FXMVECTOR Point2, FXMVECTOR Point3);
/****************************************************************************
*
* Color operations
*
****************************************************************************/
bool XMColorEqual(FXMVECTOR C1, FXMVECTOR C2);
bool XMColorNotEqual(FXMVECTOR C1, FXMVECTOR C2);
bool XMColorGreater(FXMVECTOR C1, FXMVECTOR C2);
bool XMColorGreaterOrEqual(FXMVECTOR C1, FXMVECTOR C2);
bool XMColorLess(FXMVECTOR C1, FXMVECTOR C2);
bool XMColorLessOrEqual(FXMVECTOR C1, FXMVECTOR C2);
bool XMColorIsNaN(FXMVECTOR C);
bool XMColorIsInfinite(FXMVECTOR C);
XMVECTOR XMColorNegative(FXMVECTOR C);
XMVECTOR XMColorModulate(FXMVECTOR C1, FXMVECTOR C2);
XMVECTOR XMColorAdjustSaturation(FXMVECTOR C, float Saturation);
XMVECTOR XMColorAdjustContrast(FXMVECTOR C, float Contrast);
XMVECTOR XMColorRGBToHSL( FXMVECTOR rgb );
XMVECTOR XMColorHSLToRGB( FXMVECTOR hsl );
XMVECTOR XMColorRGBToHSV( FXMVECTOR rgb );
XMVECTOR XMColorHSVToRGB( FXMVECTOR hsv );
XMVECTOR XMColorRGBToYUV( FXMVECTOR rgb );
XMVECTOR XMColorYUVToRGB( FXMVECTOR yuv );
XMVECTOR XMColorRGBToYUV_HD( FXMVECTOR rgb );
XMVECTOR XMColorYUVToRGB_HD( FXMVECTOR yuv );
XMVECTOR XMColorRGBToXYZ( FXMVECTOR rgb );
XMVECTOR XMColorXYZToRGB( FXMVECTOR xyz );
XMVECTOR XMColorXYZToSRGB( FXMVECTOR xyz );
XMVECTOR XMColorSRGBToXYZ( FXMVECTOR srgb );
/****************************************************************************
*
* Miscellaneous operations
*
****************************************************************************/
bool XMVerifyCPUSupport();
XMVECTOR XMFresnelTerm(FXMVECTOR CosIncidentAngle, FXMVECTOR RefractionIndex);
bool XMScalarNearEqual(float S1, float S2, float Epsilon);
float XMScalarModAngle(float Value);
float XMScalarSin(float Value);
float XMScalarSinEst(float Value);
float XMScalarCos(float Value);
float XMScalarCosEst(float Value);
void XMScalarSinCos(_Out_ float* pSin, _Out_ float* pCos, float Value);
void XMScalarSinCosEst(_Out_ float* pSin, _Out_ float* pCos, float Value);
float XMScalarASin(float Value);
float XMScalarASinEst(float Value);
float XMScalarACos(float Value);
float XMScalarACosEst(float Value);
/****************************************************************************
*
* Templates
*
****************************************************************************/
#if defined(__XNAMATH_H__) && defined(XMMin)
#undef XMMin
#undef XMMax
#endif
template<class T> inline T XMMin(T a, T b) { return (a < b) ? a : b; }
template<class T> inline T XMMax(T a, T b) { return (a > b) ? a : b; }
//------------------------------------------------------------------------------
#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
#define XM_PERMUTE_PS( v, c ) _mm_shuffle_ps( v, v, c )
// PermuteHelper internal template (SSE only)
namespace Internal
{
// Slow path fallback for permutes that do not map to a single SSE shuffle opcode.
template<uint32_t Shuffle, bool WhichX, bool WhichY, bool WhichZ, bool WhichW> struct PermuteHelper
{
static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2)
{
static const XMVECTORU32 selectMask =
{
WhichX ? 0xFFFFFFFF : 0,
WhichY ? 0xFFFFFFFF : 0,
WhichZ ? 0xFFFFFFFF : 0,
WhichW ? 0xFFFFFFFF : 0,
};
XMVECTOR shuffled1 = XM_PERMUTE_PS(v1, Shuffle);
XMVECTOR shuffled2 = XM_PERMUTE_PS(v2, Shuffle);
XMVECTOR masked1 = _mm_andnot_ps(selectMask, shuffled1);
XMVECTOR masked2 = _mm_and_ps(selectMask, shuffled2);
return _mm_or_ps(masked1, masked2);
}
};
// Fast path for permutes that only read from the first vector.
template<uint32_t Shuffle> struct PermuteHelper<Shuffle, false, false, false, false>
{
static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2) { (v2); return XM_PERMUTE_PS(v1, Shuffle); }
};
// Fast path for permutes that only read from the second vector.
template<uint32_t Shuffle> struct PermuteHelper<Shuffle, true, true, true, true>
{
static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2){ (v1); return XM_PERMUTE_PS(v2, Shuffle); }
};
// Fast path for permutes that read XY from the first vector, ZW from the second.
template<uint32_t Shuffle> struct PermuteHelper<Shuffle, false, false, true, true>
{
static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2) { return _mm_shuffle_ps(v1, v2, Shuffle); }
};
// Fast path for permutes that read XY from the second vector, ZW from the first.
template<uint32_t Shuffle> struct PermuteHelper<Shuffle, true, true, false, false>
{
static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2) { return _mm_shuffle_ps(v2, v1, Shuffle); }
};
};
#endif // _XM_SSE_INTRINSICS_ && !_XM_NO_INTRINSICS_
// General permute template
template<uint32_t PermuteX, uint32_t PermuteY, uint32_t PermuteZ, uint32_t PermuteW>
inline XMVECTOR XMVectorPermute(FXMVECTOR V1, FXMVECTOR V2)
{
static_assert(PermuteX <= 7, "PermuteX template parameter out of range");
static_assert(PermuteY <= 7, "PermuteY template parameter out of range");
static_assert(PermuteZ <= 7, "PermuteZ template parameter out of range");
static_assert(PermuteW <= 7, "PermuteW template parameter out of range");
#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
const uint32_t Shuffle = _MM_SHUFFLE(PermuteW & 3, PermuteZ & 3, PermuteY & 3, PermuteX & 3);
const bool WhichX = PermuteX > 3;
const bool WhichY = PermuteY > 3;
const bool WhichZ = PermuteZ > 3;
const bool WhichW = PermuteW > 3;
return Internal::PermuteHelper<Shuffle, WhichX, WhichY, WhichZ, WhichW>::Permute(V1, V2);
#else
return XMVectorPermute( V1, V2, PermuteX, PermuteY, PermuteZ, PermuteW );
#endif
}
// Special-case permute templates
template<> inline XMVECTOR XMVectorPermute<0,1,2,3>(FXMVECTOR V1, FXMVECTOR V2) { (V2); return V1; }
template<> inline XMVECTOR XMVectorPermute<4,5,6,7>(FXMVECTOR V1, FXMVECTOR V2) { (V1); return V2; }
#if defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
// If the indices are all in the range 0-3 or 4-7, then use XMVectorSwizzle instead
// The mirror cases are not spelled out here as the programmer can always swap the arguments
// (i.e. prefer permutes where the X element comes from the V1 vector instead of the V2 vector)
template<> inline XMVECTOR XMVectorPermute<0,1,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vget_low_f32(V2) ); }
template<> inline XMVECTOR XMVectorPermute<1,0,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vget_low_f32(V2) ); }
template<> inline XMVECTOR XMVectorPermute<0,1,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vrev64_f32( vget_low_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<1,0,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vrev64_f32( vget_low_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<2,3,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_high_f32(V1), vget_high_f32(V2) ); }
template<> inline XMVECTOR XMVectorPermute<3,2,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vget_high_f32(V2) ); }
template<> inline XMVECTOR XMVectorPermute<2,3,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_high_f32(V1), vrev64_f32( vget_high_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<3,2,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vrev64_f32( vget_high_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<0,1,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vget_high_f32(V2) ); }
template<> inline XMVECTOR XMVectorPermute<1,0,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vget_high_f32(V2) ); }
template<> inline XMVECTOR XMVectorPermute<0,1,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vrev64_f32( vget_high_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<1,0,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vrev64_f32( vget_high_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<3,2,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vget_low_f32(V2) ); }
template<> inline XMVECTOR XMVectorPermute<2,3,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_high_f32(V1), vrev64_f32( vget_low_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<3,2,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vrev64_f32( vget_low_f32(V2) ) ); }
template<> inline XMVECTOR XMVectorPermute<0,4,2,6>(FXMVECTOR V1, FXMVECTOR V2) { return vtrnq_f32(V1,V2).val[0]; }
template<> inline XMVECTOR XMVectorPermute<1,5,3,7>(FXMVECTOR V1, FXMVECTOR V2) { return vtrnq_f32(V1,V2).val[1]; }
template<> inline XMVECTOR XMVectorPermute<0,4,1,5>(FXMVECTOR V1, FXMVECTOR V2) { return vzipq_f32(V1,V2).val[0]; }
template<> inline XMVECTOR XMVectorPermute<2,6,3,7>(FXMVECTOR V1, FXMVECTOR V2) { return vzipq_f32(V1,V2).val[1]; }
template<> inline XMVECTOR XMVectorPermute<0,2,4,6>(FXMVECTOR V1, FXMVECTOR V2) { return vuzpq_f32(V1,V2).val[0]; }
template<> inline XMVECTOR XMVectorPermute<1,3,5,7>(FXMVECTOR V1, FXMVECTOR V2) { return vuzpq_f32(V1,V2).val[1]; }
template<> inline XMVECTOR XMVectorPermute<1,2,3,4>(FXMVECTOR V1, FXMVECTOR V2) { return vextq_f32(V1, V2, 1); }
template<> inline XMVECTOR XMVectorPermute<2,3,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vextq_f32(V1, V2, 2); }
template<> inline XMVECTOR XMVectorPermute<3,4,5,6>(FXMVECTOR V1, FXMVECTOR V2) { return vextq_f32(V1, V2, 3); }
#endif // _XM_ARM_NEON_INTRINSICS_ && !_XM_NO_INTRINSICS_
//------------------------------------------------------------------------------
// General swizzle template
template<uint32_t SwizzleX, uint32_t SwizzleY, uint32_t SwizzleZ, uint32_t SwizzleW>
inline XMVECTOR XMVectorSwizzle(FXMVECTOR V)
{
static_assert(SwizzleX <= 3, "SwizzleX template parameter out of range");
static_assert(SwizzleY <= 3, "SwizzleY template parameter out of range");
static_assert(SwizzleZ <= 3, "SwizzleZ template parameter out of range");
static_assert(SwizzleW <= 3, "SwizzleW template parameter out of range");
#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
return XM_PERMUTE_PS( V, _MM_SHUFFLE( SwizzleW, SwizzleZ, SwizzleY, SwizzleX ) );
#elif defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
return __vpermwi(V, ((SwizzleX & 3) << 6) | ((SwizzleY & 3) << 4) | ((SwizzleZ & 3) << 2) | (SwizzleW & 3) );
#else
return XMVectorSwizzle( V, SwizzleX, SwizzleY, SwizzleZ, SwizzleW );
#endif
}
// Specialized swizzles
template<> inline XMVECTOR XMVectorSwizzle<0,1,2,3>(FXMVECTOR V) { return V; }
#if defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
template<> inline XMVECTOR XMVectorSwizzle<0,0,0,0>(FXMVECTOR V) { return vdupq_lane_f32( vget_low_f32(V), 0); }
template<> inline XMVECTOR XMVectorSwizzle<1,1,1,1>(FXMVECTOR V) { return vdupq_lane_f32( vget_low_f32(V), 1); }
template<> inline XMVECTOR XMVectorSwizzle<2,2,2,2>(FXMVECTOR V) { return vdupq_lane_f32( vget_high_f32(V), 0); }
template<> inline XMVECTOR XMVectorSwizzle<3,3,3,3>(FXMVECTOR V) { return vdupq_lane_f32( vget_high_f32(V), 1); }
template<> inline XMVECTOR XMVectorSwizzle<1,0,3,2>(FXMVECTOR V) { return vrev64q_f32(V); }
template<> inline XMVECTOR XMVectorSwizzle<0,1,0,1>(FXMVECTOR V) { __n64 vt = vget_low_f32(V); return vcombine_f32( vt, vt ); }
template<> inline XMVECTOR XMVectorSwizzle<2,3,2,3>(FXMVECTOR V) { __n64 vt = vget_high_f32(V); return vcombine_f32( vt, vt ); }
template<> inline XMVECTOR XMVectorSwizzle<1,0,1,0>(FXMVECTOR V) { __n64 vt = vrev64_f32( vget_low_f32(V) ); return vcombine_f32( vt, vt ); }
template<> inline XMVECTOR XMVectorSwizzle<3,2,3,2>(FXMVECTOR V) { __n64 vt = vrev64_f32( vget_high_f32(V) ); return vcombine_f32( vt, vt ); }
template<> inline XMVECTOR XMVectorSwizzle<0,1,3,2>(FXMVECTOR V) { return vcombine_f32( vget_low_f32(V), vrev64_f32( vget_high_f32(V) ) ); }
template<> inline XMVECTOR XMVectorSwizzle<1,0,2,3>(FXMVECTOR V) { return vcombine_f32( vrev64_f32( vget_low_f32(V) ), vget_high_f32(V) ); }
template<> inline XMVECTOR XMVectorSwizzle<2,3,1,0>(FXMVECTOR V) { return vcombine_f32( vget_high_f32(V), vrev64_f32( vget_low_f32(V) ) ); }
template<> inline XMVECTOR XMVectorSwizzle<3,2,0,1>(FXMVECTOR V) { return vcombine_f32( vrev64_f32( vget_high_f32(V) ), vget_low_f32(V) ); }
template<> inline XMVECTOR XMVectorSwizzle<3,2,1,0>(FXMVECTOR V) { return vcombine_f32( vrev64_f32( vget_high_f32(V) ), vrev64_f32( vget_low_f32(V) ) ); }
template<> inline XMVECTOR XMVectorSwizzle<0,0,2,2>(FXMVECTOR V) { return vtrnq_f32(V,V).val[0]; }
template<> inline XMVECTOR XMVectorSwizzle<1,1,3,3>(FXMVECTOR V) { return vtrnq_f32(V,V).val[1]; }
template<> inline XMVECTOR XMVectorSwizzle<0,0,1,1>(FXMVECTOR V) { return vzipq_f32(V,V).val[0]; }
template<> inline XMVECTOR XMVectorSwizzle<2,2,3,3>(FXMVECTOR V) { return vzipq_f32(V,V).val[1]; }
template<> inline XMVECTOR XMVectorSwizzle<0,2,0,2>(FXMVECTOR V) { return vuzpq_f32(V,V).val[0]; }
template<> inline XMVECTOR XMVectorSwizzle<1,3,1,3>(FXMVECTOR V) { return vuzpq_f32(V,V).val[1]; }
template<> inline XMVECTOR XMVectorSwizzle<1,2,3,0>(FXMVECTOR V) { return vextq_f32(V, V, 1); }
template<> inline XMVECTOR XMVectorSwizzle<2,3,0,1>(FXMVECTOR V) { return vextq_f32(V, V, 2); }
template<> inline XMVECTOR XMVectorSwizzle<3,0,1,2>(FXMVECTOR V) { return vextq_f32(V, V, 3); }
#endif // _XM_ARM_NEON_INTRINSICS_ && !_XM_NO_INTRINSICS_
//------------------------------------------------------------------------------
template<uint32_t Elements>
inline XMVECTOR XMVectorShiftLeft(FXMVECTOR V1, FXMVECTOR V2)
{
static_assert( Elements < 4, "Elements template parameter out of range" );
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
#else
return XMVectorPermute<Elements, (Elements + 1), (Elements + 2), (Elements + 3)>(V1, V2);
#endif
}
template<uint32_t Elements>
inline XMVECTOR XMVectorRotateLeft(FXMVECTOR V)
{
static_assert( Elements < 4, "Elements template parameter out of range" );
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
#else
return XMVectorSwizzle<Elements & 3, (Elements + 1) & 3, (Elements + 2) & 3, (Elements + 3) & 3>(V);
#endif
}
template<uint32_t Elements>
inline XMVECTOR XMVectorRotateRight(FXMVECTOR V)
{
static_assert( Elements < 4, "Elements template parameter out of range" );
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
#else
return XMVectorSwizzle<(4 - Elements) & 3, (5 - Elements) & 3, (6 - Elements) & 3, (7 - Elements) & 3>(V);
#endif
}
template<uint32_t VSLeftRotateElements, uint32_t Select0, uint32_t Select1, uint32_t Select2, uint32_t Select3>
inline XMVECTOR XMVectorInsert(FXMVECTOR VD, FXMVECTOR VS)
{
#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
#else
XMVECTOR Control = XMVectorSelectControl(Select0&1, Select1&1, Select2&1, Select3&1);
return XMVectorSelect( VD, XMVectorRotateLeft<VSLeftRotateElements>(VS), Control );
#endif
}
/****************************************************************************
*
* Globals
*
****************************************************************************/
// The purpose of the following global constants is to prevent redundant
// reloading of the constants when they are referenced by more than one
// separate inline math routine called within the same function. Declaring
// a constant locally within a routine is sufficient to prevent redundant
// reloads of that constant when that single routine is called multiple
// times in a function, but if the constant is used (and declared) in a
// separate math routine it would be reloaded.
#ifndef XMGLOBALCONST
#define XMGLOBALCONST static const // extern const // MGH - __declspec(selectany)
#endif
XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients0 = {-0.16666667f, +0.0083333310f, -0.00019840874f, +2.7525562e-06f};
XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients1 = {-2.3889859e-08f, -0.16665852f /*Est1*/, +0.0083139502f /*Est2*/, -0.00018524670f /*Est3*/};
XMGLOBALCONST XMVECTORF32 g_XMCosCoefficients0 = {-0.5f, +0.041666638f, -0.0013888378f, +2.4760495e-05f};
XMGLOBALCONST XMVECTORF32 g_XMCosCoefficients1 = {-2.6051615e-07f, -0.49992746f /*Est1*/, +0.041493919f /*Est2*/, -0.0012712436f /*Est3*/};
XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients0 = {1.0f, 0.333333333f, 0.133333333f, 5.396825397e-2f};
XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients1 = {2.186948854e-2f, 8.863235530e-3f, 3.592128167e-3f, 1.455834485e-3f};
XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients2 = {5.900274264e-4f, 2.391290764e-4f, 9.691537707e-5f, 3.927832950e-5f};
XMGLOBALCONST XMVECTORF32 g_XMArcCoefficients0 = {+1.5707963050f, -0.2145988016f, +0.0889789874f, -0.0501743046f};
XMGLOBALCONST XMVECTORF32 g_XMArcCoefficients1 = {+0.0308918810f, -0.0170881256f, +0.0066700901f, -0.0012624911f};
XMGLOBALCONST XMVECTORF32 g_XMATanCoefficients0 = {-0.3333314528f, +0.1999355085f, -0.1420889944f, +0.1065626393f};
XMGLOBALCONST XMVECTORF32 g_XMATanCoefficients1 = {-0.0752896400f, +0.0429096138f, -0.0161657367f, +0.0028662257f};
XMGLOBALCONST XMVECTORF32 g_XMATanEstCoefficients0 = {+0.999866f, +0.999866f, +0.999866f, +0.999866f};
XMGLOBALCONST XMVECTORF32 g_XMATanEstCoefficients1 = {-0.3302995f, +0.180141f, -0.085133f, +0.0208351f};
XMGLOBALCONST XMVECTORF32 g_XMTanEstCoefficients = {2.484f, -1.954923183e-1f, 2.467401101f, XM_1DIVPI};
XMGLOBALCONST XMVECTORF32 g_XMArcEstCoefficients = {+1.5707288f,-0.2121144f,+0.0742610f,-0.0187293f};
XMGLOBALCONST XMVECTORF32 g_XMPiConstants0 = {XM_PI, XM_2PI, XM_1DIVPI, XM_1DIV2PI};
XMGLOBALCONST XMVECTORF32 g_XMIdentityR0 = {1.0f, 0.0f, 0.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMIdentityR1 = {0.0f, 1.0f, 0.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMIdentityR2 = {0.0f, 0.0f, 1.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMIdentityR3 = {0.0f, 0.0f, 0.0f, 1.0f};
XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR0 = {-1.0f,0.0f, 0.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR1 = {0.0f,-1.0f, 0.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR2 = {0.0f, 0.0f,-1.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR3 = {0.0f, 0.0f, 0.0f,-1.0f};
XMGLOBALCONST XMVECTORI32 g_XMNegativeZero = {0x80000000, 0x80000000, 0x80000000, 0x80000000};
XMGLOBALCONST XMVECTORI32 g_XMNegate3 = {0x80000000, 0x80000000, 0x80000000, 0x00000000};
XMGLOBALCONST XMVECTORI32 g_XMMask3 = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000};
XMGLOBALCONST XMVECTORI32 g_XMMaskX = {0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000};
XMGLOBALCONST XMVECTORI32 g_XMMaskY = {0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000};
XMGLOBALCONST XMVECTORI32 g_XMMaskZ = {0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000};
XMGLOBALCONST XMVECTORI32 g_XMMaskW = {0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF};
XMGLOBALCONST XMVECTORF32 g_XMOne = { 1.0f, 1.0f, 1.0f, 1.0f};
XMGLOBALCONST XMVECTORF32 g_XMOne3 = { 1.0f, 1.0f, 1.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMZero = { 0.0f, 0.0f, 0.0f, 0.0f};
XMGLOBALCONST XMVECTORF32 g_XMTwo = { 2.f, 2.f, 2.f, 2.f };
XMGLOBALCONST XMVECTORF32 g_XMFour = { 4.f, 4.f, 4.f, 4.f };
XMGLOBALCONST XMVECTORF32 g_XMSix = { 6.f, 6.f, 6.f, 6.f };
XMGLOBALCONST XMVECTORF32 g_XMNegativeOne = {-1.0f,-1.0f,-1.0f,-1.0f};
XMGLOBALCONST XMVECTORF32 g_XMOneHalf = { 0.5f, 0.5f, 0.5f, 0.5f};
XMGLOBALCONST XMVECTORF32 g_XMNegativeOneHalf = {-0.5f,-0.5f,-0.5f,-0.5f};
XMGLOBALCONST XMVECTORF32 g_XMNegativeTwoPi = {-XM_2PI, -XM_2PI, -XM_2PI, -XM_2PI};
XMGLOBALCONST XMVECTORF32 g_XMNegativePi = {-XM_PI, -XM_PI, -XM_PI, -XM_PI};
XMGLOBALCONST XMVECTORF32 g_XMHalfPi = {XM_PIDIV2, XM_PIDIV2, XM_PIDIV2, XM_PIDIV2};
XMGLOBALCONST XMVECTORF32 g_XMPi = {XM_PI, XM_PI, XM_PI, XM_PI};
XMGLOBALCONST XMVECTORF32 g_XMReciprocalPi = {XM_1DIVPI, XM_1DIVPI, XM_1DIVPI, XM_1DIVPI};
XMGLOBALCONST XMVECTORF32 g_XMTwoPi = {XM_2PI, XM_2PI, XM_2PI, XM_2PI};
XMGLOBALCONST XMVECTORF32 g_XMReciprocalTwoPi = {XM_1DIV2PI, XM_1DIV2PI, XM_1DIV2PI, XM_1DIV2PI};
XMGLOBALCONST XMVECTORF32 g_XMEpsilon = {1.192092896e-7f, 1.192092896e-7f, 1.192092896e-7f, 1.192092896e-7f};
XMGLOBALCONST XMVECTORI32 g_XMInfinity = {0x7F800000, 0x7F800000, 0x7F800000, 0x7F800000};
XMGLOBALCONST XMVECTORI32 g_XMQNaN = {0x7FC00000, 0x7FC00000, 0x7FC00000, 0x7FC00000};
XMGLOBALCONST XMVECTORI32 g_XMQNaNTest = {0x007FFFFF, 0x007FFFFF, 0x007FFFFF, 0x007FFFFF};
XMGLOBALCONST XMVECTORI32 g_XMAbsMask = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
XMGLOBALCONST XMVECTORI32 g_XMFltMin = {0x00800000, 0x00800000, 0x00800000, 0x00800000};
XMGLOBALCONST XMVECTORI32 g_XMFltMax = {0x7F7FFFFF, 0x7F7FFFFF, 0x7F7FFFFF, 0x7F7FFFFF};
XMGLOBALCONST XMVECTORI32 g_XMNegOneMask = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
XMGLOBALCONST XMVECTORI32 g_XMMaskA8R8G8B8 = {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000};
XMGLOBALCONST XMVECTORI32 g_XMFlipA8R8G8B8 = {0x00000000, 0x00000000, 0x00000000, 0x80000000};
XMGLOBALCONST XMVECTORF32 g_XMFixAA8R8G8B8 = {0.0f,0.0f,0.0f,(float)(0x80000000U)};
XMGLOBALCONST XMVECTORF32 g_XMNormalizeA8R8G8B8 = {1.0f/(255.0f*(float)(0x10000)),1.0f/(255.0f*(float)(0x100)),1.0f/255.0f,1.0f/(255.0f*(float)(0x1000000))};
XMGLOBALCONST XMVECTORI32 g_XMMaskA2B10G10R10 = {0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000};
XMGLOBALCONST XMVECTORI32 g_XMFlipA2B10G10R10 = {0x00000200, 0x00080000, 0x20000000, 0x80000000};
XMGLOBALCONST XMVECTORF32 g_XMFixAA2B10G10R10 = {-512.0f,-512.0f*(float)(0x400),-512.0f*(float)(0x100000),(float)(0x80000000U)};
XMGLOBALCONST XMVECTORF32 g_XMNormalizeA2B10G10R10 = {1.0f/511.0f,1.0f/(511.0f*(float)(0x400)),1.0f/(511.0f*(float)(0x100000)),1.0f/(3.0f*(float)(0x40000000))};
XMGLOBALCONST XMVECTORI32 g_XMMaskX16Y16 = {0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000};
XMGLOBALCONST XMVECTORI32 g_XMFlipX16Y16 = {0x00008000, 0x00000000, 0x00000000, 0x00000000};
XMGLOBALCONST XMVECTORF32 g_XMFixX16Y16 = {-32768.0f,0.0f,0.0f,0.0f};
XMGLOBALCONST XMVECTORF32 g_XMNormalizeX16Y16 = {1.0f/32767.0f,1.0f/(32767.0f*65536.0f),0.0f,0.0f};
XMGLOBALCONST XMVECTORI32 g_XMMaskX16Y16Z16W16 = {0x0000FFFF, 0x0000FFFF, 0xFFFF0000, 0xFFFF0000};
XMGLOBALCONST XMVECTORI32 g_XMFlipX16Y16Z16W16 = {0x00008000, 0x00008000, 0x00000000, 0x00000000};
XMGLOBALCONST XMVECTORF32 g_XMFixX16Y16Z16W16 = {-32768.0f,-32768.0f,0.0f,0.0f};
XMGLOBALCONST XMVECTORF32 g_XMNormalizeX16Y16Z16W16 = {1.0f/32767.0f,1.0f/32767.0f,1.0f/(32767.0f*65536.0f),1.0f/(32767.0f*65536.0f)};
XMGLOBALCONST XMVECTORF32 g_XMNoFraction = {8388608.0f,8388608.0f,8388608.0f,8388608.0f};
XMGLOBALCONST XMVECTORI32 g_XMMaskByte = {0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF};
XMGLOBALCONST XMVECTORF32 g_XMNegateX = {-1.0f, 1.0f, 1.0f, 1.0f};
XMGLOBALCONST XMVECTORF32 g_XMNegateY = { 1.0f,-1.0f, 1.0f, 1.0f};
XMGLOBALCONST XMVECTORF32 g_XMNegateZ = { 1.0f, 1.0f,-1.0f, 1.0f};
XMGLOBALCONST XMVECTORF32 g_XMNegateW = { 1.0f, 1.0f, 1.0f,-1.0f};
XMGLOBALCONST XMVECTORI32 g_XMSelect0101 = {XM_SELECT_0, XM_SELECT_1, XM_SELECT_0, XM_SELECT_1};
XMGLOBALCONST XMVECTORI32 g_XMSelect1010 = {XM_SELECT_1, XM_SELECT_0, XM_SELECT_1, XM_SELECT_0};
XMGLOBALCONST XMVECTORI32 g_XMOneHalfMinusEpsilon = { 0x3EFFFFFD, 0x3EFFFFFD, 0x3EFFFFFD, 0x3EFFFFFD};
XMGLOBALCONST XMVECTORI32 g_XMSelect1000 = {XM_SELECT_1, XM_SELECT_0, XM_SELECT_0, XM_SELECT_0};
XMGLOBALCONST XMVECTORI32 g_XMSelect1100 = {XM_SELECT_1, XM_SELECT_1, XM_SELECT_0, XM_SELECT_0};
XMGLOBALCONST XMVECTORI32 g_XMSelect1110 = {XM_SELECT_1, XM_SELECT_1, XM_SELECT_1, XM_SELECT_0};
XMGLOBALCONST XMVECTORI32 g_XMSelect1011 = { XM_SELECT_1, XM_SELECT_0, XM_SELECT_1, XM_SELECT_1 };
XMGLOBALCONST XMVECTORF32 g_XMFixupY16 = {1.0f,1.0f/65536.0f,0.0f,0.0f};
XMGLOBALCONST XMVECTORF32 g_XMFixupY16W16 = {1.0f,1.0f,1.0f/65536.0f,1.0f/65536.0f};
XMGLOBALCONST XMVECTORI32 g_XMFlipY = {0,0x80000000,0,0};
XMGLOBALCONST XMVECTORI32 g_XMFlipZ = {0,0,0x80000000,0};
XMGLOBALCONST XMVECTORI32 g_XMFlipW = {0,0,0,0x80000000};
XMGLOBALCONST XMVECTORI32 g_XMFlipYZ = {0,0x80000000,0x80000000,0};
XMGLOBALCONST XMVECTORI32 g_XMFlipZW = {0,0,0x80000000,0x80000000};
XMGLOBALCONST XMVECTORI32 g_XMFlipYW = {0,0x80000000,0,0x80000000};
XMGLOBALCONST XMVECTORI32 g_XMMaskDec4 = {0x3FF,0x3FF<<10,0x3FF<<20,0x3<<30};
XMGLOBALCONST XMVECTORI32 g_XMXorDec4 = {0x200,0x200<<10,0x200<<20,0};
XMGLOBALCONST XMVECTORF32 g_XMAddUDec4 = {0,0,0,32768.0f*65536.0f};
XMGLOBALCONST XMVECTORF32 g_XMAddDec4 = {-512.0f,-512.0f*1024.0f,-512.0f*1024.0f*1024.0f,0};
XMGLOBALCONST XMVECTORF32 g_XMMulDec4 = {1.0f,1.0f/1024.0f,1.0f/(1024.0f*1024.0f),1.0f/(1024.0f*1024.0f*1024.0f)};
XMGLOBALCONST XMVECTORI32 g_XMMaskByte4 = {0xFF,0xFF00,0xFF0000,0xFF000000};
XMGLOBALCONST XMVECTORI32 g_XMXorByte4 = {0x80,0x8000,0x800000,0x00000000};
XMGLOBALCONST XMVECTORF32 g_XMAddByte4 = {-128.0f,-128.0f*256.0f,-128.0f*65536.0f,0};
XMGLOBALCONST XMVECTORF32 g_XMFixUnsigned = {32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f};
XMGLOBALCONST XMVECTORF32 g_XMMaxInt = {65536.0f*32768.0f-128.0f,65536.0f*32768.0f-128.0f,65536.0f*32768.0f-128.0f,65536.0f*32768.0f-128.0f};
XMGLOBALCONST XMVECTORF32 g_XMMaxUInt = {65536.0f*65536.0f-256.0f,65536.0f*65536.0f-256.0f,65536.0f*65536.0f-256.0f,65536.0f*65536.0f-256.0f};
XMGLOBALCONST XMVECTORF32 g_XMUnsignedFix = {32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f};
XMGLOBALCONST XMVECTORF32 g_XMsrgbScale = { 12.92f, 12.92f, 12.92f, 1.0f };
XMGLOBALCONST XMVECTORF32 g_XMsrgbA = { 0.055f, 0.055f, 0.055f, 0.0f };
XMGLOBALCONST XMVECTORF32 g_XMsrgbA1 = { 1.055f, 1.055f, 1.055f, 1.0f };
/****************************************************************************
*
* Implementation
*
****************************************************************************/
#pragma warning(push)
#pragma warning(disable:4068 4214 4204 4365 4616 4640 6001)
#pragma prefast(push)
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")
//------------------------------------------------------------------------------
#if defined(_XM_NO_INTRINSICS_) || defined(_XM_SSE_INTRINSICS_) || defined(_XM_ARM_NEON_INTRINSICS_)
inline XMVECTOR XMVectorSetBinaryConstant(uint32_t C0, uint32_t C1, uint32_t C2, uint32_t C3)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTORU32 vResult;
vResult.u[0] = (0-(C0&1)) & 0x3F800000;
vResult.u[1] = (0-(C1&1)) & 0x3F800000;
vResult.u[2] = (0-(C2&1)) & 0x3F800000;
vResult.u[3] = (0-(C3&1)) & 0x3F800000;
return vResult.v;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
XMVECTORU32 vResult;
vResult.u[0] = (0-(C0&1)) & 0x3F800000;
vResult.u[1] = (0-(C1&1)) & 0x3F800000;
vResult.u[2] = (0-(C2&1)) & 0x3F800000;
vResult.u[3] = (0-(C3&1)) & 0x3F800000;
return vResult.v;
#else // XM_SSE_INTRINSICS_
static const XMVECTORU32 g_vMask1 = {1,1,1,1};
// Move the parms to a vector
__m128i vTemp = _mm_set_epi32(C3,C2,C1,C0);
// Mask off the low bits
vTemp = _mm_and_si128(vTemp,g_vMask1);
// 0xFFFFFFFF on true bits
vTemp = _mm_cmpeq_epi32(vTemp,g_vMask1);
// 0xFFFFFFFF -> 1.0f, 0x00000000 -> 0.0f
vTemp = _mm_and_si128(vTemp,g_XMOne);
return _mm_castsi128_ps(vTemp);
#endif
}
//------------------------------------------------------------------------------
inline XMVECTOR XMVectorSplatConstant(int32_t IntConstant, uint32_t DivExponent)
{
assert( IntConstant >= -16 && IntConstant <= 15 );
assert( DivExponent < 32 );
#if defined(_XM_NO_INTRINSICS_)
using DirectX::XMConvertVectorIntToFloat;
XMVECTORI32 V = { IntConstant, IntConstant, IntConstant, IntConstant };
return XMConvertVectorIntToFloat( V.v, DivExponent);
#elif defined(_XM_ARM_NEON_INTRINSICS_)
// Splat the int
int32x4_t vScale = vdupq_n_s32(IntConstant);
// Convert to a float
XMVECTOR vResult = vcvtq_f32_s32(vScale);
// Convert DivExponent into 1.0f/(1<<DivExponent)
uint32_t uScale = 0x3F800000U - (DivExponent << 23);
// Splat the scalar value (It's really a float)
vScale = vdupq_n_s32(uScale);
// Multiply by the reciprocal (Perform a right shift by DivExponent)
vResult = vmulq_f32(vResult,reinterpret_cast<const float32x4_t *>(&vScale)[0]);
return vResult;
#else // XM_SSE_INTRINSICS_
// Splat the int
__m128i vScale = _mm_set1_epi32(IntConstant);
// Convert to a float
XMVECTOR vResult = _mm_cvtepi32_ps(vScale);
// Convert DivExponent into 1.0f/(1<<DivExponent)
uint32_t uScale = 0x3F800000U - (DivExponent << 23);
// Splat the scalar value (It's really a float)
vScale = _mm_set1_epi32(uScale);
// Multiply by the reciprocal (Perform a right shift by DivExponent)
vResult = _mm_mul_ps(vResult,_mm_castsi128_ps(vScale));
return vResult;
#endif
}
//------------------------------------------------------------------------------
inline XMVECTOR XMVectorSplatConstantInt(int32_t IntConstant)
{
assert( IntConstant >= -16 && IntConstant <= 15 );
#if defined(_XM_NO_INTRINSICS_)
XMVECTORI32 V = { IntConstant, IntConstant, IntConstant, IntConstant };
return V.v;
#elif defined(_XM_ARM_NEON_INTRINSICS_)
int32x4_t V = vdupq_n_s32( IntConstant );
return reinterpret_cast<float32x4_t *>(&V)[0];
#else // XM_SSE_INTRINSICS_
__m128i V = _mm_set1_epi32( IntConstant );
return reinterpret_cast<__m128 *>(&V)[0];
#endif
}
// Implemented for VMX128 intrinsics as #defines aboves
#endif // _XM_NO_INTRINSICS_ || _XM_SSE_INTRINSICS_ || _XM_ARM_NEON_INTRINSICS_
#include "DirectXMathConvert.inl"
#include "DirectXMathVector.inl"
#include "DirectXMathMatrix.inl"
#include "DirectXMathMisc.inl"
#pragma prefast(pop)
#pragma warning(pop)
}; // namespace DirectX
|