Subversion Repositories Games.Chess Giants

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*++
  2.  
  3. Copyright (c) Microsoft Corporation. All rights reserved.
  4.  
  5. Module Name:
  6.  
  7.     xnamath.h
  8.  
  9. Abstract:
  10.  
  11.         XNA math library for Windows and Xbox 360
  12. --*/
  13.  
  14. #if defined(_MSC_VER) && (_MSC_VER > 1000)
  15. #pragma once
  16. #endif
  17.  
  18. #ifndef __XNAMATH_H__
  19. #define __XNAMATH_H__
  20.  
  21. #ifdef __XBOXMATH_H__
  22. #error XNAMATH and XBOXMATH are incompatible in the same compilation module. Use one or the other.
  23. #endif
  24.  
  25. #define XNAMATH_VERSION 201
  26.  
  27. #if !defined(_XM_X64_) && !defined(_XM_X86_)
  28. #if defined(_M_AMD64) || defined(_AMD64_)
  29. #define _XM_X64_
  30. #elif defined(_M_IX86) || defined(_X86_)
  31. #define _XM_X86_
  32. #endif
  33. #endif
  34.  
  35. #if defined(_XM_X86_) || defined(_XM_X64_)
  36. #define _XM_SSE_INTRINSICS_
  37. #if !defined(__cplusplus) && !defined(_XM_NO_INTRINSICS_)
  38. #error xnamath.h only supports C compliation for Xbox 360 targets and no intrinsics cases for x86/x64
  39. #endif
  40. #elif defined(_XBOX_VER)
  41. #if !defined(__VMX128_SUPPORTED) && !defined(_XM_NO_INTRINSICS_)
  42. #error xnamath.h requires VMX128 compiler support for XBOX 360
  43. #endif // !__VMX128_SUPPORTED && !_XM_NO_INTRINSICS_
  44. #define _XM_VMX128_INTRINSICS_
  45. #else
  46. #error xnamath.h only supports x86, x64, or XBox 360 targets
  47. #endif
  48.  
  49.  
  50. #if defined(_XM_SSE_INTRINSICS_)
  51. #ifndef _XM_NO_INTRINSICS_
  52. #include <xmmintrin.h>
  53. #include <emmintrin.h>
  54. #endif
  55. #elif defined(_XM_VMX128_INTRINSICS_)
  56. #error This version of xnamath.h is for Windows use only
  57. #endif
  58.  
  59. #if defined(_XM_SSE_INTRINSICS_)
  60. #pragma warning(push)
  61. #pragma warning(disable:4985)
  62. #endif
  63. #include <math.h>
  64. #if defined(_XM_SSE_INTRINSICS_)
  65. #pragma warning(pop)
  66. #endif
  67.  
  68. #include <sal.h>
  69.  
  70. #if !defined(XMINLINE)
  71. #if !defined(XM_NO_MISALIGNED_VECTOR_ACCESS)
  72. #define XMINLINE __inline
  73. #else
  74. #define XMINLINE __forceinline
  75. #endif
  76. #endif
  77.  
  78. #if !defined(XMFINLINE)
  79. #define XMFINLINE __forceinline
  80. #endif
  81.  
  82. #if !defined(XMDEBUG)
  83. #if defined(_DEBUG)
  84. #define XMDEBUG
  85. #endif
  86. #endif // !XMDEBUG
  87.  
  88. #if !defined(XMASSERT)
  89. #if defined(_PREFAST_)
  90. #define XMASSERT(Expression) __analysis_assume((Expression))
  91. #elif defined(XMDEBUG) // !_PREFAST_
  92. #define XMASSERT(Expression) ((VOID)((Expression) || (XMAssert(#Expression, __FILE__, __LINE__), 0)))
  93. #else // !XMDEBUG
  94. #define XMASSERT(Expression) ((VOID)0)
  95. #endif // !XMDEBUG
  96. #endif // !XMASSERT
  97.  
  98. #if !defined(XM_NO_ALIGNMENT)
  99. #define _DECLSPEC_ALIGN_16_   __declspec(align(16))
  100. #else
  101. #define _DECLSPEC_ALIGN_16_
  102. #endif
  103.  
  104.  
  105. #if defined(_MSC_VER) && (_MSC_VER<1500) && (_MSC_VER>=1400)
  106. #define _XM_ISVS2005_
  107. #endif
  108.  
  109. #if defined(_MSC_VER) && (_MSC_VER<1600) && (_MSC_VER>=1500)
  110. #define _XM_ISVS2008_
  111. #endif
  112.  
  113. /****************************************************************************
  114.  *
  115.  * Constant definitions
  116.  *
  117.  ****************************************************************************/
  118.  
  119. #define XM_PI               3.141592654f
  120. #define XM_2PI              6.283185307f
  121. #define XM_1DIVPI           0.318309886f
  122. #define XM_1DIV2PI          0.159154943f
  123. #define XM_PIDIV2           1.570796327f
  124. #define XM_PIDIV4           0.785398163f
  125.  
  126. #define XM_SELECT_0         0x00000000
  127. #define XM_SELECT_1         0xFFFFFFFF
  128.  
  129. #define XM_PERMUTE_0X       0x00010203
  130. #define XM_PERMUTE_0Y       0x04050607
  131. #define XM_PERMUTE_0Z       0x08090A0B
  132. #define XM_PERMUTE_0W       0x0C0D0E0F
  133. #define XM_PERMUTE_1X       0x10111213
  134. #define XM_PERMUTE_1Y       0x14151617
  135. #define XM_PERMUTE_1Z       0x18191A1B
  136. #define XM_PERMUTE_1W       0x1C1D1E1F
  137.  
  138. #define XM_CRMASK_CR6       0x000000F0
  139. #define XM_CRMASK_CR6TRUE   0x00000080
  140. #define XM_CRMASK_CR6FALSE  0x00000020
  141. #define XM_CRMASK_CR6BOUNDS XM_CRMASK_CR6FALSE
  142.  
  143. #define XM_CACHE_LINE_SIZE  64
  144.  
  145. /****************************************************************************
  146.  *
  147.  * Macros
  148.  *
  149.  ****************************************************************************/
  150.  
  151. // Unit conversion
  152.  
  153. XMFINLINE FLOAT XMConvertToRadians(FLOAT fDegrees) { return fDegrees * (XM_PI / 180.0f); }
  154. XMFINLINE FLOAT XMConvertToDegrees(FLOAT fRadians) { return fRadians * (180.0f / XM_PI); }
  155.  
  156. // Condition register evaluation proceeding a recording (Rc) comparison
  157.  
  158. #define XMComparisonAllTrue(CR)            (((CR) & XM_CRMASK_CR6TRUE) == XM_CRMASK_CR6TRUE)
  159. #define XMComparisonAnyTrue(CR)            (((CR) & XM_CRMASK_CR6FALSE) != XM_CRMASK_CR6FALSE)
  160. #define XMComparisonAllFalse(CR)           (((CR) & XM_CRMASK_CR6FALSE) == XM_CRMASK_CR6FALSE)
  161. #define XMComparisonAnyFalse(CR)           (((CR) & XM_CRMASK_CR6TRUE) != XM_CRMASK_CR6TRUE)
  162. #define XMComparisonMixed(CR)              (((CR) & XM_CRMASK_CR6) == 0)
  163. #define XMComparisonAllInBounds(CR)        (((CR) & XM_CRMASK_CR6BOUNDS) == XM_CRMASK_CR6BOUNDS)
  164. #define XMComparisonAnyOutOfBounds(CR)     (((CR) & XM_CRMASK_CR6BOUNDS) != XM_CRMASK_CR6BOUNDS)
  165.  
  166.  
  167. #define XMMin(a, b) (((a) < (b)) ? (a) : (b))
  168. #define XMMax(a, b) (((a) > (b)) ? (a) : (b))
  169.  
  170. /****************************************************************************
  171.  *
  172.  * Data types
  173.  *
  174.  ****************************************************************************/
  175.  
  176. #pragma warning(push)
  177. #pragma warning(disable:4201)
  178.  
  179. #if !defined (_XM_X86_) && !defined(_XM_X64_)
  180. #pragma bitfield_order(push)
  181. #pragma bitfield_order(lsb_to_msb)
  182. #endif // !_XM_X86_ && !_XM_X64_
  183.  
  184. #if defined(_XM_NO_INTRINSICS_) && !defined(_XBOX_VER)
  185. // The __vector4 structure is an intrinsic on Xbox but must be separately defined
  186. // for x86/x64
  187. typedef struct __vector4
  188. {
  189.     union
  190.     {
  191.         float        vector4_f32[4];
  192.         unsigned int vector4_u32[4];
  193. #ifndef XM_STRICT_VECTOR4
  194.         struct
  195.         {
  196.             FLOAT x;
  197.             FLOAT y;
  198.             FLOAT z;
  199.             FLOAT w;
  200.         };
  201.         FLOAT v[4];
  202.         UINT  u[4];
  203. #endif // !XM_STRICT_VECTOR4
  204.     };
  205. } __vector4;
  206. #endif // _XM_NO_INTRINSICS_
  207.  
  208. #if (defined (_XM_X86_) || defined(_XM_X64_)) && defined(_XM_NO_INTRINSICS_)
  209. typedef UINT __vector4i[4];
  210. #else
  211. typedef __declspec(align(16)) UINT __vector4i[4];
  212. #endif
  213.  
  214. // Vector intrinsic: Four 32 bit floating point components aligned on a 16 byte
  215. // boundary and mapped to hardware vector registers
  216. #if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
  217. typedef __m128 XMVECTOR;
  218. #else
  219. typedef __vector4 XMVECTOR;
  220. #endif
  221.  
  222. // Conversion types for constants
  223. typedef _DECLSPEC_ALIGN_16_ struct XMVECTORF32 {
  224.     union {
  225.         float f[4];
  226.         XMVECTOR v;
  227.     };
  228.  
  229. #if defined(__cplusplus)
  230.     inline operator XMVECTOR() const { return v; }
  231. #if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
  232.     inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
  233.     inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
  234. #endif
  235. #endif // __cplusplus
  236. } XMVECTORF32;
  237.  
  238. typedef _DECLSPEC_ALIGN_16_ struct XMVECTORI32 {
  239.     union {
  240.         INT i[4];
  241.         XMVECTOR v;
  242.     };
  243. #if defined(__cplusplus)
  244.     inline operator XMVECTOR() const { return v; }
  245. #if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
  246.     inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
  247.     inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
  248. #endif
  249. #endif // __cplusplus
  250. } XMVECTORI32;
  251.  
  252. typedef _DECLSPEC_ALIGN_16_ struct XMVECTORU8 {
  253.     union {
  254.         BYTE u[16];
  255.         XMVECTOR v;
  256.     };
  257. #if defined(__cplusplus)
  258.     inline operator XMVECTOR() const { return v; }
  259. #if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
  260.     inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
  261.     inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
  262. #endif
  263. #endif // __cplusplus
  264. } XMVECTORU8;
  265.  
  266. typedef _DECLSPEC_ALIGN_16_ struct XMVECTORU32 {
  267.     union {
  268.         UINT u[4];
  269.         XMVECTOR v;
  270.     };
  271. #if defined(__cplusplus)
  272.     inline operator XMVECTOR() const { return v; }
  273. #if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_)
  274.     inline operator __m128i() const { return reinterpret_cast<const __m128i *>(&v)[0]; }
  275.     inline operator __m128d() const { return reinterpret_cast<const __m128d *>(&v)[0]; }
  276. #endif
  277. #endif // __cplusplus
  278. } XMVECTORU32;
  279.  
  280. // Fix-up for (1st-3rd) XMVECTOR parameters that are pass-in-register for x86 and Xbox 360, but not for other targets
  281. #if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINISCS_)
  282. typedef const XMVECTOR FXMVECTOR;
  283. #elif defined(_XM_X86_) && !defined(_XM_NO_INTRINISCS_)
  284. typedef const XMVECTOR FXMVECTOR;
  285. #elif defined(__cplusplus)
  286. typedef const XMVECTOR& FXMVECTOR;
  287. #else
  288. typedef const XMVECTOR FXMVECTOR;
  289. #endif
  290.  
  291. // Fix-up for (4th+) XMVECTOR parameters to pass in-register for Xbox 360 and by reference otherwise
  292. #if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINISCS_)
  293. typedef const XMVECTOR CXMVECTOR;
  294. #elif defined(__cplusplus)
  295. typedef const XMVECTOR& CXMVECTOR;
  296. #else
  297. typedef const XMVECTOR CXMVECTOR;
  298. #endif
  299.  
  300. // Vector operators
  301. #if defined(__cplusplus) && !defined(XM_NO_OPERATOR_OVERLOADS)
  302.  
  303. XMVECTOR    operator+ (FXMVECTOR V);
  304. XMVECTOR    operator- (FXMVECTOR V);
  305.  
  306. XMVECTOR&   operator+= (XMVECTOR& V1, FXMVECTOR V2);
  307. XMVECTOR&   operator-= (XMVECTOR& V1, FXMVECTOR V2);
  308. XMVECTOR&   operator*= (XMVECTOR& V1, FXMVECTOR V2);
  309. XMVECTOR&   operator/= (XMVECTOR& V1, FXMVECTOR V2);
  310. XMVECTOR&   operator*= (XMVECTOR& V, FLOAT S);
  311. XMVECTOR&   operator/= (XMVECTOR& V, FLOAT S);
  312.  
  313. XMVECTOR    operator+ (FXMVECTOR V1, FXMVECTOR V2);
  314. XMVECTOR    operator- (FXMVECTOR V1, FXMVECTOR V2);
  315. XMVECTOR    operator* (FXMVECTOR V1, FXMVECTOR V2);
  316. XMVECTOR    operator/ (FXMVECTOR V1, FXMVECTOR V2);
  317. XMVECTOR    operator* (FXMVECTOR V, FLOAT S);
  318. XMVECTOR    operator* (FLOAT S, FXMVECTOR V);
  319. XMVECTOR    operator/ (FXMVECTOR V, FLOAT S);
  320.  
  321. #endif // __cplusplus && !XM_NO_OPERATOR_OVERLOADS
  322.  
  323. // Matrix type: Sixteen 32 bit floating point components aligned on a
  324. // 16 byte boundary and mapped to four hardware vector registers
  325. #if (defined(_XM_X86_) || defined(_XM_X64_)) && defined(_XM_NO_INTRINSICS_)
  326. typedef struct _XMMATRIX
  327. #else
  328. typedef _DECLSPEC_ALIGN_16_ struct _XMMATRIX
  329. #endif
  330. {
  331.     union
  332.     {
  333.         XMVECTOR r[4];
  334.         struct
  335.         {
  336.             FLOAT _11, _12, _13, _14;
  337.             FLOAT _21, _22, _23, _24;
  338.             FLOAT _31, _32, _33, _34;
  339.             FLOAT _41, _42, _43, _44;
  340.         };
  341.         FLOAT m[4][4];
  342.     };
  343.  
  344. #ifdef __cplusplus
  345.  
  346.     _XMMATRIX() {};
  347.     _XMMATRIX(FXMVECTOR R0, FXMVECTOR R1, FXMVECTOR R2, CXMVECTOR R3);
  348.     _XMMATRIX(FLOAT m00, FLOAT m01, FLOAT m02, FLOAT m03,
  349.               FLOAT m10, FLOAT m11, FLOAT m12, FLOAT m13,
  350.               FLOAT m20, FLOAT m21, FLOAT m22, FLOAT m23,
  351.               FLOAT m30, FLOAT m31, FLOAT m32, FLOAT m33);
  352.     _XMMATRIX(CONST FLOAT *pArray);
  353.  
  354.     FLOAT       operator() (UINT Row, UINT Column) CONST { return m[Row][Column]; }
  355.     FLOAT&      operator() (UINT Row, UINT Column) { return m[Row][Column]; }
  356.  
  357.     _XMMATRIX&  operator= (CONST _XMMATRIX&);
  358.  
  359. #ifndef XM_NO_OPERATOR_OVERLOADS
  360.     _XMMATRIX&  operator*= (CONST _XMMATRIX&);
  361.     _XMMATRIX   operator* (CONST _XMMATRIX&) CONST;
  362. #endif // !XM_NO_OPERATOR_OVERLOADS
  363.  
  364. #endif // __cplusplus
  365.  
  366. } XMMATRIX;
  367.  
  368. // Fix-up for XMMATRIX parameters to pass in-register on Xbox 360, by reference otherwise
  369. #if defined(_XM_VMX128_INTRINSICS_)
  370. typedef const XMMATRIX CXMMATRIX;
  371. #elif defined(__cplusplus)
  372. typedef const XMMATRIX& CXMMATRIX;
  373. #else
  374. typedef const XMMATRIX CXMMATRIX;
  375. #endif
  376.  
  377. // 16 bit floating point number consisting of a sign bit, a 5 bit biased
  378. // exponent, and a 10 bit mantissa
  379. //typedef WORD HALF;
  380. typedef USHORT HALF;
  381.  
  382. // 2D Vector; 32 bit floating point components
  383. typedef struct _XMFLOAT2
  384. {
  385.     FLOAT x;
  386.     FLOAT y;
  387.  
  388. #ifdef __cplusplus
  389.  
  390.     _XMFLOAT2() {};
  391.     _XMFLOAT2(FLOAT _x, FLOAT _y) : x(_x), y(_y) {};
  392.     _XMFLOAT2(CONST FLOAT *pArray);
  393.  
  394.     _XMFLOAT2& operator= (CONST _XMFLOAT2& Float2);
  395.  
  396. #endif // __cplusplus
  397.  
  398. } XMFLOAT2;
  399.  
  400. // 2D Vector; 32 bit floating point components aligned on a 16 byte boundary
  401. typedef __declspec(align(16)) XMFLOAT2 XMFLOAT2A;
  402.  
  403. // 2D Vector; 16 bit floating point components
  404. typedef struct _XMHALF2
  405. {
  406.     HALF x;
  407.     HALF y;
  408.  
  409. #ifdef __cplusplus
  410.  
  411.     _XMHALF2() {};
  412.     _XMHALF2(HALF _x, HALF _y) : x(_x), y(_y) {};
  413.     _XMHALF2(CONST HALF *pArray);
  414.     _XMHALF2(FLOAT _x, FLOAT _y);
  415.     _XMHALF2(CONST FLOAT *pArray);
  416.  
  417.     _XMHALF2& operator= (CONST _XMHALF2& Half2);
  418.  
  419. #endif // __cplusplus
  420.  
  421. } XMHALF2;
  422.  
  423. // 2D Vector; 16 bit signed normalized integer components
  424. typedef struct _XMSHORTN2
  425. {
  426.     SHORT x;
  427.     SHORT y;
  428.  
  429. #ifdef __cplusplus
  430.  
  431.     _XMSHORTN2() {};
  432.     _XMSHORTN2(SHORT _x, SHORT _y) : x(_x), y(_y) {};
  433.     _XMSHORTN2(CONST SHORT *pArray);
  434.     _XMSHORTN2(FLOAT _x, FLOAT _y);
  435.     _XMSHORTN2(CONST FLOAT *pArray);
  436.  
  437.     _XMSHORTN2& operator= (CONST _XMSHORTN2& ShortN2);
  438.  
  439. #endif // __cplusplus
  440.  
  441. } XMSHORTN2;
  442.  
  443. // 2D Vector; 16 bit signed integer components
  444. typedef struct _XMSHORT2
  445. {
  446.     SHORT x;
  447.     SHORT y;
  448.  
  449. #ifdef __cplusplus
  450.  
  451.     _XMSHORT2() {};
  452.     _XMSHORT2(SHORT _x, SHORT _y) : x(_x), y(_y) {};
  453.     _XMSHORT2(CONST SHORT *pArray);
  454.     _XMSHORT2(FLOAT _x, FLOAT _y);
  455.     _XMSHORT2(CONST FLOAT *pArray);
  456.  
  457.     _XMSHORT2& operator= (CONST _XMSHORT2& Short2);
  458.  
  459. #endif // __cplusplus
  460.  
  461. } XMSHORT2;
  462.  
  463. // 2D Vector; 16 bit unsigned normalized integer components
  464. typedef struct _XMUSHORTN2
  465. {
  466.     USHORT x;
  467.     USHORT y;
  468.  
  469. #ifdef __cplusplus
  470.  
  471.     _XMUSHORTN2() {};
  472.     _XMUSHORTN2(USHORT _x, USHORT _y) : x(_x), y(_y) {};
  473.     _XMUSHORTN2(CONST USHORT *pArray);
  474.     _XMUSHORTN2(FLOAT _x, FLOAT _y);
  475.     _XMUSHORTN2(CONST FLOAT *pArray);
  476.  
  477.     _XMUSHORTN2& operator= (CONST _XMUSHORTN2& UShortN2);
  478.  
  479. #endif // __cplusplus
  480.  
  481. } XMUSHORTN2;
  482.  
  483. // 2D Vector; 16 bit unsigned integer components
  484. typedef struct _XMUSHORT2
  485. {
  486.     USHORT x;
  487.     USHORT y;
  488.  
  489. #ifdef __cplusplus
  490.  
  491.     _XMUSHORT2() {};
  492.     _XMUSHORT2(USHORT _x, USHORT _y) : x(_x), y(_y) {};
  493.     _XMUSHORT2(CONST USHORT *pArray);
  494.     _XMUSHORT2(FLOAT _x, FLOAT _y);
  495.     _XMUSHORT2(CONST FLOAT *pArray);
  496.  
  497.     _XMUSHORT2& operator= (CONST _XMUSHORT2& UShort2);
  498.  
  499. #endif // __cplusplus
  500.  
  501. } XMUSHORT2;
  502.  
  503. // 3D Vector; 32 bit floating point components
  504. typedef struct _XMFLOAT3
  505. {
  506.     FLOAT x;
  507.     FLOAT y;
  508.     FLOAT z;
  509.  
  510. #ifdef __cplusplus
  511.  
  512.     _XMFLOAT3() {};
  513.     _XMFLOAT3(FLOAT _x, FLOAT _y, FLOAT _z) : x(_x), y(_y), z(_z) {};
  514.     _XMFLOAT3(CONST FLOAT *pArray);
  515.  
  516.     _XMFLOAT3& operator= (CONST _XMFLOAT3& Float3);
  517.  
  518. #endif // __cplusplus
  519.  
  520. } XMFLOAT3;
  521.  
  522. // 3D Vector; 32 bit floating point components aligned on a 16 byte boundary
  523. typedef __declspec(align(16)) XMFLOAT3 XMFLOAT3A;
  524.  
  525. // 3D Vector; 11-11-10 bit normalized components packed into a 32 bit integer
  526. // The normalized 3D Vector is packed into 32 bits as follows: a 10 bit signed,
  527. // normalized integer for the z component and 11 bit signed, normalized
  528. // integers for the x and y components.  The z component is stored in the
  529. // most significant bits and the x component in the least significant bits
  530. // (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
  531. typedef struct _XMHENDN3
  532. {
  533.     union
  534.     {
  535.         struct
  536.         {
  537.             INT  x   : 11;    // -1023/1023 to 1023/1023
  538.             INT  y   : 11;    // -1023/1023 to 1023/1023
  539.             INT  z   : 10;    // -511/511 to 511/511
  540.         };
  541.         UINT v;
  542.     };
  543.  
  544. #ifdef __cplusplus
  545.  
  546.     _XMHENDN3() {};
  547.     _XMHENDN3(UINT Packed) : v(Packed) {};
  548.     _XMHENDN3(FLOAT _x, FLOAT _y, FLOAT _z);
  549.     _XMHENDN3(CONST FLOAT *pArray);
  550.  
  551.     operator UINT () { return v; }
  552.  
  553.     _XMHENDN3& operator= (CONST _XMHENDN3& HenDN3);
  554.     _XMHENDN3& operator= (CONST UINT Packed);
  555.  
  556. #endif // __cplusplus
  557.  
  558. } XMHENDN3;
  559.  
  560. // 3D Vector; 11-11-10 bit components packed into a 32 bit integer
  561. // The 3D Vector is packed into 32 bits as follows: a 10 bit signed,
  562. // integer for the z component and 11 bit signed integers for the
  563. // x and y components.  The z component is stored in the
  564. // most significant bits and the x component in the least significant bits
  565. // (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
  566. typedef struct _XMHEND3
  567. {
  568.     union
  569.     {
  570.         struct
  571.         {
  572.             INT  x   : 11;    // -1023 to 1023
  573.             INT  y   : 11;    // -1023 to 1023
  574.             INT  z   : 10;    // -511 to 511
  575.         };
  576.         UINT v;
  577.     };
  578.  
  579. #ifdef __cplusplus
  580.  
  581.     _XMHEND3() {};
  582.     _XMHEND3(UINT Packed) : v(Packed) {};
  583.     _XMHEND3(FLOAT _x, FLOAT _y, FLOAT _z);
  584.     _XMHEND3(CONST FLOAT *pArray);
  585.  
  586.     operator UINT () { return v; }
  587.  
  588.     _XMHEND3& operator= (CONST _XMHEND3& HenD3);
  589.     _XMHEND3& operator= (CONST UINT Packed);
  590.  
  591. #endif // __cplusplus
  592.  
  593. } XMHEND3;
  594.  
  595. // 3D Vector; 11-11-10 bit normalized components packed into a 32 bit integer
  596. // The normalized 3D Vector is packed into 32 bits as follows: a 10 bit unsigned,
  597. // normalized integer for the z component and 11 bit unsigned, normalized
  598. // integers for the x and y components.  The z component is stored in the
  599. // most significant bits and the x component in the least significant bits
  600. // (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
  601. typedef struct _XMUHENDN3
  602. {
  603.     union
  604.     {
  605.         struct
  606.         {
  607.             UINT  x  : 11;    // 0/2047 to 2047/2047
  608.             UINT  y  : 11;    // 0/2047 to 2047/2047
  609.             UINT  z  : 10;    // 0/1023 to 1023/1023
  610.         };
  611.         UINT v;
  612.     };
  613.  
  614. #ifdef __cplusplus
  615.  
  616.     _XMUHENDN3() {};
  617.     _XMUHENDN3(UINT Packed) : v(Packed) {};
  618.     _XMUHENDN3(FLOAT _x, FLOAT _y, FLOAT _z);
  619.     _XMUHENDN3(CONST FLOAT *pArray);
  620.  
  621.     operator UINT () { return v; }
  622.  
  623.     _XMUHENDN3& operator= (CONST _XMUHENDN3& UHenDN3);
  624.     _XMUHENDN3& operator= (CONST UINT Packed);
  625.  
  626. #endif // __cplusplus
  627.  
  628. } XMUHENDN3;
  629.  
  630. // 3D Vector; 11-11-10 bit components packed into a 32 bit integer
  631. // The 3D Vector is packed into 32 bits as follows: a 10 bit unsigned
  632. // integer for the z component and 11 bit unsigned integers
  633. // for the x and y components.  The z component is stored in the
  634. // most significant bits and the x component in the least significant bits
  635. // (Z10Y11X11): [32] zzzzzzzz zzyyyyyy yyyyyxxx xxxxxxxx [0]
  636. typedef struct _XMUHEND3
  637. {
  638.     union
  639.     {
  640.         struct
  641.         {
  642.             UINT  x  : 11;    // 0 to 2047
  643.             UINT  y  : 11;    // 0 to 2047
  644.             UINT  z  : 10;    // 0 to 1023
  645.         };
  646.         UINT v;
  647.     };
  648.  
  649. #ifdef __cplusplus
  650.  
  651.     _XMUHEND3() {};
  652.     _XMUHEND3(UINT Packed) : v(Packed) {};
  653.     _XMUHEND3(FLOAT _x, FLOAT _y, FLOAT _z);
  654.     _XMUHEND3(CONST FLOAT *pArray);
  655.  
  656.     operator UINT () { return v; }
  657.  
  658.     _XMUHEND3& operator= (CONST _XMUHEND3& UHenD3);
  659.     _XMUHEND3& operator= (CONST UINT Packed);
  660.  
  661. #endif // __cplusplus
  662.  
  663. } XMUHEND3;
  664.  
  665. // 3D Vector; 10-11-11 bit normalized components packed into a 32 bit integer
  666. // The normalized 3D Vector is packed into 32 bits as follows: a 10 bit signed,
  667. // normalized integer for the x component and 11 bit signed, normalized
  668. // integers for the y and z components.  The z component is stored in the
  669. // most significant bits and the x component in the least significant bits
  670. // (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
  671. typedef struct _XMDHENN3
  672. {
  673.     union
  674.     {
  675.         struct
  676.         {
  677.             INT  x   : 10;    // -511/511 to 511/511
  678.             INT  y   : 11;    // -1023/1023 to 1023/1023
  679.             INT  z   : 11;    // -1023/1023 to 1023/1023
  680.         };
  681.         UINT v;
  682.     };
  683.  
  684. #ifdef __cplusplus
  685.  
  686.     _XMDHENN3() {};
  687.     _XMDHENN3(UINT Packed) : v(Packed) {};
  688.     _XMDHENN3(FLOAT _x, FLOAT _y, FLOAT _z);
  689.     _XMDHENN3(CONST FLOAT *pArray);
  690.  
  691.     operator UINT () { return v; }
  692.  
  693.     _XMDHENN3& operator= (CONST _XMDHENN3& DHenN3);
  694.     _XMDHENN3& operator= (CONST UINT Packed);
  695.  
  696. #endif // __cplusplus
  697.  
  698. } XMDHENN3;
  699.  
  700. // 3D Vector; 10-11-11 bit components packed into a 32 bit integer
  701. // The 3D Vector is packed into 32 bits as follows: a 10 bit signed,
  702. // integer for the x component and 11 bit signed integers for the
  703. // y and z components.  The w component is stored in the
  704. // most significant bits and the x component in the least significant bits
  705. // (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
  706. typedef struct _XMDHEN3
  707. {
  708.     union
  709.     {
  710.         struct
  711.         {
  712.             INT  x   : 10;    // -511 to 511
  713.             INT  y   : 11;    // -1023 to 1023
  714.             INT  z   : 11;    // -1023 to 1023
  715.         };
  716.         UINT v;
  717.     };
  718.  
  719. #ifdef __cplusplus
  720.  
  721.     _XMDHEN3() {};
  722.     _XMDHEN3(UINT Packed) : v(Packed) {};
  723.     _XMDHEN3(FLOAT _x, FLOAT _y, FLOAT _z);
  724.     _XMDHEN3(CONST FLOAT *pArray);
  725.  
  726.     operator UINT () { return v; }
  727.  
  728.     _XMDHEN3& operator= (CONST _XMDHEN3& DHen3);
  729.     _XMDHEN3& operator= (CONST UINT Packed);
  730.  
  731. #endif // __cplusplus
  732.  
  733. } XMDHEN3;
  734.  
  735. // 3D Vector; 10-11-11 bit normalized components packed into a 32 bit integer
  736. // The normalized 3D Vector is packed into 32 bits as follows: a 10 bit unsigned,
  737. // normalized integer for the x component and 11 bit unsigned, normalized
  738. // integers for the y and z components.  The w component is stored in the
  739. // most significant bits and the x component in the least significant bits
  740. // (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
  741. typedef struct _XMUDHENN3
  742. {
  743.     union
  744.     {
  745.         struct
  746.         {
  747.             UINT  x  : 10;    // 0/1023 to 1023/1023
  748.             UINT  y  : 11;    // 0/2047 to 2047/2047
  749.             UINT  z  : 11;    // 0/2047 to 2047/2047
  750.         };
  751.         UINT v;
  752.     };
  753.  
  754. #ifdef __cplusplus
  755.  
  756.     _XMUDHENN3() {};
  757.     _XMUDHENN3(UINT Packed) : v(Packed) {};
  758.     _XMUDHENN3(FLOAT _x, FLOAT _y, FLOAT _z);
  759.     _XMUDHENN3(CONST FLOAT *pArray);
  760.  
  761.     operator UINT () { return v; }
  762.  
  763.     _XMUDHENN3& operator= (CONST _XMUDHENN3& UDHenN3);
  764.     _XMUDHENN3& operator= (CONST UINT Packed);
  765.  
  766. #endif // __cplusplus
  767.  
  768. } XMUDHENN3;
  769.  
  770. // 3D Vector; 10-11-11 bit components packed into a 32 bit integer
  771. // The 3D Vector is packed into 32 bits as follows: a 10 bit unsigned,
  772. // integer for the x component and 11 bit unsigned integers
  773. // for the y and z components.  The w component is stored in the
  774. // most significant bits and the x component in the least significant bits
  775. // (Z11Y11X10): [32] zzzzzzzz zzzyyyyy yyyyyyxx xxxxxxxx [0]
  776. typedef struct _XMUDHEN3
  777. {
  778.     union
  779.     {
  780.         struct
  781.         {
  782.             UINT  x  : 10;    // 0 to 1023
  783.             UINT  y  : 11;    // 0 to 2047
  784.             UINT  z  : 11;    // 0 to 2047
  785.         };
  786.         UINT v;
  787.     };
  788.  
  789. #ifdef __cplusplus
  790.  
  791.     _XMUDHEN3() {};
  792.     _XMUDHEN3(UINT Packed) : v(Packed) {};
  793.     _XMUDHEN3(FLOAT _x, FLOAT _y, FLOAT _z);
  794.     _XMUDHEN3(CONST FLOAT *pArray);
  795.  
  796.     operator UINT () { return v; }
  797.  
  798.     _XMUDHEN3& operator= (CONST _XMUDHEN3& UDHen3);
  799.     _XMUDHEN3& operator= (CONST UINT Packed);
  800.  
  801. #endif // __cplusplus
  802.  
  803. } XMUDHEN3;
  804.  
  805. // 3D vector: 5/6/5 unsigned integer components
  806. typedef struct _XMU565
  807. {
  808.     union
  809.     {
  810.         struct
  811.         {
  812.             USHORT x  : 5;
  813.             USHORT y  : 6;
  814.             USHORT z  : 5;
  815.         };
  816.         USHORT v;
  817.     };
  818.  
  819. #ifdef __cplusplus
  820.  
  821.     _XMU565() {};
  822.     _XMU565(USHORT Packed) : v(Packed) {};
  823.     _XMU565(CHAR _x, CHAR _y, CHAR _z) : x(_x), y(_y), z(_z) {};
  824.     _XMU565(CONST CHAR *pArray);
  825.     _XMU565(FLOAT _x, FLOAT _y, FLOAT _z);
  826.     _XMU565(CONST FLOAT *pArray);
  827.  
  828.     operator USHORT () { return v; }
  829.  
  830.     _XMU565& operator= (CONST _XMU565& U565);
  831.     _XMU565& operator= (CONST USHORT Packed);
  832.  
  833. #endif // __cplusplus
  834.  
  835. } XMU565;
  836.  
  837. // 3D vector: 11/11/10 floating-point components
  838. // The 3D vector is packed into 32 bits as follows: a 5-bit biased exponent
  839. // and 6-bit mantissa for x component, a 5-bit biased exponent and
  840. // 6-bit mantissa for y component, a 5-bit biased exponent and a 5-bit
  841. // mantissa for z. The z component is stored in the most significant bits
  842. // and the x component in the least significant bits. No sign bits so
  843. // all partial-precision numbers are positive.
  844. // (Z10Y11X11): [32] ZZZZZzzz zzzYYYYY yyyyyyXX XXXxxxxx [0]
  845. typedef struct _XMFLOAT3PK
  846. {
  847.     union
  848.     {
  849.         struct
  850.         {
  851.             UINT xm : 6;
  852.             UINT xe : 5;
  853.             UINT ym : 6;
  854.             UINT ye : 5;
  855.             UINT zm : 5;
  856.             UINT ze : 5;
  857.         };
  858.         UINT v;
  859.     };
  860.  
  861. #ifdef __cplusplus
  862.  
  863.     _XMFLOAT3PK() {};
  864.     _XMFLOAT3PK(UINT Packed) : v(Packed) {};
  865.     _XMFLOAT3PK(FLOAT _x, FLOAT _y, FLOAT _z);
  866.     _XMFLOAT3PK(CONST FLOAT *pArray);
  867.  
  868.     operator UINT () { return v; }
  869.  
  870.     _XMFLOAT3PK& operator= (CONST _XMFLOAT3PK& float3pk);
  871.     _XMFLOAT3PK& operator= (CONST UINT Packed);
  872.  
  873. #endif // __cplusplus
  874.  
  875. } XMFLOAT3PK;
  876.  
  877. // 3D vector: 9/9/9 floating-point components with shared 5-bit exponent
  878. // The 3D vector is packed into 32 bits as follows: a 5-bit biased exponent
  879. // with 9-bit mantissa for the x, y, and z component. The shared exponent
  880. // is stored in the most significant bits and the x component mantissa is in
  881. // the least significant bits. No sign bits so all partial-precision numbers
  882. // are positive.
  883. // (E5Z9Y9X9): [32] EEEEEzzz zzzzzzyy yyyyyyyx xxxxxxxx [0]
  884. typedef struct _XMFLOAT3SE
  885. {
  886.     union
  887.     {
  888.         struct
  889.         {
  890.             UINT xm : 9;
  891.             UINT ym : 9;
  892.             UINT zm : 9;
  893.             UINT e  : 5;
  894.         };
  895.         UINT v;
  896.     };
  897.  
  898. #ifdef __cplusplus
  899.  
  900.     _XMFLOAT3SE() {};
  901.     _XMFLOAT3SE(UINT Packed) : v(Packed) {};
  902.     _XMFLOAT3SE(FLOAT _x, FLOAT _y, FLOAT _z);
  903.     _XMFLOAT3SE(CONST FLOAT *pArray);
  904.  
  905.     operator UINT () { return v; }
  906.  
  907.     _XMFLOAT3SE& operator= (CONST _XMFLOAT3SE& float3se);
  908.     _XMFLOAT3SE& operator= (CONST UINT Packed);
  909.  
  910. #endif // __cplusplus
  911.  
  912. } XMFLOAT3SE;
  913.  
  914. // 4D Vector; 32 bit floating point components
  915. typedef struct _XMFLOAT4
  916. {
  917.     FLOAT x;
  918.     FLOAT y;
  919.     FLOAT z;
  920.     FLOAT w;
  921.  
  922. #ifdef __cplusplus
  923.  
  924.     _XMFLOAT4() {};
  925.     _XMFLOAT4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w) : x(_x), y(_y), z(_z), w(_w) {};
  926.     _XMFLOAT4(CONST FLOAT *pArray);
  927.  
  928.     _XMFLOAT4& operator= (CONST _XMFLOAT4& Float4);
  929.  
  930. #endif // __cplusplus
  931.  
  932. } XMFLOAT4;
  933.  
  934. // 4D Vector; 32 bit floating point components aligned on a 16 byte boundary
  935. typedef __declspec(align(16)) XMFLOAT4 XMFLOAT4A;
  936.  
  937. // 4D Vector; 16 bit floating point components
  938. typedef struct _XMHALF4
  939. {
  940.     HALF x;
  941.     HALF y;
  942.     HALF z;
  943.     HALF w;
  944.  
  945. #ifdef __cplusplus
  946.  
  947.     _XMHALF4() {};
  948.     _XMHALF4(HALF _x, HALF _y, HALF _z, HALF _w) : x(_x), y(_y), z(_z), w(_w) {};
  949.     _XMHALF4(CONST HALF *pArray);
  950.     _XMHALF4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  951.     _XMHALF4(CONST FLOAT *pArray);
  952.  
  953.     _XMHALF4& operator= (CONST _XMHALF4& Half4);
  954.  
  955. #endif // __cplusplus
  956.  
  957. } XMHALF4;
  958.  
  959. // 4D Vector; 16 bit signed normalized integer components
  960. typedef struct _XMSHORTN4
  961. {
  962.     SHORT x;
  963.     SHORT y;
  964.     SHORT z;
  965.     SHORT w;
  966.  
  967. #ifdef __cplusplus
  968.  
  969.     _XMSHORTN4() {};
  970.     _XMSHORTN4(SHORT _x, SHORT _y, SHORT _z, SHORT _w) : x(_x), y(_y), z(_z), w(_w) {};
  971.     _XMSHORTN4(CONST SHORT *pArray);
  972.     _XMSHORTN4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  973.     _XMSHORTN4(CONST FLOAT *pArray);
  974.  
  975.     _XMSHORTN4& operator= (CONST _XMSHORTN4& ShortN4);
  976.  
  977. #endif // __cplusplus
  978.  
  979. } XMSHORTN4;
  980.  
  981. // 4D Vector; 16 bit signed integer components
  982. typedef struct _XMSHORT4
  983. {
  984.     SHORT x;
  985.     SHORT y;
  986.     SHORT z;
  987.     SHORT w;
  988.  
  989. #ifdef __cplusplus
  990.  
  991.     _XMSHORT4() {};
  992.     _XMSHORT4(SHORT _x, SHORT _y, SHORT _z, SHORT _w) : x(_x), y(_y), z(_z), w(_w) {};
  993.     _XMSHORT4(CONST SHORT *pArray);
  994.     _XMSHORT4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  995.     _XMSHORT4(CONST FLOAT *pArray);
  996.  
  997.     _XMSHORT4& operator= (CONST _XMSHORT4& Short4);
  998.  
  999. #endif // __cplusplus
  1000.  
  1001. } XMSHORT4;
  1002.  
  1003. // 4D Vector; 16 bit unsigned normalized integer components
  1004. typedef struct _XMUSHORTN4
  1005. {
  1006.     USHORT x;
  1007.     USHORT y;
  1008.     USHORT z;
  1009.     USHORT w;
  1010.  
  1011. #ifdef __cplusplus
  1012.  
  1013.     _XMUSHORTN4() {};
  1014.     _XMUSHORTN4(USHORT _x, USHORT _y, USHORT _z, USHORT _w) : x(_x), y(_y), z(_z), w(_w) {};
  1015.     _XMUSHORTN4(CONST USHORT *pArray);
  1016.     _XMUSHORTN4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1017.     _XMUSHORTN4(CONST FLOAT *pArray);
  1018.  
  1019.     _XMUSHORTN4& operator= (CONST _XMUSHORTN4& UShortN4);
  1020.  
  1021. #endif // __cplusplus
  1022.  
  1023. } XMUSHORTN4;
  1024.  
  1025. // 4D Vector; 16 bit unsigned integer components
  1026. typedef struct _XMUSHORT4
  1027. {
  1028.     USHORT x;
  1029.     USHORT y;
  1030.     USHORT z;
  1031.     USHORT w;
  1032.  
  1033. #ifdef __cplusplus
  1034.  
  1035.     _XMUSHORT4() {};
  1036.     _XMUSHORT4(USHORT _x, USHORT _y, USHORT _z, USHORT _w) : x(_x), y(_y), z(_z), w(_w) {};
  1037.     _XMUSHORT4(CONST USHORT *pArray);
  1038.     _XMUSHORT4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1039.     _XMUSHORT4(CONST FLOAT *pArray);
  1040.  
  1041.     _XMUSHORT4& operator= (CONST _XMUSHORT4& UShort4);
  1042.  
  1043. #endif // __cplusplus
  1044.  
  1045. } XMUSHORT4;
  1046.  
  1047. // 4D Vector; 10-10-10-2 bit normalized components packed into a 32 bit integer
  1048. // The normalized 4D Vector is packed into 32 bits as follows: a 2 bit unsigned,
  1049. // normalized integer for the w component and 10 bit signed, normalized
  1050. // integers for the z, y, and x components.  The w component is stored in the
  1051. // most significant bits and the x component in the least significant bits
  1052. // (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
  1053. typedef struct _XMXDECN4
  1054. {
  1055.     union
  1056.     {
  1057.         struct
  1058.         {
  1059.             INT  x   : 10;    // -511/511 to 511/511
  1060.             INT  y   : 10;    // -511/511 to 511/511
  1061.             INT  z   : 10;    // -511/511 to 511/511
  1062.             UINT w   : 2;     //      0/3 to     3/3
  1063.         };
  1064.         UINT v;
  1065.     };
  1066.  
  1067. #ifdef __cplusplus
  1068.  
  1069.     _XMXDECN4() {};
  1070.     _XMXDECN4(UINT Packed) : v(Packed) {};
  1071.     _XMXDECN4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1072.     _XMXDECN4(CONST FLOAT *pArray);
  1073.  
  1074.     operator UINT () { return v; }
  1075.  
  1076.     _XMXDECN4& operator= (CONST _XMXDECN4& XDecN4);
  1077.     _XMXDECN4& operator= (CONST UINT Packed);
  1078.  
  1079. #endif // __cplusplus
  1080.  
  1081. } XMXDECN4;
  1082.  
  1083. // 4D Vector; 10-10-10-2 bit components packed into a 32 bit integer
  1084. // The normalized 4D Vector is packed into 32 bits as follows: a 2 bit unsigned
  1085. // integer for the w component and 10 bit signed integers for the
  1086. // z, y, and x components.  The w component is stored in the
  1087. // most significant bits and the x component in the least significant bits
  1088. // (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
  1089. typedef struct _XMXDEC4
  1090. {
  1091.     union
  1092.     {
  1093.         struct
  1094.         {
  1095.             INT  x   : 10;    // -511 to 511
  1096.             INT  y   : 10;    // -511 to 511
  1097.             INT  z   : 10;    // -511 to 511
  1098.             UINT w   : 2;     //    0 to   3
  1099.         };
  1100.         UINT v;
  1101.     };
  1102.  
  1103. #ifdef __cplusplus
  1104.  
  1105.     _XMXDEC4() {};
  1106.     _XMXDEC4(UINT Packed) : v(Packed) {};
  1107.     _XMXDEC4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1108.     _XMXDEC4(CONST FLOAT *pArray);
  1109.  
  1110.     operator UINT () { return v; }
  1111.  
  1112.     _XMXDEC4& operator= (CONST _XMXDEC4& XDec4);
  1113.     _XMXDEC4& operator= (CONST UINT Packed);
  1114.  
  1115. #endif // __cplusplus
  1116.  
  1117. } XMXDEC4;
  1118.  
  1119. // 4D Vector; 10-10-10-2 bit normalized components packed into a 32 bit integer
  1120. // The normalized 4D Vector is packed into 32 bits as follows: a 2 bit signed,
  1121. // normalized integer for the w component and 10 bit signed, normalized
  1122. // integers for the z, y, and x components.  The w component is stored in the
  1123. // most significant bits and the x component in the least significant bits
  1124. // (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
  1125. typedef struct _XMDECN4
  1126. {
  1127.     union
  1128.     {
  1129.         struct
  1130.         {
  1131.             INT  x   : 10;    // -511/511 to 511/511
  1132.             INT  y   : 10;    // -511/511 to 511/511
  1133.             INT  z   : 10;    // -511/511 to 511/511
  1134.             INT  w   : 2;     //     -1/1 to     1/1
  1135.         };
  1136.         UINT v;
  1137.     };
  1138.  
  1139. #ifdef __cplusplus
  1140.  
  1141.     _XMDECN4() {};
  1142.     _XMDECN4(UINT Packed) : v(Packed) {};
  1143.     _XMDECN4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1144.     _XMDECN4(CONST FLOAT *pArray);
  1145.  
  1146.     operator UINT () { return v; }
  1147.  
  1148.     _XMDECN4& operator= (CONST _XMDECN4& DecN4);
  1149.     _XMDECN4& operator= (CONST UINT Packed);
  1150.  
  1151. #endif // __cplusplus
  1152.  
  1153. } XMDECN4;
  1154.  
  1155. // 4D Vector; 10-10-10-2 bit components packed into a 32 bit integer
  1156. // The 4D Vector is packed into 32 bits as follows: a 2 bit signed,
  1157. // integer for the w component and 10 bit signed integers for the
  1158. // z, y, and x components.  The w component is stored in the
  1159. // most significant bits and the x component in the least significant bits
  1160. // (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
  1161. typedef struct _XMDEC4
  1162. {
  1163.     union
  1164.     {
  1165.         struct
  1166.         {
  1167.             INT  x   : 10;    // -511 to 511
  1168.             INT  y   : 10;    // -511 to 511
  1169.             INT  z   : 10;    // -511 to 511
  1170.             INT  w   : 2;     //   -1 to   1
  1171.         };
  1172.         UINT v;
  1173.     };
  1174.  
  1175. #ifdef __cplusplus
  1176.  
  1177.     _XMDEC4() {};
  1178.     _XMDEC4(UINT Packed) : v(Packed) {};
  1179.     _XMDEC4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1180.     _XMDEC4(CONST FLOAT *pArray);
  1181.  
  1182.     operator UINT () { return v; }
  1183.  
  1184.     _XMDEC4& operator= (CONST _XMDEC4& Dec4);
  1185.     _XMDEC4& operator= (CONST UINT Packed);
  1186.  
  1187. #endif // __cplusplus
  1188.  
  1189. } XMDEC4;
  1190.  
  1191. // 4D Vector; 10-10-10-2 bit normalized components packed into a 32 bit integer
  1192. // The normalized 4D Vector is packed into 32 bits as follows: a 2 bit unsigned,
  1193. // normalized integer for the w component and 10 bit unsigned, normalized
  1194. // integers for the z, y, and x components.  The w component is stored in the
  1195. // most significant bits and the x component in the least significant bits
  1196. // (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
  1197. typedef struct _XMUDECN4
  1198. {
  1199.     union
  1200.     {
  1201.         struct
  1202.         {
  1203.             UINT  x  : 10;    // 0/1023 to 1023/1023
  1204.             UINT  y  : 10;    // 0/1023 to 1023/1023
  1205.             UINT  z  : 10;    // 0/1023 to 1023/1023
  1206.             UINT  w  : 2;     //    0/3 to       3/3
  1207.         };
  1208.         UINT v;
  1209.     };
  1210.  
  1211. #ifdef __cplusplus
  1212.  
  1213.     _XMUDECN4() {};
  1214.     _XMUDECN4(UINT Packed) : v(Packed) {};
  1215.     _XMUDECN4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1216.     _XMUDECN4(CONST FLOAT *pArray);
  1217.  
  1218.     operator UINT () { return v; }
  1219.  
  1220.     _XMUDECN4& operator= (CONST _XMUDECN4& UDecN4);
  1221.     _XMUDECN4& operator= (CONST UINT Packed);
  1222.  
  1223. #endif // __cplusplus
  1224.  
  1225. } XMUDECN4;
  1226.  
  1227. // 4D Vector; 10-10-10-2 bit components packed into a 32 bit integer
  1228. // The 4D Vector is packed into 32 bits as follows: a 2 bit unsigned,
  1229. // integer for the w component and 10 bit unsigned integers
  1230. // for the z, y, and x components.  The w component is stored in the
  1231. // most significant bits and the x component in the least significant bits
  1232. // (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
  1233. typedef struct _XMUDEC4
  1234. {
  1235.     union
  1236.     {
  1237.         struct
  1238.         {
  1239.             UINT  x  : 10;    // 0 to 1023
  1240.             UINT  y  : 10;    // 0 to 1023
  1241.             UINT  z  : 10;    // 0 to 1023
  1242.             UINT  w  : 2;     // 0 to    3
  1243.         };
  1244.         UINT v;
  1245.     };
  1246.  
  1247. #ifdef __cplusplus
  1248.  
  1249.     _XMUDEC4() {};
  1250.     _XMUDEC4(UINT Packed) : v(Packed) {};
  1251.     _XMUDEC4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1252.     _XMUDEC4(CONST FLOAT *pArray);
  1253.  
  1254.     operator UINT () { return v; }
  1255.  
  1256.     _XMUDEC4& operator= (CONST _XMUDEC4& UDec4);
  1257.     _XMUDEC4& operator= (CONST UINT Packed);
  1258.  
  1259. #endif // __cplusplus
  1260.  
  1261. } XMUDEC4;
  1262.  
  1263. // 4D Vector; 20-20-20-4 bit normalized components packed into a 64 bit integer
  1264. // The normalized 4D Vector is packed into 64 bits as follows: a 4 bit unsigned,
  1265. // normalized integer for the w component and 20 bit signed, normalized
  1266. // integers for the z, y, and x components.  The w component is stored in the
  1267. // most significant bits and the x component in the least significant bits
  1268. // (W4Z20Y20X20): [64] wwwwzzzz zzzzzzzz zzzzzzzz yyyyyyyy yyyyyyyy yyyyxxxx xxxxxxxx xxxxxxxx [0]
  1269. typedef struct _XMXICON4
  1270. {
  1271.     union
  1272.     {
  1273.         struct
  1274.         {
  1275.             INT64  x   : 20;    // -524287/524287 to 524287/524287
  1276.             INT64  y   : 20;    // -524287/524287 to 524287/524287
  1277.             INT64  z   : 20;    // -524287/524287 to 524287/524287
  1278.             UINT64 w   : 4;     //           0/15 to         15/15
  1279.         };
  1280.         UINT64 v;
  1281.     };
  1282.  
  1283. #ifdef __cplusplus
  1284.  
  1285.     _XMXICON4() {};
  1286.     _XMXICON4(UINT64 Packed) : v(Packed) {};
  1287.     _XMXICON4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1288.     _XMXICON4(CONST FLOAT *pArray);
  1289.  
  1290.     operator UINT64 () { return v; }
  1291.  
  1292.     _XMXICON4& operator= (CONST _XMXICON4& XIcoN4);
  1293.     _XMXICON4& operator= (CONST UINT64 Packed);
  1294.  
  1295. #endif // __cplusplus
  1296.  
  1297. } XMXICON4;
  1298.  
  1299. // 4D Vector; 20-20-20-4 bit components packed into a 64 bit integer
  1300. // The 4D Vector is packed into 64 bits as follows: a 4 bit unsigned
  1301. // integer for the w component and 20 bit signed integers for the
  1302. // z, y, and x components.  The w component is stored in the
  1303. // most significant bits and the x component in the least significant bits
  1304. // (W4Z20Y20X20): [64] wwwwzzzz zzzzzzzz zzzzzzzz yyyyyyyy yyyyyyyy yyyyxxxx xxxxxxxx xxxxxxxx [0]
  1305. typedef struct _XMXICO4
  1306. {
  1307.     union
  1308.     {
  1309.         struct
  1310.         {
  1311.             INT64  x   : 20;    // -524287 to 524287
  1312.             INT64  y   : 20;    // -524287 to 524287
  1313.             INT64  z   : 20;    // -524287 to 524287
  1314.             UINT64 w   : 4;     //       0 to     15
  1315.         };
  1316.         UINT64 v;
  1317.     };
  1318.  
  1319. #ifdef __cplusplus
  1320.  
  1321.     _XMXICO4() {};
  1322.     _XMXICO4(UINT64 Packed) : v(Packed) {};
  1323.     _XMXICO4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1324.     _XMXICO4(CONST FLOAT *pArray);
  1325.  
  1326.     operator UINT64 () { return v; }
  1327.  
  1328.     _XMXICO4& operator= (CONST _XMXICO4& XIco4);
  1329.     _XMXICO4& operator= (CONST UINT64 Packed);
  1330.  
  1331. #endif // __cplusplus
  1332.  
  1333. } XMXICO4;
  1334.  
  1335. // 4D Vector; 20-20-20-4 bit normalized components packed into a 64 bit integer
  1336. // The normalized 4D Vector is packed into 64 bits as follows: a 4 bit signed,
  1337. // normalized integer for the w component and 20 bit signed, normalized
  1338. // integers for the z, y, and x components.  The w component is stored in the
  1339. // most significant bits and the x component in the least significant bits
  1340. // (W4Z20Y20X20): [64] wwwwzzzz zzzzzzzz zzzzzzzz yyyyyyyy yyyyyyyy yyyyxxxx xxxxxxxx xxxxxxxx [0]
  1341. typedef struct _XMICON4
  1342. {
  1343.     union
  1344.     {
  1345.         struct
  1346.         {
  1347.             INT64  x   : 20;    // -524287/524287 to 524287/524287
  1348.             INT64  y   : 20;    // -524287/524287 to 524287/524287
  1349.             INT64  z   : 20;    // -524287/524287 to 524287/524287
  1350.             INT64  w   : 4;     //           -7/7 to           7/7
  1351.         };
  1352.         UINT64 v;
  1353.     };
  1354.  
  1355. #ifdef __cplusplus
  1356.  
  1357.     _XMICON4() {};
  1358.     _XMICON4(UINT64 Packed) : v(Packed) {};
  1359.     _XMICON4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1360.     _XMICON4(CONST FLOAT *pArray);
  1361.  
  1362.     operator UINT64 () { return v; }
  1363.  
  1364.     _XMICON4& operator= (CONST _XMICON4& IcoN4);
  1365.     _XMICON4& operator= (CONST UINT64 Packed);
  1366.  
  1367. #endif // __cplusplus
  1368.  
  1369. } XMICON4;
  1370.  
  1371. // 4D Vector; 20-20-20-4 bit components packed into a 64 bit integer
  1372. // The 4D Vector is packed into 64 bits as follows: a 4 bit signed,
  1373. // integer for the w component and 20 bit signed integers for the
  1374. // z, y, and x components.  The w component is stored in the
  1375. // most significant bits and the x component in the least significant bits
  1376. // (W4Z20Y20X20): [64] wwwwzzzz zzzzzzzz zzzzzzzz yyyyyyyy yyyyyyyy yyyyxxxx xxxxxxxx xxxxxxxx [0]
  1377. typedef struct _XMICO4
  1378. {
  1379.     union
  1380.     {
  1381.         struct
  1382.         {
  1383.             INT64  x   : 20;    // -524287 to 524287
  1384.             INT64  y   : 20;    // -524287 to 524287
  1385.             INT64  z   : 20;    // -524287 to 524287
  1386.             INT64  w   : 4;     //      -7 to      7
  1387.         };
  1388.         UINT64 v;
  1389.     };
  1390.  
  1391. #ifdef __cplusplus
  1392.  
  1393.     _XMICO4() {};
  1394.     _XMICO4(UINT64 Packed) : v(Packed) {};
  1395.     _XMICO4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1396.     _XMICO4(CONST FLOAT *pArray);
  1397.  
  1398.     operator UINT64 () { return v; }
  1399.  
  1400.     _XMICO4& operator= (CONST _XMICO4& Ico4);
  1401.     _XMICO4& operator= (CONST UINT64 Packed);
  1402.  
  1403. #endif // __cplusplus
  1404.  
  1405. } XMICO4;
  1406.  
  1407. // 4D Vector; 20-20-20-4 bit normalized components packed into a 64 bit integer
  1408. // The normalized 4D Vector is packed into 64 bits as follows: a 4 bit unsigned,
  1409. // normalized integer for the w component and 20 bit unsigned, normalized
  1410. // integers for the z, y, and x components.  The w component is stored in the
  1411. // most significant bits and the x component in the least significant bits
  1412. // (W4Z20Y20X20): [64] wwwwzzzz zzzzzzzz zzzzzzzz yyyyyyyy yyyyyyyy yyyyxxxx xxxxxxxx xxxxxxxx [0]
  1413. typedef struct _XMUICON4
  1414. {
  1415.     union
  1416.     {
  1417.         struct
  1418.         {
  1419.             UINT64  x  : 20;    // 0/1048575 to 1048575/1048575
  1420.             UINT64  y  : 20;    // 0/1048575 to 1048575/1048575
  1421.             UINT64  z  : 20;    // 0/1048575 to 1048575/1048575
  1422.             UINT64  w  : 4;     //      0/15 to           15/15
  1423.         };
  1424.         UINT64 v;
  1425.     };
  1426.  
  1427. #ifdef __cplusplus
  1428.  
  1429.     _XMUICON4() {};
  1430.     _XMUICON4(UINT64 Packed) : v(Packed) {};
  1431.     _XMUICON4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1432.     _XMUICON4(CONST FLOAT *pArray);
  1433.  
  1434.     operator UINT64 () { return v; }
  1435.  
  1436.     _XMUICON4& operator= (CONST _XMUICON4& UIcoN4);
  1437.     _XMUICON4& operator= (CONST UINT64 Packed);
  1438.  
  1439. #endif // __cplusplus
  1440.  
  1441. } XMUICON4;
  1442.  
  1443. // 4D Vector; 20-20-20-4 bit components packed into a 64 bit integer
  1444. // The 4D Vector is packed into 64 bits as follows: a 4 bit unsigned
  1445. // integer for the w component and 20 bit unsigned integers for the
  1446. // z, y, and x components.  The w component is stored in the
  1447. // most significant bits and the x component in the least significant bits
  1448. // (W4Z20Y20X20): [64] wwwwzzzz zzzzzzzz zzzzzzzz yyyyyyyy yyyyyyyy yyyyxxxx xxxxxxxx xxxxxxxx [0]
  1449. typedef struct _XMUICO4
  1450. {
  1451.     union
  1452.     {
  1453.         struct
  1454.         {
  1455.             UINT64  x  : 20;    // 0 to 1048575
  1456.             UINT64  y  : 20;    // 0 to 1048575
  1457.             UINT64  z  : 20;    // 0 to 1048575
  1458.             UINT64  w  : 4;     // 0 to      15
  1459.         };
  1460.         UINT64 v;
  1461.     };
  1462.  
  1463. #ifdef __cplusplus
  1464.  
  1465.     _XMUICO4() {};
  1466.     _XMUICO4(UINT64 Packed) : v(Packed) {};
  1467.     _XMUICO4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1468.     _XMUICO4(CONST FLOAT *pArray);
  1469.  
  1470.     operator UINT64 () { return v; }
  1471.  
  1472.     _XMUICO4& operator= (CONST _XMUICO4& UIco4);
  1473.     _XMUICO4& operator= (CONST UINT64 Packed);
  1474.  
  1475. #endif // __cplusplus
  1476.  
  1477. } XMUICO4;
  1478.  
  1479. // ARGB Color; 8-8-8-8 bit unsigned normalized integer components packed into
  1480. // a 32 bit integer.  The normalized color is packed into 32 bits using 8 bit
  1481. // unsigned, normalized integers for the alpha, red, green, and blue components.
  1482. // The alpha component is stored in the most significant bits and the blue
  1483. // component in the least significant bits (A8R8G8B8):
  1484. // [32] aaaaaaaa rrrrrrrr gggggggg bbbbbbbb [0]
  1485. typedef struct _XMCOLOR
  1486. {
  1487.     union
  1488.     {
  1489.         struct
  1490.         {
  1491.             UINT b    : 8;  // Blue:    0/255 to 255/255
  1492.             UINT g    : 8;  // Green:   0/255 to 255/255
  1493.             UINT r    : 8;  // Red:     0/255 to 255/255
  1494.             UINT a    : 8;  // Alpha:   0/255 to 255/255
  1495.         };
  1496.         UINT c;
  1497.     };
  1498.  
  1499. #ifdef __cplusplus
  1500.  
  1501.     _XMCOLOR() {};
  1502.     _XMCOLOR(UINT Color) : c(Color) {};
  1503.     _XMCOLOR(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1504.     _XMCOLOR(CONST FLOAT *pArray);
  1505.  
  1506.     operator UINT () { return c; }
  1507.  
  1508.     _XMCOLOR& operator= (CONST _XMCOLOR& Color);
  1509.     _XMCOLOR& operator= (CONST UINT Color);
  1510.  
  1511. #endif // __cplusplus
  1512.  
  1513. } XMCOLOR;
  1514.  
  1515. // 4D Vector; 8 bit signed normalized integer components
  1516. typedef struct _XMBYTEN4
  1517. {
  1518.     union
  1519.     {
  1520.         struct
  1521.         {
  1522.             CHAR x;
  1523.             CHAR y;
  1524.             CHAR z;
  1525.             CHAR w;
  1526.         };
  1527.         UINT v;
  1528.     };
  1529.  
  1530. #ifdef __cplusplus
  1531.  
  1532.     _XMBYTEN4() {};
  1533.     _XMBYTEN4(CHAR _x, CHAR _y, CHAR _z, CHAR _w) : x(_x), y(_y), z(_z), w(_w) {};
  1534.     _XMBYTEN4(UINT Packed) : v(Packed) {};
  1535.     _XMBYTEN4(CONST CHAR *pArray);
  1536.     _XMBYTEN4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1537.     _XMBYTEN4(CONST FLOAT *pArray);
  1538.  
  1539.     _XMBYTEN4& operator= (CONST _XMBYTEN4& ByteN4);
  1540.  
  1541. #endif // __cplusplus
  1542.  
  1543. } XMBYTEN4;
  1544.  
  1545. // 4D Vector; 8 bit signed integer components
  1546. typedef struct _XMBYTE4
  1547. {
  1548.     union
  1549.     {
  1550.         struct
  1551.         {
  1552.             CHAR x;
  1553.             CHAR y;
  1554.             CHAR z;
  1555.             CHAR w;
  1556.         };
  1557.         UINT v;
  1558.     };
  1559.  
  1560. #ifdef __cplusplus
  1561.  
  1562.     _XMBYTE4() {};
  1563.     _XMBYTE4(CHAR _x, CHAR _y, CHAR _z, CHAR _w) : x(_x), y(_y), z(_z), w(_w) {};
  1564.     _XMBYTE4(UINT Packed) : v(Packed) {};
  1565.     _XMBYTE4(CONST CHAR *pArray);
  1566.     _XMBYTE4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1567.     _XMBYTE4(CONST FLOAT *pArray);
  1568.  
  1569.     _XMBYTE4& operator= (CONST _XMBYTE4& Byte4);
  1570.  
  1571. #endif // __cplusplus
  1572.  
  1573. } XMBYTE4;
  1574.  
  1575. // 4D Vector; 8 bit unsigned normalized integer components
  1576. typedef struct _XMUBYTEN4
  1577. {
  1578.     union
  1579.     {
  1580.         struct
  1581.         {
  1582.             BYTE x;
  1583.             BYTE y;
  1584.             BYTE z;
  1585.             BYTE w;
  1586.         };
  1587.         UINT v;
  1588.     };
  1589.  
  1590. #ifdef __cplusplus
  1591.  
  1592.     _XMUBYTEN4() {};
  1593.     _XMUBYTEN4(BYTE _x, BYTE _y, BYTE _z, BYTE _w) : x(_x), y(_y), z(_z), w(_w) {};
  1594.     _XMUBYTEN4(UINT Packed) : v(Packed) {};
  1595.     _XMUBYTEN4(CONST BYTE *pArray);
  1596.     _XMUBYTEN4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1597.     _XMUBYTEN4(CONST FLOAT *pArray);
  1598.  
  1599.     _XMUBYTEN4& operator= (CONST _XMUBYTEN4& UByteN4);
  1600.  
  1601. #endif // __cplusplus
  1602.  
  1603. } XMUBYTEN4;
  1604.  
  1605. // 4D Vector; 8 bit unsigned integer components
  1606. typedef struct _XMUBYTE4
  1607. {
  1608.     union
  1609.     {
  1610.         struct
  1611.         {
  1612.             BYTE x;
  1613.             BYTE y;
  1614.             BYTE z;
  1615.             BYTE w;
  1616.         };
  1617.         UINT v;
  1618.     };
  1619.  
  1620. #ifdef __cplusplus
  1621.  
  1622.     _XMUBYTE4() {};
  1623.     _XMUBYTE4(BYTE _x, BYTE _y, BYTE _z, BYTE _w) : x(_x), y(_y), z(_z), w(_w) {};
  1624.     _XMUBYTE4(UINT Packed) : v(Packed) {};
  1625.     _XMUBYTE4(CONST BYTE *pArray);
  1626.     _XMUBYTE4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1627.     _XMUBYTE4(CONST FLOAT *pArray);
  1628.  
  1629.     _XMUBYTE4& operator= (CONST _XMUBYTE4& UByte4);
  1630.  
  1631. #endif // __cplusplus
  1632.  
  1633. } XMUBYTE4;
  1634.  
  1635. // 4D vector; 4 bit unsigned integer components
  1636. typedef struct _XMUNIBBLE4
  1637. {
  1638.     union
  1639.     {
  1640.         struct
  1641.         {
  1642.             USHORT x  : 4;
  1643.             USHORT y  : 4;
  1644.             USHORT z  : 4;
  1645.             USHORT w  : 4;
  1646.         };
  1647.         USHORT v;
  1648.     };
  1649.  
  1650. #ifdef __cplusplus
  1651.  
  1652.     _XMUNIBBLE4() {};
  1653.     _XMUNIBBLE4(USHORT Packed) : v(Packed) {};
  1654.     _XMUNIBBLE4(CHAR _x, CHAR _y, CHAR _z, CHAR _w) : x(_x), y(_y), z(_z), w(_w) {};
  1655.     _XMUNIBBLE4(CONST CHAR *pArray);
  1656.     _XMUNIBBLE4(FLOAT _x, FLOAT _y, FLOAT _z, FLOAT _w);
  1657.     _XMUNIBBLE4(CONST FLOAT *pArray);
  1658.  
  1659.     operator USHORT () { return v; }
  1660.  
  1661.     _XMUNIBBLE4& operator= (CONST _XMUNIBBLE4& UNibble4);
  1662.     _XMUNIBBLE4& operator= (CONST USHORT Packed);
  1663.  
  1664. #endif // __cplusplus
  1665.  
  1666. } XMUNIBBLE4;
  1667.  
  1668. // 4D vector: 5/5/5/1 unsigned integer components
  1669. typedef struct _XMU555
  1670. {
  1671.     union
  1672.     {
  1673.         struct
  1674.         {
  1675.             USHORT x  : 5;
  1676.             USHORT y  : 5;
  1677.             USHORT z  : 5;
  1678.             USHORT w  : 1;
  1679.         };
  1680.         USHORT v;
  1681.     };
  1682.  
  1683. #ifdef __cplusplus
  1684.  
  1685.     _XMU555() {};
  1686.     _XMU555(USHORT Packed) : v(Packed) {};
  1687.     _XMU555(CHAR _x, CHAR _y, CHAR _z, BOOL _w) : x(_x), y(_y), z(_z), w(_w ? 0x1 : 0) {};
  1688.     _XMU555(CONST CHAR *pArray, BOOL _w);
  1689.     _XMU555(FLOAT _x, FLOAT _y, FLOAT _z, BOOL _w);
  1690.     _XMU555(CONST FLOAT *pArray, BOOL _w);
  1691.  
  1692.     operator USHORT () { return v; }
  1693.  
  1694.     _XMU555& operator= (CONST _XMU555& U555);
  1695.     _XMU555& operator= (CONST USHORT Packed);
  1696.  
  1697. #endif // __cplusplus
  1698.  
  1699. } XMU555;
  1700.  
  1701. // 3x3 Matrix: 32 bit floating point components
  1702. typedef struct _XMFLOAT3X3
  1703. {
  1704.     union
  1705.     {
  1706.         struct
  1707.         {
  1708.             FLOAT _11, _12, _13;
  1709.             FLOAT _21, _22, _23;
  1710.             FLOAT _31, _32, _33;
  1711.         };
  1712.         FLOAT m[3][3];
  1713.     };
  1714.  
  1715. #ifdef __cplusplus
  1716.  
  1717.     _XMFLOAT3X3() {};
  1718.     _XMFLOAT3X3(FLOAT m00, FLOAT m01, FLOAT m02,
  1719.                 FLOAT m10, FLOAT m11, FLOAT m12,
  1720.                 FLOAT m20, FLOAT m21, FLOAT m22);
  1721.     _XMFLOAT3X3(CONST FLOAT *pArray);
  1722.  
  1723.     FLOAT       operator() (UINT Row, UINT Column) CONST { return m[Row][Column]; }
  1724.     FLOAT&      operator() (UINT Row, UINT Column) { return m[Row][Column]; }
  1725.  
  1726.     _XMFLOAT3X3& operator= (CONST _XMFLOAT3X3& Float3x3);
  1727.  
  1728. #endif // __cplusplus
  1729.  
  1730. } XMFLOAT3X3;
  1731.  
  1732. // 4x3 Matrix: 32 bit floating point components
  1733. typedef struct _XMFLOAT4X3
  1734. {
  1735.     union
  1736.     {
  1737.         struct
  1738.         {
  1739.             FLOAT _11, _12, _13;
  1740.             FLOAT _21, _22, _23;
  1741.             FLOAT _31, _32, _33;
  1742.             FLOAT _41, _42, _43;
  1743.         };
  1744.         FLOAT m[4][3];
  1745.     };
  1746.  
  1747. #ifdef __cplusplus
  1748.  
  1749.     _XMFLOAT4X3() {};
  1750.     _XMFLOAT4X3(FLOAT m00, FLOAT m01, FLOAT m02,
  1751.                 FLOAT m10, FLOAT m11, FLOAT m12,
  1752.                 FLOAT m20, FLOAT m21, FLOAT m22,
  1753.                 FLOAT m30, FLOAT m31, FLOAT m32);
  1754.     _XMFLOAT4X3(CONST FLOAT *pArray);
  1755.  
  1756.     FLOAT       operator() (UINT Row, UINT Column) CONST { return m[Row][Column]; }
  1757.     FLOAT&      operator() (UINT Row, UINT Column) { return m[Row][Column]; }
  1758.  
  1759.     _XMFLOAT4X3& operator= (CONST _XMFLOAT4X3& Float4x3);
  1760.  
  1761. #endif // __cplusplus
  1762.  
  1763. } XMFLOAT4X3;
  1764.  
  1765. // 4x3 Matrix: 32 bit floating point components aligned on a 16 byte boundary
  1766. typedef __declspec(align(16)) XMFLOAT4X3 XMFLOAT4X3A;
  1767.  
  1768. // 4x4 Matrix: 32 bit floating point components
  1769. typedef struct _XMFLOAT4X4
  1770. {
  1771.     union
  1772.     {
  1773.         struct
  1774.         {
  1775.             FLOAT _11, _12, _13, _14;
  1776.             FLOAT _21, _22, _23, _24;
  1777.             FLOAT _31, _32, _33, _34;
  1778.             FLOAT _41, _42, _43, _44;
  1779.         };
  1780.         FLOAT m[4][4];
  1781.     };
  1782.  
  1783. #ifdef __cplusplus
  1784.  
  1785.     _XMFLOAT4X4() {};
  1786.     _XMFLOAT4X4(FLOAT m00, FLOAT m01, FLOAT m02, FLOAT m03,
  1787.                 FLOAT m10, FLOAT m11, FLOAT m12, FLOAT m13,
  1788.                 FLOAT m20, FLOAT m21, FLOAT m22, FLOAT m23,
  1789.                 FLOAT m30, FLOAT m31, FLOAT m32, FLOAT m33);
  1790.     _XMFLOAT4X4(CONST FLOAT *pArray);
  1791.  
  1792.     FLOAT       operator() (UINT Row, UINT Column) CONST { return m[Row][Column]; }
  1793.     FLOAT&      operator() (UINT Row, UINT Column) { return m[Row][Column]; }
  1794.  
  1795.     _XMFLOAT4X4& operator= (CONST _XMFLOAT4X4& Float4x4);
  1796.  
  1797. #endif // __cplusplus
  1798.  
  1799. } XMFLOAT4X4;
  1800.  
  1801. // 4x4 Matrix: 32 bit floating point components aligned on a 16 byte boundary
  1802. typedef __declspec(align(16)) XMFLOAT4X4 XMFLOAT4X4A;
  1803.  
  1804. #if !defined(_XM_X86_) && !defined(_XM_X64_)
  1805. #pragma bitfield_order(pop)
  1806. #endif // !_XM_X86_ && !_XM_X64_
  1807.  
  1808. #pragma warning(pop)
  1809.  
  1810. /****************************************************************************
  1811.  *
  1812.  * Data conversion operations
  1813.  *
  1814.  ****************************************************************************/
  1815.  
  1816. #if !defined(_XM_NO_INTRINSICS_) && defined(_XM_VMX128_INTRINSICS_)
  1817. #else
  1818. XMVECTOR        XMConvertVectorIntToFloat(FXMVECTOR VInt, UINT DivExponent);
  1819. XMVECTOR        XMConvertVectorFloatToInt(FXMVECTOR VFloat, UINT MulExponent);
  1820. XMVECTOR        XMConvertVectorUIntToFloat(FXMVECTOR VUInt, UINT DivExponent);
  1821. XMVECTOR        XMConvertVectorFloatToUInt(FXMVECTOR VFloat, UINT MulExponent);
  1822. #endif
  1823.  
  1824. FLOAT           XMConvertHalfToFloat(HALF Value);
  1825. FLOAT*          XMConvertHalfToFloatStream(__out_bcount(sizeof(FLOAT)+OutputStride*(HalfCount-1)) FLOAT* pOutputStream,
  1826.                                            __in UINT OutputStride,
  1827.                                            __in_bcount(sizeof(HALF)+InputStride*(HalfCount-1)) CONST HALF* pInputStream,
  1828.                                            __in UINT InputStride, __in UINT HalfCount);
  1829. HALF            XMConvertFloatToHalf(FLOAT Value);
  1830. HALF*           XMConvertFloatToHalfStream(__out_bcount(sizeof(HALF)+OutputStride*(FloatCount-1)) HALF* pOutputStream,
  1831.                                            __in UINT OutputStride,
  1832.                                            __in_bcount(sizeof(FLOAT)+InputStride*(FloatCount-1)) CONST FLOAT* pInputStream,
  1833.                                            __in UINT InputStride, __in UINT FloatCount);
  1834.  
  1835. #if !defined(_XM_NO_INTRINSICS_) && defined(_XM_VMX128_INTRINSICS_)
  1836. #else
  1837. XMVECTOR XMVectorSetBinaryConstant(UINT C0, UINT C1, UINT C2, UINT C3);
  1838. XMVECTOR XMVectorSplatConstant(INT IntConstant, UINT DivExponent);
  1839. XMVECTOR XMVectorSplatConstantInt(INT IntConstant);
  1840. #endif
  1841.  
  1842. /****************************************************************************
  1843.  *
  1844.  * Load operations
  1845.  *
  1846.  ****************************************************************************/
  1847.  
  1848. XMVECTOR        XMLoadInt(__in CONST UINT* pSource);
  1849. XMVECTOR        XMLoadFloat(__in CONST FLOAT* pSource);
  1850.  
  1851. XMVECTOR        XMLoadInt2(__in_ecount(2) CONST UINT* pSource);
  1852. XMVECTOR        XMLoadInt2A(__in_ecount(2) CONST UINT* PSource);
  1853. XMVECTOR        XMLoadFloat2(__in CONST XMFLOAT2* pSource);
  1854. XMVECTOR        XMLoadFloat2A(__in CONST XMFLOAT2A* pSource);
  1855. XMVECTOR        XMLoadHalf2(__in CONST XMHALF2* pSource);
  1856. XMVECTOR        XMLoadShortN2(__in CONST XMSHORTN2* pSource);
  1857. XMVECTOR        XMLoadShort2(__in CONST XMSHORT2* pSource);
  1858. XMVECTOR        XMLoadUShortN2(__in CONST XMUSHORTN2* pSource);
  1859. XMVECTOR        XMLoadUShort2(__in CONST XMUSHORT2* pSource);
  1860.  
  1861. XMVECTOR        XMLoadInt3(__in_ecount(3) CONST UINT* pSource);
  1862. XMVECTOR        XMLoadInt3A(__in_ecount(3) CONST UINT* pSource);
  1863. XMVECTOR        XMLoadFloat3(__in CONST XMFLOAT3* pSource);
  1864. XMVECTOR        XMLoadFloat3A(__in CONST XMFLOAT3A* pSource);
  1865. XMVECTOR        XMLoadHenDN3(__in CONST XMHENDN3* pSource);
  1866. XMVECTOR        XMLoadHenD3(__in CONST XMHEND3* pSource);
  1867. XMVECTOR        XMLoadUHenDN3(__in CONST XMUHENDN3* pSource);
  1868. XMVECTOR        XMLoadUHenD3(__in CONST XMUHEND3* pSource);
  1869. XMVECTOR        XMLoadDHenN3(__in CONST XMDHENN3* pSource);
  1870. XMVECTOR        XMLoadDHen3(__in CONST XMDHEN3* pSource);
  1871. XMVECTOR        XMLoadUDHenN3(__in CONST XMUDHENN3* pSource);
  1872. XMVECTOR        XMLoadUDHen3(__in CONST XMUDHEN3* pSource);
  1873. XMVECTOR        XMLoadU565(__in CONST XMU565* pSource);
  1874. XMVECTOR        XMLoadFloat3PK(__in CONST XMFLOAT3PK* pSource);
  1875. XMVECTOR        XMLoadFloat3SE(__in CONST XMFLOAT3SE* pSource);
  1876.  
  1877. XMVECTOR        XMLoadInt4(__in_ecount(4) CONST UINT* pSource);
  1878. XMVECTOR        XMLoadInt4A(__in_ecount(4) CONST UINT* pSource);
  1879. XMVECTOR        XMLoadFloat4(__in CONST XMFLOAT4* pSource);
  1880. XMVECTOR        XMLoadFloat4A(__in CONST XMFLOAT4A* pSource);
  1881. XMVECTOR        XMLoadHalf4(__in CONST XMHALF4* pSource);
  1882. XMVECTOR        XMLoadShortN4(__in CONST XMSHORTN4* pSource);
  1883. XMVECTOR        XMLoadShort4(__in CONST XMSHORT4* pSource);
  1884. XMVECTOR        XMLoadUShortN4(__in CONST XMUSHORTN4* pSource);
  1885. XMVECTOR        XMLoadUShort4(__in CONST XMUSHORT4* pSource);
  1886. XMVECTOR        XMLoadXIcoN4(__in CONST XMXICON4* pSource);
  1887. XMVECTOR        XMLoadXIco4(__in CONST XMXICO4* pSource);
  1888. XMVECTOR        XMLoadIcoN4(__in CONST XMICON4* pSource);
  1889. XMVECTOR        XMLoadIco4(__in CONST XMICO4* pSource);
  1890. XMVECTOR        XMLoadUIcoN4(__in CONST XMUICON4* pSource);
  1891. XMVECTOR        XMLoadUIco4(__in CONST XMUICO4* pSource);
  1892. XMVECTOR        XMLoadXDecN4(__in CONST XMXDECN4* pSource);
  1893. XMVECTOR        XMLoadXDec4(__in CONST XMXDEC4* pSource);
  1894. XMVECTOR        XMLoadDecN4(__in CONST XMDECN4* pSource);
  1895. XMVECTOR        XMLoadDec4(__in CONST XMDEC4* pSource);
  1896. XMVECTOR        XMLoadUDecN4(__in CONST XMUDECN4* pSource);
  1897. XMVECTOR        XMLoadUDec4(__in CONST XMUDEC4* pSource);
  1898. XMVECTOR        XMLoadByteN4(__in CONST XMBYTEN4* pSource);
  1899. XMVECTOR        XMLoadByte4(__in CONST XMBYTE4* pSource);
  1900. XMVECTOR        XMLoadUByteN4(__in CONST XMUBYTEN4* pSource);
  1901. XMVECTOR        XMLoadUByte4(__in CONST XMUBYTE4* pSource);
  1902. XMVECTOR        XMLoadUNibble4(__in CONST XMUNIBBLE4* pSource);
  1903. XMVECTOR        XMLoadU555(__in CONST XMU555* pSource);
  1904. XMVECTOR        XMLoadColor(__in CONST XMCOLOR* pSource);
  1905.  
  1906. XMMATRIX        XMLoadFloat3x3(__in CONST XMFLOAT3X3* pSource);
  1907. XMMATRIX        XMLoadFloat4x3(__in CONST XMFLOAT4X3* pSource);
  1908. XMMATRIX        XMLoadFloat4x3A(__in CONST XMFLOAT4X3A* pSource);
  1909. XMMATRIX        XMLoadFloat4x4(__in CONST XMFLOAT4X4* pSource);
  1910. XMMATRIX        XMLoadFloat4x4A(__in CONST XMFLOAT4X4A* pSource);
  1911.  
  1912. /****************************************************************************
  1913.  *
  1914.  * Store operations
  1915.  *
  1916.  ****************************************************************************/
  1917.  
  1918. VOID            XMStoreInt(__out UINT* pDestination, FXMVECTOR V);
  1919. VOID            XMStoreFloat(__out FLOAT* pDestination, FXMVECTOR V);
  1920.  
  1921. VOID            XMStoreInt2(__out_ecount(2) UINT* pDestination, FXMVECTOR V);
  1922. VOID            XMStoreInt2A(__out_ecount(2) UINT* pDestination, FXMVECTOR V);
  1923. VOID            XMStoreFloat2(__out XMFLOAT2* pDestination, FXMVECTOR V);
  1924. VOID            XMStoreFloat2A(__out XMFLOAT2A* pDestination, FXMVECTOR V);
  1925. VOID            XMStoreHalf2(__out XMHALF2* pDestination, FXMVECTOR V);
  1926. VOID            XMStoreShortN2(__out XMSHORTN2* pDestination, FXMVECTOR V);
  1927. VOID            XMStoreShort2(__out XMSHORT2* pDestination, FXMVECTOR V);
  1928. VOID            XMStoreUShortN2(__out XMUSHORTN2* pDestination, FXMVECTOR V);
  1929. VOID            XMStoreUShort2(__out XMUSHORT2* pDestination, FXMVECTOR V);
  1930.  
  1931. VOID            XMStoreInt3(__out_ecount(3) UINT* pDestination, FXMVECTOR V);
  1932. VOID            XMStoreInt3A(__out_ecount(3) UINT* pDestination, FXMVECTOR V);
  1933. VOID            XMStoreFloat3(__out XMFLOAT3* pDestination, FXMVECTOR V);
  1934. VOID            XMStoreFloat3A(__out XMFLOAT3A* pDestination, FXMVECTOR V);
  1935. VOID            XMStoreHenDN3(__out XMHENDN3* pDestination, FXMVECTOR V);
  1936. VOID            XMStoreHenD3(__out XMHEND3* pDestination, FXMVECTOR V);
  1937. VOID            XMStoreUHenDN3(__out XMUHENDN3* pDestination, FXMVECTOR V);
  1938. VOID            XMStoreUHenD3(__out XMUHEND3* pDestination, FXMVECTOR V);
  1939. VOID            XMStoreDHenN3(__out XMDHENN3* pDestination, FXMVECTOR V);
  1940. VOID            XMStoreDHen3(__out XMDHEN3* pDestination, FXMVECTOR V);
  1941. VOID            XMStoreUDHenN3(__out XMUDHENN3* pDestination, FXMVECTOR V);
  1942. VOID            XMStoreUDHen3(__out XMUDHEN3* pDestination, FXMVECTOR V);
  1943. VOID            XMStoreU565(__out XMU565* pDestination, FXMVECTOR V);
  1944. VOID            XMStoreFloat3PK(__out XMFLOAT3PK* pDestination, FXMVECTOR V);
  1945. VOID            XMStoreFloat3SE(__out XMFLOAT3SE* pDestination, FXMVECTOR V);
  1946.  
  1947. VOID            XMStoreInt4(__out_ecount(4) UINT* pDestination, FXMVECTOR V);
  1948. VOID            XMStoreInt4A(__out_ecount(4) UINT* pDestination, FXMVECTOR V);
  1949. VOID            XMStoreInt4NC(__out UINT* pDestination, FXMVECTOR V);
  1950. VOID            XMStoreFloat4(__out XMFLOAT4* pDestination, FXMVECTOR V);
  1951. VOID            XMStoreFloat4A(__out XMFLOAT4A* pDestination, FXMVECTOR V);
  1952. VOID            XMStoreFloat4NC(__out XMFLOAT4* pDestination, FXMVECTOR V);
  1953. VOID            XMStoreHalf4(__out XMHALF4* pDestination, FXMVECTOR V);
  1954. VOID            XMStoreShortN4(__out XMSHORTN4* pDestination, FXMVECTOR V);
  1955. VOID            XMStoreShort4(__out XMSHORT4* pDestination, FXMVECTOR V);
  1956. VOID            XMStoreUShortN4(__out XMUSHORTN4* pDestination, FXMVECTOR V);
  1957. VOID            XMStoreUShort4(__out XMUSHORT4* pDestination, FXMVECTOR V);
  1958. VOID            XMStoreXIcoN4(__out XMXICON4* pDestination, FXMVECTOR V);
  1959. VOID            XMStoreXIco4(__out XMXICO4* pDestination, FXMVECTOR V);
  1960. VOID            XMStoreIcoN4(__out XMICON4* pDestination, FXMVECTOR V);
  1961. VOID            XMStoreIco4(__out XMICO4* pDestination, FXMVECTOR V);
  1962. VOID            XMStoreUIcoN4(__out XMUICON4* pDestination, FXMVECTOR V);
  1963. VOID            XMStoreUIco4(__out XMUICO4* pDestination, FXMVECTOR V);
  1964. VOID            XMStoreXDecN4(__out XMXDECN4* pDestination, FXMVECTOR V);
  1965. VOID            XMStoreXDec4(__out XMXDEC4* pDestination, FXMVECTOR V);
  1966. VOID            XMStoreDecN4(__out XMDECN4* pDestination, FXMVECTOR V);
  1967. VOID            XMStoreDec4(__out XMDEC4* pDestination, FXMVECTOR V);
  1968. VOID            XMStoreUDecN4(__out XMUDECN4* pDestination, FXMVECTOR V);
  1969. VOID            XMStoreUDec4(__out XMUDEC4* pDestination, FXMVECTOR V);
  1970. VOID            XMStoreByteN4(__out XMBYTEN4* pDestination, FXMVECTOR V);
  1971. VOID            XMStoreByte4(__out XMBYTE4* pDestination, FXMVECTOR V);
  1972. VOID            XMStoreUByteN4(__out XMUBYTEN4* pDestination, FXMVECTOR V);
  1973. VOID            XMStoreUByte4(__out XMUBYTE4* pDestination, FXMVECTOR V);
  1974. VOID            XMStoreUNibble4(__out XMUNIBBLE4* pDestination, FXMVECTOR V);
  1975. VOID            XMStoreU555(__out XMU555* pDestination, FXMVECTOR V);
  1976. VOID            XMStoreColor(__out XMCOLOR* pDestination, FXMVECTOR V);
  1977.  
  1978. VOID            XMStoreFloat3x3(__out XMFLOAT3X3* pDestination, CXMMATRIX M);
  1979. VOID            XMStoreFloat3x3NC(__out XMFLOAT3X3* pDestination, CXMMATRIX M);
  1980. VOID            XMStoreFloat4x3(__out XMFLOAT4X3* pDestination, CXMMATRIX M);
  1981. VOID            XMStoreFloat4x3A(__out XMFLOAT4X3A* pDestination, CXMMATRIX M);
  1982. VOID            XMStoreFloat4x3NC(__out XMFLOAT4X3* pDestination, CXMMATRIX M);
  1983. VOID            XMStoreFloat4x4(__out XMFLOAT4X4* pDestination, CXMMATRIX M);
  1984. VOID            XMStoreFloat4x4A(__out XMFLOAT4X4A* pDestination, CXMMATRIX M);
  1985. VOID            XMStoreFloat4x4NC(__out XMFLOAT4X4* pDestination, CXMMATRIX M);
  1986.  
  1987. /****************************************************************************
  1988.  *
  1989.  * General vector operations
  1990.  *
  1991.  ****************************************************************************/
  1992.  
  1993. XMVECTOR        XMVectorZero();
  1994. XMVECTOR        XMVectorSet(FLOAT x, FLOAT y, FLOAT z, FLOAT w);
  1995. XMVECTOR        XMVectorSetInt(UINT x, UINT y, UINT z, UINT w);
  1996. XMVECTOR        XMVectorReplicate(FLOAT Value);
  1997. XMVECTOR        XMVectorReplicatePtr(__in CONST FLOAT *pValue);
  1998. XMVECTOR        XMVectorReplicateInt(UINT Value);
  1999. XMVECTOR        XMVectorReplicateIntPtr(__in CONST UINT *pValue);
  2000. XMVECTOR        XMVectorTrueInt();
  2001. XMVECTOR        XMVectorFalseInt();
  2002. XMVECTOR        XMVectorSplatX(FXMVECTOR V);
  2003. XMVECTOR        XMVectorSplatY(FXMVECTOR V);
  2004. XMVECTOR        XMVectorSplatZ(FXMVECTOR V);
  2005. XMVECTOR        XMVectorSplatW(FXMVECTOR V);
  2006. XMVECTOR        XMVectorSplatOne();
  2007. XMVECTOR        XMVectorSplatInfinity();
  2008. XMVECTOR        XMVectorSplatQNaN();
  2009. XMVECTOR        XMVectorSplatEpsilon();
  2010. XMVECTOR        XMVectorSplatSignMask();
  2011.  
  2012. FLOAT           XMVectorGetByIndex(FXMVECTOR V,UINT i);
  2013. FLOAT           XMVectorGetX(FXMVECTOR V);
  2014. FLOAT           XMVectorGetY(FXMVECTOR V);
  2015. FLOAT           XMVectorGetZ(FXMVECTOR V);
  2016. FLOAT           XMVectorGetW(FXMVECTOR V);
  2017.  
  2018. VOID            XMVectorGetByIndexPtr(__out FLOAT *f, FXMVECTOR V, UINT i);
  2019. VOID            XMVectorGetXPtr(__out FLOAT *x, FXMVECTOR V);
  2020. VOID            XMVectorGetYPtr(__out FLOAT *y, FXMVECTOR V);
  2021. VOID            XMVectorGetZPtr(__out FLOAT *z, FXMVECTOR V);
  2022. VOID            XMVectorGetWPtr(__out FLOAT *w, FXMVECTOR V);
  2023.  
  2024. UINT            XMVectorGetIntByIndex(FXMVECTOR V,UINT i);
  2025. UINT            XMVectorGetIntX(FXMVECTOR V);
  2026. UINT            XMVectorGetIntY(FXMVECTOR V);
  2027. UINT            XMVectorGetIntZ(FXMVECTOR V);
  2028. UINT            XMVectorGetIntW(FXMVECTOR V);
  2029.  
  2030. VOID            XMVectorGetIntByIndexPtr(__out UINT *x,FXMVECTOR V, UINT i);
  2031. VOID            XMVectorGetIntXPtr(__out UINT *x, FXMVECTOR V);
  2032. VOID            XMVectorGetIntYPtr(__out UINT *y, FXMVECTOR V);
  2033. VOID            XMVectorGetIntZPtr(__out UINT *z, FXMVECTOR V);
  2034. VOID            XMVectorGetIntWPtr(__out UINT *w, FXMVECTOR V);
  2035.  
  2036. XMVECTOR        XMVectorSetByIndex(FXMVECTOR V,FLOAT f,UINT i);
  2037. XMVECTOR        XMVectorSetX(FXMVECTOR V, FLOAT x);
  2038. XMVECTOR        XMVectorSetY(FXMVECTOR V, FLOAT y);
  2039. XMVECTOR        XMVectorSetZ(FXMVECTOR V, FLOAT z);
  2040. XMVECTOR        XMVectorSetW(FXMVECTOR V, FLOAT w);
  2041.  
  2042. XMVECTOR        XMVectorSetByIndexPtr(FXMVECTOR V, __in CONST FLOAT *f, UINT i);
  2043. XMVECTOR        XMVectorSetXPtr(FXMVECTOR V, __in CONST FLOAT *x);
  2044. XMVECTOR        XMVectorSetYPtr(FXMVECTOR V, __in CONST FLOAT *y);
  2045. XMVECTOR        XMVectorSetZPtr(FXMVECTOR V, __in CONST FLOAT *z);
  2046. XMVECTOR        XMVectorSetWPtr(FXMVECTOR V, __in CONST FLOAT *w);
  2047.  
  2048. XMVECTOR        XMVectorSetIntByIndex(FXMVECTOR V, UINT x,UINT i);
  2049. XMVECTOR        XMVectorSetIntX(FXMVECTOR V, UINT x);
  2050. XMVECTOR        XMVectorSetIntY(FXMVECTOR V, UINT y);
  2051. XMVECTOR        XMVectorSetIntZ(FXMVECTOR V, UINT z);
  2052. XMVECTOR        XMVectorSetIntW(FXMVECTOR V, UINT w);
  2053.  
  2054. XMVECTOR        XMVectorSetIntByIndexPtr(FXMVECTOR V, __in CONST UINT *x, UINT i);
  2055. XMVECTOR        XMVectorSetIntXPtr(FXMVECTOR V, __in CONST UINT *x);
  2056. XMVECTOR        XMVectorSetIntYPtr(FXMVECTOR V, __in CONST UINT *y);
  2057. XMVECTOR        XMVectorSetIntZPtr(FXMVECTOR V, __in CONST UINT *z);
  2058. XMVECTOR        XMVectorSetIntWPtr(FXMVECTOR V, __in CONST UINT *w);
  2059.  
  2060. XMVECTOR        XMVectorPermuteControl(UINT ElementIndex0, UINT ElementIndex1, UINT ElementIndex2, UINT ElementIndex3);
  2061. XMVECTOR        XMVectorPermute(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Control);
  2062. XMVECTOR        XMVectorSelectControl(UINT VectorIndex0, UINT VectorIndex1, UINT VectorIndex2, UINT VectorIndex3);
  2063. XMVECTOR        XMVectorSelect(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Control);
  2064. XMVECTOR        XMVectorMergeXY(FXMVECTOR V1, FXMVECTOR V2);
  2065. XMVECTOR        XMVectorMergeZW(FXMVECTOR V1, FXMVECTOR V2);
  2066.  
  2067. #if !defined(_XM_NO_INTRINSICS_) && defined(_XM_VMX128_INTRINSICS_)
  2068. #else
  2069. XMVECTOR XMVectorShiftLeft(FXMVECTOR V1, FXMVECTOR V2, UINT Elements);
  2070. XMVECTOR XMVectorRotateLeft(FXMVECTOR V, UINT Elements);
  2071. XMVECTOR XMVectorRotateRight(FXMVECTOR V, UINT Elements);
  2072. XMVECTOR XMVectorSwizzle(FXMVECTOR V, UINT E0, UINT E1, UINT E2, UINT E3);
  2073. XMVECTOR XMVectorInsert(FXMVECTOR VD, FXMVECTOR VS, UINT VSLeftRotateElements,
  2074.                         UINT Select0, UINT Select1, UINT Select2, UINT Select3);
  2075. #endif
  2076.  
  2077. XMVECTOR        XMVectorEqual(FXMVECTOR V1, FXMVECTOR V2);
  2078. XMVECTOR        XMVectorEqualR(__out UINT* pCR, FXMVECTOR V1, FXMVECTOR V2);
  2079. XMVECTOR        XMVectorEqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2080. XMVECTOR        XMVectorEqualIntR(__out UINT* pCR, FXMVECTOR V, FXMVECTOR V2);
  2081. XMVECTOR        XMVectorNearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
  2082. XMVECTOR        XMVectorNotEqual(FXMVECTOR V1, FXMVECTOR V2);
  2083. XMVECTOR        XMVectorNotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2084. XMVECTOR        XMVectorGreater(FXMVECTOR V1, FXMVECTOR V2);
  2085. XMVECTOR        XMVectorGreaterR(__out UINT* pCR, FXMVECTOR V1, FXMVECTOR V2);
  2086. XMVECTOR        XMVectorGreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2087. XMVECTOR        XMVectorGreaterOrEqualR(__out UINT* pCR, FXMVECTOR V1, FXMVECTOR V2);
  2088. XMVECTOR        XMVectorLess(FXMVECTOR V1, FXMVECTOR V2);
  2089. XMVECTOR        XMVectorLessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2090. XMVECTOR        XMVectorInBounds(FXMVECTOR V, FXMVECTOR Bounds);
  2091. XMVECTOR        XMVectorInBoundsR(__out UINT* pCR, FXMVECTOR V, FXMVECTOR Bounds);
  2092.  
  2093. XMVECTOR        XMVectorIsNaN(FXMVECTOR V);
  2094. XMVECTOR        XMVectorIsInfinite(FXMVECTOR V);
  2095.  
  2096. XMVECTOR        XMVectorMin(FXMVECTOR V1,FXMVECTOR V2);
  2097. XMVECTOR        XMVectorMax(FXMVECTOR V1, FXMVECTOR V2);
  2098. XMVECTOR        XMVectorRound(FXMVECTOR V);
  2099. XMVECTOR        XMVectorTruncate(FXMVECTOR V);
  2100. XMVECTOR        XMVectorFloor(FXMVECTOR V);
  2101. XMVECTOR        XMVectorCeiling(FXMVECTOR V);
  2102. XMVECTOR        XMVectorClamp(FXMVECTOR V, FXMVECTOR Min, FXMVECTOR Max);
  2103. XMVECTOR        XMVectorSaturate(FXMVECTOR V);
  2104.  
  2105. XMVECTOR        XMVectorAndInt(FXMVECTOR V1, FXMVECTOR V2);
  2106. XMVECTOR        XMVectorAndCInt(FXMVECTOR V1, FXMVECTOR V2);
  2107. XMVECTOR        XMVectorOrInt(FXMVECTOR V1, FXMVECTOR V2);
  2108. XMVECTOR        XMVectorNorInt(FXMVECTOR V1, FXMVECTOR V2);
  2109. XMVECTOR        XMVectorXorInt(FXMVECTOR V1, FXMVECTOR V2);
  2110.  
  2111. XMVECTOR        XMVectorNegate(FXMVECTOR V);
  2112. XMVECTOR        XMVectorAdd(FXMVECTOR V1, FXMVECTOR V2);
  2113. XMVECTOR        XMVectorAddAngles(FXMVECTOR V1, FXMVECTOR V2);
  2114. XMVECTOR        XMVectorSubtract(FXMVECTOR V1, FXMVECTOR V2);
  2115. XMVECTOR        XMVectorSubtractAngles(FXMVECTOR V1, FXMVECTOR V2);
  2116. XMVECTOR        XMVectorMultiply(FXMVECTOR V1, FXMVECTOR V2);
  2117. XMVECTOR        XMVectorMultiplyAdd(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3);
  2118. XMVECTOR        XMVectorNegativeMultiplySubtract(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3);
  2119. XMVECTOR        XMVectorScale(FXMVECTOR V, FLOAT ScaleFactor);
  2120. XMVECTOR        XMVectorReciprocalEst(FXMVECTOR V);
  2121. XMVECTOR        XMVectorReciprocal(FXMVECTOR V);
  2122. XMVECTOR        XMVectorSqrtEst(FXMVECTOR V);
  2123. XMVECTOR        XMVectorSqrt(FXMVECTOR V);
  2124. XMVECTOR        XMVectorReciprocalSqrtEst(FXMVECTOR V);
  2125. XMVECTOR        XMVectorReciprocalSqrt(FXMVECTOR V);
  2126. XMVECTOR        XMVectorExpEst(FXMVECTOR V);
  2127. XMVECTOR        XMVectorExp(FXMVECTOR V);
  2128. XMVECTOR        XMVectorLogEst(FXMVECTOR V);
  2129. XMVECTOR        XMVectorLog(FXMVECTOR V);
  2130. XMVECTOR        XMVectorPowEst(FXMVECTOR V1, FXMVECTOR V2);
  2131. XMVECTOR        XMVectorPow(FXMVECTOR V1, FXMVECTOR V2);
  2132. XMVECTOR        XMVectorAbs(FXMVECTOR V);
  2133. XMVECTOR        XMVectorMod(FXMVECTOR V1, FXMVECTOR V2);
  2134. XMVECTOR        XMVectorModAngles(FXMVECTOR Angles);
  2135. XMVECTOR        XMVectorSin(FXMVECTOR V);
  2136. XMVECTOR        XMVectorSinEst(FXMVECTOR V);
  2137. XMVECTOR        XMVectorCos(FXMVECTOR V);
  2138. XMVECTOR        XMVectorCosEst(FXMVECTOR V);
  2139. VOID            XMVectorSinCos(__out XMVECTOR* pSin, __out XMVECTOR* pCos, FXMVECTOR V);
  2140. VOID            XMVectorSinCosEst(__out XMVECTOR* pSin, __out XMVECTOR* pCos, FXMVECTOR V);
  2141. XMVECTOR        XMVectorTan(FXMVECTOR V);
  2142. XMVECTOR        XMVectorTanEst(FXMVECTOR V);
  2143. XMVECTOR        XMVectorSinH(FXMVECTOR V);
  2144. XMVECTOR        XMVectorSinHEst(FXMVECTOR V);
  2145. XMVECTOR        XMVectorCosH(FXMVECTOR V);
  2146. XMVECTOR        XMVectorCosHEst(FXMVECTOR V);
  2147. XMVECTOR        XMVectorTanH(FXMVECTOR V);
  2148. XMVECTOR        XMVectorTanHEst(FXMVECTOR V);
  2149. XMVECTOR        XMVectorASin(FXMVECTOR V);
  2150. XMVECTOR        XMVectorASinEst(FXMVECTOR V);
  2151. XMVECTOR        XMVectorACos(FXMVECTOR V);
  2152. XMVECTOR        XMVectorACosEst(FXMVECTOR V);
  2153. XMVECTOR        XMVectorATan(FXMVECTOR V);
  2154. XMVECTOR        XMVectorATanEst(FXMVECTOR V);
  2155. XMVECTOR        XMVectorATan2(FXMVECTOR Y, FXMVECTOR X);
  2156. XMVECTOR        XMVectorATan2Est(FXMVECTOR Y, FXMVECTOR X);
  2157. XMVECTOR        XMVectorLerp(FXMVECTOR V0, FXMVECTOR V1, FLOAT t);
  2158. XMVECTOR        XMVectorLerpV(FXMVECTOR V0, FXMVECTOR V1, FXMVECTOR T);
  2159. XMVECTOR        XMVectorHermite(FXMVECTOR Position0, FXMVECTOR Tangent0, FXMVECTOR Position1, CXMVECTOR Tangent1, FLOAT t);
  2160. XMVECTOR        XMVectorHermiteV(FXMVECTOR Position0, FXMVECTOR Tangent0, FXMVECTOR Position1, CXMVECTOR Tangent1, CXMVECTOR T);
  2161. XMVECTOR        XMVectorCatmullRom(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, CXMVECTOR Position3, FLOAT t);
  2162. XMVECTOR        XMVectorCatmullRomV(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, CXMVECTOR Position3, CXMVECTOR T);
  2163. XMVECTOR        XMVectorBaryCentric(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, FLOAT f, FLOAT g);
  2164. XMVECTOR        XMVectorBaryCentricV(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, CXMVECTOR F, CXMVECTOR G);
  2165.  
  2166. /****************************************************************************
  2167.  *
  2168.  * 2D vector operations
  2169.  *
  2170.  ****************************************************************************/
  2171.  
  2172.  
  2173. BOOL            XMVector2Equal(FXMVECTOR V1, FXMVECTOR V2);
  2174. UINT            XMVector2EqualR(FXMVECTOR V1, FXMVECTOR V2);
  2175. BOOL            XMVector2EqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2176. UINT            XMVector2EqualIntR(FXMVECTOR V1, FXMVECTOR V2);
  2177. BOOL            XMVector2NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
  2178. BOOL            XMVector2NotEqual(FXMVECTOR V1, FXMVECTOR V2);
  2179. BOOL            XMVector2NotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2180. BOOL            XMVector2Greater(FXMVECTOR V1, FXMVECTOR V2);
  2181. UINT            XMVector2GreaterR(FXMVECTOR V1, FXMVECTOR V2);
  2182. BOOL            XMVector2GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2183. UINT            XMVector2GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2);
  2184. BOOL            XMVector2Less(FXMVECTOR V1, FXMVECTOR V2);
  2185. BOOL            XMVector2LessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2186. BOOL            XMVector2InBounds(FXMVECTOR V, FXMVECTOR Bounds);
  2187. UINT            XMVector2InBoundsR(FXMVECTOR V, FXMVECTOR Bounds);
  2188.  
  2189. BOOL            XMVector2IsNaN(FXMVECTOR V);
  2190. BOOL            XMVector2IsInfinite(FXMVECTOR V);
  2191.  
  2192. XMVECTOR        XMVector2Dot(FXMVECTOR V1, FXMVECTOR V2);
  2193. XMVECTOR        XMVector2Cross(FXMVECTOR V1, FXMVECTOR V2);
  2194. XMVECTOR        XMVector2LengthSq(FXMVECTOR V);
  2195. XMVECTOR        XMVector2ReciprocalLengthEst(FXMVECTOR V);
  2196. XMVECTOR        XMVector2ReciprocalLength(FXMVECTOR V);
  2197. XMVECTOR        XMVector2LengthEst(FXMVECTOR V);
  2198. XMVECTOR        XMVector2Length(FXMVECTOR V);
  2199. XMVECTOR        XMVector2NormalizeEst(FXMVECTOR V);
  2200. XMVECTOR        XMVector2Normalize(FXMVECTOR V);
  2201. XMVECTOR        XMVector2ClampLength(FXMVECTOR V, FLOAT LengthMin, FLOAT LengthMax);
  2202. XMVECTOR        XMVector2ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax);
  2203. XMVECTOR        XMVector2Reflect(FXMVECTOR Incident, FXMVECTOR Normal);
  2204. XMVECTOR        XMVector2Refract(FXMVECTOR Incident, FXMVECTOR Normal, FLOAT RefractionIndex);
  2205. XMVECTOR        XMVector2RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex);
  2206. XMVECTOR        XMVector2Orthogonal(FXMVECTOR V);
  2207. XMVECTOR        XMVector2AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2);
  2208. XMVECTOR        XMVector2AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2);
  2209. XMVECTOR        XMVector2AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2);
  2210. XMVECTOR        XMVector2LinePointDistance(FXMVECTOR LinePoint1, FXMVECTOR LinePoint2, FXMVECTOR Point);
  2211. XMVECTOR        XMVector2IntersectLine(FXMVECTOR Line1Point1, FXMVECTOR Line1Point2, FXMVECTOR Line2Point1, CXMVECTOR Line2Point2);
  2212. XMVECTOR        XMVector2Transform(FXMVECTOR V, CXMMATRIX M);
  2213. XMFLOAT4*       XMVector2TransformStream(__out_bcount(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
  2214.                                          __in UINT OutputStride,
  2215.                                          __in_bcount(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) CONST XMFLOAT2* pInputStream,
  2216.                                          __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2217. XMFLOAT4*       XMVector2TransformStreamNC(__out_bcount(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
  2218.                                            __in UINT OutputStride,
  2219.                                            __in_bcount(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) CONST XMFLOAT2* pInputStream,
  2220.                                            __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2221. XMVECTOR        XMVector2TransformCoord(FXMVECTOR V, CXMMATRIX M);
  2222. XMFLOAT2*       XMVector2TransformCoordStream(__out_bcount(sizeof(XMFLOAT2)+OutputStride*(VectorCount-1)) XMFLOAT2* pOutputStream,
  2223.                                               __in UINT OutputStride,
  2224.                                               __in_bcount(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) CONST XMFLOAT2* pInputStream,
  2225.                                               __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2226. XMVECTOR        XMVector2TransformNormal(FXMVECTOR V, CXMMATRIX M);
  2227. XMFLOAT2*       XMVector2TransformNormalStream(__out_bcount(sizeof(XMFLOAT2)+OutputStride*(VectorCount-1)) XMFLOAT2* pOutputStream,
  2228.                                                __in UINT OutputStride,
  2229.                                                __in_bcount(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) CONST XMFLOAT2* pInputStream,
  2230.                                                __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2231.  
  2232. /****************************************************************************
  2233.  *
  2234.  * 3D vector operations
  2235.  *
  2236.  ****************************************************************************/
  2237.  
  2238.  
  2239. BOOL            XMVector3Equal(FXMVECTOR V1, FXMVECTOR V2);
  2240. UINT            XMVector3EqualR(FXMVECTOR V1, FXMVECTOR V2);
  2241. BOOL            XMVector3EqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2242. UINT            XMVector3EqualIntR(FXMVECTOR V1, FXMVECTOR V2);
  2243. BOOL            XMVector3NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
  2244. BOOL            XMVector3NotEqual(FXMVECTOR V1, FXMVECTOR V2);
  2245. BOOL            XMVector3NotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2246. BOOL            XMVector3Greater(FXMVECTOR V1, FXMVECTOR V2);
  2247. UINT            XMVector3GreaterR(FXMVECTOR V1, FXMVECTOR V2);
  2248. BOOL            XMVector3GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2249. UINT            XMVector3GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2);
  2250. BOOL            XMVector3Less(FXMVECTOR V1, FXMVECTOR V2);
  2251. BOOL            XMVector3LessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2252. BOOL            XMVector3InBounds(FXMVECTOR V, FXMVECTOR Bounds);
  2253. UINT            XMVector3InBoundsR(FXMVECTOR V, FXMVECTOR Bounds);
  2254.  
  2255. BOOL            XMVector3IsNaN(FXMVECTOR V);
  2256. BOOL            XMVector3IsInfinite(FXMVECTOR V);
  2257.  
  2258. XMVECTOR        XMVector3Dot(FXMVECTOR V1, FXMVECTOR V2);
  2259. XMVECTOR        XMVector3Cross(FXMVECTOR V1, FXMVECTOR V2);
  2260. XMVECTOR        XMVector3LengthSq(FXMVECTOR V);
  2261. XMVECTOR        XMVector3ReciprocalLengthEst(FXMVECTOR V);
  2262. XMVECTOR        XMVector3ReciprocalLength(FXMVECTOR V);
  2263. XMVECTOR        XMVector3LengthEst(FXMVECTOR V);
  2264. XMVECTOR        XMVector3Length(FXMVECTOR V);
  2265. XMVECTOR        XMVector3NormalizeEst(FXMVECTOR V);
  2266. XMVECTOR        XMVector3Normalize(FXMVECTOR V);
  2267. XMVECTOR        XMVector3ClampLength(FXMVECTOR V, FLOAT LengthMin, FLOAT LengthMax);
  2268. XMVECTOR        XMVector3ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax);
  2269. XMVECTOR        XMVector3Reflect(FXMVECTOR Incident, FXMVECTOR Normal);
  2270. XMVECTOR        XMVector3Refract(FXMVECTOR Incident, FXMVECTOR Normal, FLOAT RefractionIndex);
  2271. XMVECTOR        XMVector3RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex);
  2272. XMVECTOR        XMVector3Orthogonal(FXMVECTOR V);
  2273. XMVECTOR        XMVector3AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2);
  2274. XMVECTOR        XMVector3AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2);
  2275. XMVECTOR        XMVector3AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2);
  2276. XMVECTOR        XMVector3LinePointDistance(FXMVECTOR LinePoint1, FXMVECTOR LinePoint2, FXMVECTOR Point);
  2277. VOID            XMVector3ComponentsFromNormal(__out XMVECTOR* pParallel, __out XMVECTOR* pPerpendicular, FXMVECTOR V, FXMVECTOR Normal);
  2278. XMVECTOR        XMVector3Rotate(FXMVECTOR V, FXMVECTOR RotationQuaternion);
  2279. XMVECTOR        XMVector3InverseRotate(FXMVECTOR V, FXMVECTOR RotationQuaternion);
  2280. XMVECTOR        XMVector3Transform(FXMVECTOR V, CXMMATRIX M);
  2281. XMFLOAT4*       XMVector3TransformStream(__out_bcount(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
  2282.                                          __in UINT OutputStride,
  2283.                                          __in_bcount(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) CONST XMFLOAT3* pInputStream,
  2284.                                          __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2285. XMFLOAT4*       XMVector3TransformStreamNC(__out_bcount(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
  2286.                                            __in UINT OutputStride,
  2287.                                            __in_bcount(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) CONST XMFLOAT3* pInputStream,
  2288.                                            __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2289. XMVECTOR        XMVector3TransformCoord(FXMVECTOR V, CXMMATRIX M);
  2290. XMFLOAT3*       XMVector3TransformCoordStream(__out_bcount(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
  2291.                                               __in UINT OutputStride,
  2292.                                               __in_bcount(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) CONST XMFLOAT3* pInputStream,
  2293.                                               __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2294. XMVECTOR        XMVector3TransformNormal(FXMVECTOR V, CXMMATRIX M);
  2295. XMFLOAT3*       XMVector3TransformNormalStream(__out_bcount(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
  2296.                                                __in UINT OutputStride,
  2297.                                                __in_bcount(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) CONST XMFLOAT3* pInputStream,
  2298.                                                __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2299. XMVECTOR        XMVector3Project(FXMVECTOR V, FLOAT ViewportX, FLOAT ViewportY, FLOAT ViewportWidth, FLOAT ViewportHeight, FLOAT ViewportMinZ, FLOAT ViewportMaxZ,
  2300.                     CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World);
  2301. XMFLOAT3*       XMVector3ProjectStream(__out_bcount(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
  2302.                                        __in UINT OutputStride,
  2303.                                        __in_bcount(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) CONST XMFLOAT3* pInputStream,
  2304.                                        __in UINT InputStride, __in UINT VectorCount,
  2305.                     FLOAT ViewportX, FLOAT ViewportY, FLOAT ViewportWidth, FLOAT ViewportHeight, FLOAT ViewportMinZ, FLOAT ViewportMaxZ,
  2306.                     CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World);
  2307. XMVECTOR        XMVector3Unproject(FXMVECTOR V, FLOAT ViewportX, FLOAT ViewportY, FLOAT ViewportWidth, FLOAT ViewportHeight, FLOAT ViewportMinZ, FLOAT ViewportMaxZ,
  2308.                     CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World);
  2309. XMFLOAT3*       XMVector3UnprojectStream(__out_bcount(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream,
  2310.                                          __in UINT OutputStride,
  2311.                                          __in_bcount(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) CONST XMFLOAT3* pInputStream,
  2312.                                          __in UINT InputStride, __in UINT VectorCount,
  2313.                     FLOAT ViewportX, FLOAT ViewportY, FLOAT ViewportWidth, FLOAT ViewportHeight, FLOAT ViewportMinZ, FLOAT ViewportMaxZ,
  2314.                     CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World);
  2315.  
  2316. /****************************************************************************
  2317.  *
  2318.  * 4D vector operations
  2319.  *
  2320.  ****************************************************************************/
  2321.  
  2322. BOOL            XMVector4Equal(FXMVECTOR V1, FXMVECTOR V2);
  2323. UINT            XMVector4EqualR(FXMVECTOR V1, FXMVECTOR V2);
  2324. BOOL            XMVector4EqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2325. UINT            XMVector4EqualIntR(FXMVECTOR V1, FXMVECTOR V2);
  2326. BOOL            XMVector4NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon);
  2327. BOOL            XMVector4NotEqual(FXMVECTOR V1, FXMVECTOR V2);
  2328. BOOL            XMVector4NotEqualInt(FXMVECTOR V1, FXMVECTOR V2);
  2329. BOOL            XMVector4Greater(FXMVECTOR V1, FXMVECTOR V2);
  2330. UINT            XMVector4GreaterR(FXMVECTOR V1, FXMVECTOR V2);
  2331. BOOL            XMVector4GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2332. UINT            XMVector4GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2);
  2333. BOOL            XMVector4Less(FXMVECTOR V1, FXMVECTOR V2);
  2334. BOOL            XMVector4LessOrEqual(FXMVECTOR V1, FXMVECTOR V2);
  2335. BOOL            XMVector4InBounds(FXMVECTOR V, FXMVECTOR Bounds);
  2336. UINT            XMVector4InBoundsR(FXMVECTOR V, FXMVECTOR Bounds);
  2337.  
  2338. BOOL            XMVector4IsNaN(FXMVECTOR V);
  2339. BOOL            XMVector4IsInfinite(FXMVECTOR V);
  2340.  
  2341. XMVECTOR        XMVector4Dot(FXMVECTOR V1, FXMVECTOR V2);
  2342. XMVECTOR        XMVector4Cross(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3);
  2343. XMVECTOR        XMVector4LengthSq(FXMVECTOR V);
  2344. XMVECTOR        XMVector4ReciprocalLengthEst(FXMVECTOR V);
  2345. XMVECTOR        XMVector4ReciprocalLength(FXMVECTOR V);
  2346. XMVECTOR        XMVector4LengthEst(FXMVECTOR V);
  2347. XMVECTOR        XMVector4Length(FXMVECTOR V);
  2348. XMVECTOR        XMVector4NormalizeEst(FXMVECTOR V);
  2349. XMVECTOR        XMVector4Normalize(FXMVECTOR V);
  2350. XMVECTOR        XMVector4ClampLength(FXMVECTOR V, FLOAT LengthMin, FLOAT LengthMax);
  2351. XMVECTOR        XMVector4ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax);
  2352. XMVECTOR        XMVector4Reflect(FXMVECTOR Incident, FXMVECTOR Normal);
  2353. XMVECTOR        XMVector4Refract(FXMVECTOR Incident, FXMVECTOR Normal, FLOAT RefractionIndex);
  2354. XMVECTOR        XMVector4RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex);
  2355. XMVECTOR        XMVector4Orthogonal(FXMVECTOR V);
  2356. XMVECTOR        XMVector4AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2);
  2357. XMVECTOR        XMVector4AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2);
  2358. XMVECTOR        XMVector4AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2);
  2359. XMVECTOR        XMVector4Transform(FXMVECTOR V, CXMMATRIX M);
  2360. XMFLOAT4*       XMVector4TransformStream(__out_bcount(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream,
  2361.                                          __in UINT OutputStride,
  2362.                                          __in_bcount(sizeof(XMFLOAT4)+InputStride*(VectorCount-1)) CONST XMFLOAT4* pInputStream,
  2363.                                          __in UINT InputStride, __in UINT VectorCount, CXMMATRIX M);
  2364.  
  2365. /****************************************************************************
  2366.  *
  2367.  * Matrix operations
  2368.  *
  2369.  ****************************************************************************/
  2370.  
  2371. BOOL            XMMatrixIsNaN(CXMMATRIX M);
  2372. BOOL            XMMatrixIsInfinite(CXMMATRIX M);
  2373. BOOL            XMMatrixIsIdentity(CXMMATRIX M);
  2374.  
  2375. XMMATRIX        XMMatrixMultiply(CXMMATRIX M1, CXMMATRIX M2);
  2376. XMMATRIX        XMMatrixMultiplyTranspose(CXMMATRIX M1, CXMMATRIX M2);
  2377. XMMATRIX        XMMatrixTranspose(CXMMATRIX M);
  2378. XMMATRIX        XMMatrixInverse(__out XMVECTOR* pDeterminant, CXMMATRIX M);
  2379. XMVECTOR        XMMatrixDeterminant(CXMMATRIX M);
  2380. BOOL            XMMatrixDecompose(__out XMVECTOR *outScale, __out XMVECTOR *outRotQuat, __out XMVECTOR *outTrans, CXMMATRIX M);
  2381.  
  2382. XMMATRIX        XMMatrixIdentity();
  2383. XMMATRIX        XMMatrixSet(FLOAT m00, FLOAT m01, FLOAT m02, FLOAT m03,
  2384.                          FLOAT m10, FLOAT m11, FLOAT m12, FLOAT m13,
  2385.                          FLOAT m20, FLOAT m21, FLOAT m22, FLOAT m23,
  2386.                          FLOAT m30, FLOAT m31, FLOAT m32, FLOAT m33);
  2387. XMMATRIX        XMMatrixTranslation(FLOAT OffsetX, FLOAT OffsetY, FLOAT OffsetZ);
  2388. XMMATRIX        XMMatrixTranslationFromVector(FXMVECTOR Offset);
  2389. XMMATRIX        XMMatrixScaling(FLOAT ScaleX, FLOAT ScaleY, FLOAT ScaleZ);
  2390. XMMATRIX        XMMatrixScalingFromVector(FXMVECTOR Scale);
  2391. XMMATRIX        XMMatrixRotationX(FLOAT Angle);
  2392. XMMATRIX        XMMatrixRotationY(FLOAT Angle);
  2393. XMMATRIX        XMMatrixRotationZ(FLOAT Angle);
  2394. XMMATRIX        XMMatrixRotationRollPitchYaw(FLOAT Pitch, FLOAT Yaw, FLOAT Roll);
  2395. XMMATRIX        XMMatrixRotationRollPitchYawFromVector(FXMVECTOR Angles);
  2396. XMMATRIX        XMMatrixRotationNormal(FXMVECTOR NormalAxis, FLOAT Angle);
  2397. XMMATRIX        XMMatrixRotationAxis(FXMVECTOR Axis, FLOAT Angle);
  2398. XMMATRIX        XMMatrixRotationQuaternion(FXMVECTOR Quaternion);
  2399. XMMATRIX        XMMatrixTransformation2D(FXMVECTOR ScalingOrigin, FLOAT ScalingOrientation, FXMVECTOR Scaling,
  2400.                     FXMVECTOR RotationOrigin, FLOAT Rotation, CXMVECTOR Translation);
  2401. XMMATRIX        XMMatrixTransformation(FXMVECTOR ScalingOrigin, FXMVECTOR ScalingOrientationQuaternion, FXMVECTOR Scaling,
  2402.                     CXMVECTOR RotationOrigin, CXMVECTOR RotationQuaternion, CXMVECTOR Translation);
  2403. XMMATRIX        XMMatrixAffineTransformation2D(FXMVECTOR Scaling, FXMVECTOR RotationOrigin, FLOAT Rotation, FXMVECTOR Translation);
  2404. XMMATRIX        XMMatrixAffineTransformation(FXMVECTOR Scaling, FXMVECTOR RotationOrigin, FXMVECTOR RotationQuaternion, CXMVECTOR Translation);
  2405. XMMATRIX        XMMatrixReflect(FXMVECTOR ReflectionPlane);
  2406. XMMATRIX        XMMatrixShadow(FXMVECTOR ShadowPlane, FXMVECTOR LightPosition);
  2407.  
  2408. XMMATRIX        XMMatrixLookAtLH(FXMVECTOR EyePosition, FXMVECTOR FocusPosition, FXMVECTOR UpDirection);
  2409. XMMATRIX        XMMatrixLookAtRH(FXMVECTOR EyePosition, FXMVECTOR FocusPosition, FXMVECTOR UpDirection);
  2410. XMMATRIX        XMMatrixLookToLH(FXMVECTOR EyePosition, FXMVECTOR EyeDirection, FXMVECTOR UpDirection);
  2411. XMMATRIX        XMMatrixLookToRH(FXMVECTOR EyePosition, FXMVECTOR EyeDirection, FXMVECTOR UpDirection);
  2412. XMMATRIX        XMMatrixPerspectiveLH(FLOAT ViewWidth, FLOAT ViewHeight, FLOAT NearZ, FLOAT FarZ);
  2413. XMMATRIX        XMMatrixPerspectiveRH(FLOAT ViewWidth, FLOAT ViewHeight, FLOAT NearZ, FLOAT FarZ);
  2414. XMMATRIX        XMMatrixPerspectiveFovLH(FLOAT FovAngleY, FLOAT AspectHByW, FLOAT NearZ, FLOAT FarZ);
  2415. XMMATRIX        XMMatrixPerspectiveFovRH(FLOAT FovAngleY, FLOAT AspectHByW, FLOAT NearZ, FLOAT FarZ);
  2416. XMMATRIX        XMMatrixPerspectiveOffCenterLH(FLOAT ViewLeft, FLOAT ViewRight, FLOAT ViewBottom, FLOAT ViewTop, FLOAT NearZ, FLOAT FarZ);
  2417. XMMATRIX        XMMatrixPerspectiveOffCenterRH(FLOAT ViewLeft, FLOAT ViewRight, FLOAT ViewBottom, FLOAT ViewTop, FLOAT NearZ, FLOAT FarZ);
  2418. XMMATRIX        XMMatrixOrthographicLH(FLOAT ViewWidth, FLOAT ViewHeight, FLOAT NearZ, FLOAT FarZ);
  2419. XMMATRIX        XMMatrixOrthographicRH(FLOAT ViewWidth, FLOAT ViewHeight, FLOAT NearZ, FLOAT FarZ);
  2420. XMMATRIX        XMMatrixOrthographicOffCenterLH(FLOAT ViewLeft, FLOAT ViewRight, FLOAT ViewBottom, FLOAT ViewTop, FLOAT NearZ, FLOAT FarZ);
  2421. XMMATRIX        XMMatrixOrthographicOffCenterRH(FLOAT ViewLeft, FLOAT ViewRight, FLOAT ViewBottom, FLOAT ViewTop, FLOAT NearZ, FLOAT FarZ);
  2422.  
  2423. /****************************************************************************
  2424.  *
  2425.  * Quaternion operations
  2426.  *
  2427.  ****************************************************************************/
  2428.  
  2429. BOOL            XMQuaternionEqual(FXMVECTOR Q1, FXMVECTOR Q2);
  2430. BOOL            XMQuaternionNotEqual(FXMVECTOR Q1, FXMVECTOR Q2);
  2431.  
  2432. BOOL            XMQuaternionIsNaN(FXMVECTOR Q);
  2433. BOOL            XMQuaternionIsInfinite(FXMVECTOR Q);
  2434. BOOL            XMQuaternionIsIdentity(FXMVECTOR Q);
  2435.  
  2436. XMVECTOR        XMQuaternionDot(FXMVECTOR Q1, FXMVECTOR Q2);
  2437. XMVECTOR        XMQuaternionMultiply(FXMVECTOR Q1, FXMVECTOR Q2);
  2438. XMVECTOR        XMQuaternionLengthSq(FXMVECTOR Q);
  2439. XMVECTOR        XMQuaternionReciprocalLength(FXMVECTOR Q);
  2440. XMVECTOR        XMQuaternionLength(FXMVECTOR Q);
  2441. XMVECTOR        XMQuaternionNormalizeEst(FXMVECTOR Q);
  2442. XMVECTOR        XMQuaternionNormalize(FXMVECTOR Q);
  2443. XMVECTOR        XMQuaternionConjugate(FXMVECTOR Q);
  2444. XMVECTOR        XMQuaternionInverse(FXMVECTOR Q);
  2445. XMVECTOR        XMQuaternionLn(FXMVECTOR Q);
  2446. XMVECTOR        XMQuaternionExp(FXMVECTOR Q);
  2447. XMVECTOR        XMQuaternionSlerp(FXMVECTOR Q0, FXMVECTOR Q1, FLOAT t);
  2448. XMVECTOR        XMQuaternionSlerpV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR T);
  2449. XMVECTOR        XMQuaternionSquad(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, CXMVECTOR Q3, FLOAT t);
  2450. XMVECTOR        XMQuaternionSquadV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, CXMVECTOR Q3, CXMVECTOR T);
  2451. VOID            XMQuaternionSquadSetup(__out XMVECTOR* pA, __out XMVECTOR* pB, __out XMVECTOR* pC, FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, CXMVECTOR Q3);
  2452. XMVECTOR        XMQuaternionBaryCentric(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, FLOAT f, FLOAT g);
  2453. XMVECTOR        XMQuaternionBaryCentricV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, CXMVECTOR F, CXMVECTOR G);
  2454.  
  2455. XMVECTOR        XMQuaternionIdentity();
  2456. XMVECTOR        XMQuaternionRotationRollPitchYaw(FLOAT Pitch, FLOAT Yaw, FLOAT Roll);
  2457. XMVECTOR        XMQuaternionRotationRollPitchYawFromVector(FXMVECTOR Angles);
  2458. XMVECTOR        XMQuaternionRotationNormal(FXMVECTOR NormalAxis, FLOAT Angle);
  2459. XMVECTOR        XMQuaternionRotationAxis(FXMVECTOR Axis, FLOAT Angle);
  2460. XMVECTOR        XMQuaternionRotationMatrix(CXMMATRIX M);
  2461.  
  2462. VOID            XMQuaternionToAxisAngle(__out XMVECTOR* pAxis, __out FLOAT* pAngle, FXMVECTOR Q);
  2463.  
  2464. /****************************************************************************
  2465.  *
  2466.  * Plane operations
  2467.  *
  2468.  ****************************************************************************/
  2469.  
  2470. BOOL            XMPlaneEqual(FXMVECTOR P1, FXMVECTOR P2);
  2471. BOOL            XMPlaneNearEqual(FXMVECTOR P1, FXMVECTOR P2, FXMVECTOR Epsilon);
  2472. BOOL            XMPlaneNotEqual(FXMVECTOR P1, FXMVECTOR P2);
  2473.  
  2474. BOOL            XMPlaneIsNaN(FXMVECTOR P);
  2475. BOOL            XMPlaneIsInfinite(FXMVECTOR P);
  2476.  
  2477. XMVECTOR        XMPlaneDot(FXMVECTOR P, FXMVECTOR V);
  2478. XMVECTOR        XMPlaneDotCoord(FXMVECTOR P, FXMVECTOR V);
  2479. XMVECTOR        XMPlaneDotNormal(FXMVECTOR P, FXMVECTOR V);
  2480. XMVECTOR        XMPlaneNormalizeEst(FXMVECTOR P);
  2481. XMVECTOR        XMPlaneNormalize(FXMVECTOR P);
  2482. XMVECTOR        XMPlaneIntersectLine(FXMVECTOR P, FXMVECTOR LinePoint1, FXMVECTOR LinePoint2);
  2483. VOID            XMPlaneIntersectPlane(__out XMVECTOR* pLinePoint1, __out XMVECTOR* pLinePoint2, FXMVECTOR P1, FXMVECTOR P2);
  2484. XMVECTOR        XMPlaneTransform(FXMVECTOR P, CXMMATRIX M);
  2485. XMFLOAT4*       XMPlaneTransformStream(__out_bcount(sizeof(XMFLOAT4)+OutputStride*(PlaneCount-1)) XMFLOAT4* pOutputStream,
  2486.                                        __in UINT OutputStride,
  2487.                                        __in_bcount(sizeof(XMFLOAT4)+InputStride*(PlaneCount-1)) CONST XMFLOAT4* pInputStream,
  2488.                                        __in UINT InputStride, __in UINT PlaneCount, CXMMATRIX M);
  2489.  
  2490. XMVECTOR        XMPlaneFromPointNormal(FXMVECTOR Point, FXMVECTOR Normal);
  2491. XMVECTOR        XMPlaneFromPoints(FXMVECTOR Point1, FXMVECTOR Point2, FXMVECTOR Point3);
  2492.  
  2493. /****************************************************************************
  2494.  *
  2495.  * Color operations
  2496.  *
  2497.  ****************************************************************************/
  2498.  
  2499. BOOL            XMColorEqual(FXMVECTOR C1, FXMVECTOR C2);
  2500. BOOL            XMColorNotEqual(FXMVECTOR C1, FXMVECTOR C2);
  2501. BOOL            XMColorGreater(FXMVECTOR C1, FXMVECTOR C2);
  2502. BOOL            XMColorGreaterOrEqual(FXMVECTOR C1, FXMVECTOR C2);
  2503. BOOL            XMColorLess(FXMVECTOR C1, FXMVECTOR C2);
  2504. BOOL            XMColorLessOrEqual(FXMVECTOR C1, FXMVECTOR C2);
  2505.  
  2506. BOOL            XMColorIsNaN(FXMVECTOR C);
  2507. BOOL            XMColorIsInfinite(FXMVECTOR C);
  2508.  
  2509. XMVECTOR        XMColorNegative(FXMVECTOR C);
  2510. XMVECTOR        XMColorModulate(FXMVECTOR C1, FXMVECTOR C2);
  2511. XMVECTOR        XMColorAdjustSaturation(FXMVECTOR C, FLOAT Saturation);
  2512. XMVECTOR        XMColorAdjustContrast(FXMVECTOR C, FLOAT Contrast);
  2513.  
  2514. /****************************************************************************
  2515.  *
  2516.  * Miscellaneous operations
  2517.  *
  2518.  ****************************************************************************/
  2519.  
  2520. BOOL            XMVerifyCPUSupport();
  2521.  
  2522. VOID            XMAssert(__in_z CONST CHAR* pExpression, __in_z CONST CHAR* pFileName, UINT LineNumber);
  2523.  
  2524. XMVECTOR        XMFresnelTerm(FXMVECTOR CosIncidentAngle, FXMVECTOR RefractionIndex);
  2525.  
  2526. BOOL            XMScalarNearEqual(FLOAT S1, FLOAT S2, FLOAT Epsilon);
  2527. FLOAT           XMScalarModAngle(FLOAT Value);
  2528. FLOAT           XMScalarSin(FLOAT Value);
  2529. FLOAT           XMScalarCos(FLOAT Value);
  2530. VOID            XMScalarSinCos(__out FLOAT* pSin, __out FLOAT* pCos, FLOAT Value);
  2531. FLOAT           XMScalarASin(FLOAT Value);
  2532. FLOAT           XMScalarACos(FLOAT Value);
  2533. FLOAT           XMScalarSinEst(FLOAT Value);
  2534. FLOAT           XMScalarCosEst(FLOAT Value);
  2535. VOID            XMScalarSinCosEst(__out FLOAT* pSin, __out FLOAT* pCos, FLOAT Value);
  2536. FLOAT           XMScalarASinEst(FLOAT Value);
  2537. FLOAT           XMScalarACosEst(FLOAT Value);
  2538.  
  2539. /****************************************************************************
  2540.  *
  2541.  * Globals
  2542.  *
  2543.  ****************************************************************************/
  2544.  
  2545. // The purpose of the following global constants is to prevent redundant
  2546. // reloading of the constants when they are referenced by more than one
  2547. // separate inline math routine called within the same function.  Declaring
  2548. // a constant locally within a routine is sufficient to prevent redundant
  2549. // reloads of that constant when that single routine is called multiple
  2550. // times in a function, but if the constant is used (and declared) in a
  2551. // separate math routine it would be reloaded.
  2552.  
  2553. #define XMGLOBALCONST extern CONST __declspec(selectany)
  2554.  
  2555. XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients0    = {1.0f, -0.166666667f, 8.333333333e-3f, -1.984126984e-4f};
  2556. XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients1    = {2.755731922e-6f, -2.505210839e-8f, 1.605904384e-10f, -7.647163732e-13f};
  2557. XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients2    = {2.811457254e-15f, -8.220635247e-18f, 1.957294106e-20f, -3.868170171e-23f};
  2558. XMGLOBALCONST XMVECTORF32 g_XMCosCoefficients0    = {1.0f, -0.5f, 4.166666667e-2f, -1.388888889e-3f};
  2559. XMGLOBALCONST XMVECTORF32 g_XMCosCoefficients1    = {2.480158730e-5f, -2.755731922e-7f, 2.087675699e-9f, -1.147074560e-11f};
  2560. XMGLOBALCONST XMVECTORF32 g_XMCosCoefficients2    = {4.779477332e-14f, -1.561920697e-16f, 4.110317623e-19f, -8.896791392e-22f};
  2561. XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients0    = {1.0f, 0.333333333f, 0.133333333f, 5.396825397e-2f};
  2562. XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients1    = {2.186948854e-2f, 8.863235530e-3f, 3.592128167e-3f, 1.455834485e-3f};
  2563. XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients2    = {5.900274264e-4f, 2.391290764e-4f, 9.691537707e-5f, 3.927832950e-5f};
  2564. XMGLOBALCONST XMVECTORF32 g_XMASinCoefficients0   = {-0.05806367563904f, -0.41861972469416f, 0.22480114791621f, 2.17337241360606f};
  2565. XMGLOBALCONST XMVECTORF32 g_XMASinCoefficients1   = {0.61657275907170f, 4.29696498283455f, -1.18942822255452f, -6.53784832094831f};
  2566. XMGLOBALCONST XMVECTORF32 g_XMASinCoefficients2   = {-1.36926553863413f, -4.48179294237210f, 1.41810672941833f, 5.48179257935713f};
  2567. XMGLOBALCONST XMVECTORF32 g_XMATanCoefficients0   = {1.0f, 0.333333334f, 0.2f, 0.142857143f};
  2568. XMGLOBALCONST XMVECTORF32 g_XMATanCoefficients1   = {1.111111111e-1f, 9.090909091e-2f, 7.692307692e-2f, 6.666666667e-2f};
  2569. XMGLOBALCONST XMVECTORF32 g_XMATanCoefficients2   = {5.882352941e-2f, 5.263157895e-2f, 4.761904762e-2f, 4.347826087e-2f};
  2570. XMGLOBALCONST XMVECTORF32 g_XMSinEstCoefficients  = {1.0f, -1.66521856991541e-1f, 8.199913018755e-3f, -1.61475937228e-4f};
  2571. XMGLOBALCONST XMVECTORF32 g_XMCosEstCoefficients  = {1.0f, -4.95348008918096e-1f, 3.878259962881e-2f, -9.24587976263e-4f};
  2572. XMGLOBALCONST XMVECTORF32 g_XMTanEstCoefficients  = {2.484f, -1.954923183e-1f, 2.467401101f, XM_1DIVPI};
  2573. XMGLOBALCONST XMVECTORF32 g_XMATanEstCoefficients = {7.689891418951e-1f, 1.104742493348f, 8.661844266006e-1f, XM_PIDIV2};
  2574. XMGLOBALCONST XMVECTORF32 g_XMASinEstCoefficients = {-1.36178272886711f, 2.37949493464538f, -8.08228565650486e-1f, 2.78440142746736e-1f};
  2575. XMGLOBALCONST XMVECTORF32 g_XMASinEstConstants    = {1.00000011921f, XM_PIDIV2, 0.0f, 0.0f};
  2576. XMGLOBALCONST XMVECTORF32 g_XMPiConstants0        = {XM_PI, XM_2PI, XM_1DIVPI, XM_1DIV2PI};
  2577. XMGLOBALCONST XMVECTORF32 g_XMIdentityR0          = {1.0f, 0.0f, 0.0f, 0.0f};
  2578. XMGLOBALCONST XMVECTORF32 g_XMIdentityR1          = {0.0f, 1.0f, 0.0f, 0.0f};
  2579. XMGLOBALCONST XMVECTORF32 g_XMIdentityR2          = {0.0f, 0.0f, 1.0f, 0.0f};
  2580. XMGLOBALCONST XMVECTORF32 g_XMIdentityR3          = {0.0f, 0.0f, 0.0f, 1.0f};
  2581. XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR0       = {-1.0f,0.0f, 0.0f, 0.0f};
  2582. XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR1       = {0.0f,-1.0f, 0.0f, 0.0f};
  2583. XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR2       = {0.0f, 0.0f,-1.0f, 0.0f};
  2584. XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR3       = {0.0f, 0.0f, 0.0f,-1.0f};
  2585.  
  2586. #if defined(_XM_NO_INTRINSICS_) || defined(_XM_SSE_INTRINSICS_)
  2587.  
  2588. XMGLOBALCONST XMVECTORI32 g_XMNegativeZero      = {0x80000000, 0x80000000, 0x80000000, 0x80000000};
  2589. XMGLOBALCONST XMVECTORI32 g_XMNegate3           = {0x80000000, 0x80000000, 0x80000000, 0x00000000};
  2590. XMGLOBALCONST XMVECTORI32 g_XMMask3             = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000};
  2591. XMGLOBALCONST XMVECTORI32 g_XMMaskX             = {0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000};
  2592. XMGLOBALCONST XMVECTORI32 g_XMMaskY             = {0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000};
  2593. XMGLOBALCONST XMVECTORI32 g_XMMaskZ             = {0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000};
  2594. XMGLOBALCONST XMVECTORI32 g_XMMaskW             = {0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF};
  2595. XMGLOBALCONST XMVECTORF32 g_XMOne               = { 1.0f, 1.0f, 1.0f, 1.0f};
  2596. XMGLOBALCONST XMVECTORF32 g_XMOne3              = { 1.0f, 1.0f, 1.0f, 0.0f};
  2597. XMGLOBALCONST XMVECTORF32 g_XMZero              = { 0.0f, 0.0f, 0.0f, 0.0f};
  2598. XMGLOBALCONST XMVECTORF32 g_XMNegativeOne       = {-1.0f,-1.0f,-1.0f,-1.0f};
  2599. XMGLOBALCONST XMVECTORF32 g_XMOneHalf           = { 0.5f, 0.5f, 0.5f, 0.5f};
  2600. XMGLOBALCONST XMVECTORF32 g_XMNegativeOneHalf   = {-0.5f,-0.5f,-0.5f,-0.5f};
  2601. XMGLOBALCONST XMVECTORF32 g_XMNegativeTwoPi     = {-XM_2PI, -XM_2PI, -XM_2PI, -XM_2PI};
  2602. XMGLOBALCONST XMVECTORF32 g_XMNegativePi        = {-XM_PI, -XM_PI, -XM_PI, -XM_PI};
  2603. XMGLOBALCONST XMVECTORF32 g_XMHalfPi            = {XM_PIDIV2, XM_PIDIV2, XM_PIDIV2, XM_PIDIV2};
  2604. XMGLOBALCONST XMVECTORF32 g_XMPi                = {XM_PI, XM_PI, XM_PI, XM_PI};
  2605. XMGLOBALCONST XMVECTORF32 g_XMReciprocalPi      = {XM_1DIVPI, XM_1DIVPI, XM_1DIVPI, XM_1DIVPI};
  2606. XMGLOBALCONST XMVECTORF32 g_XMTwoPi             = {XM_2PI, XM_2PI, XM_2PI, XM_2PI};
  2607. XMGLOBALCONST XMVECTORF32 g_XMReciprocalTwoPi   = {XM_1DIV2PI, XM_1DIV2PI, XM_1DIV2PI, XM_1DIV2PI};
  2608. XMGLOBALCONST XMVECTORF32 g_XMEpsilon           = {1.192092896e-7f, 1.192092896e-7f, 1.192092896e-7f, 1.192092896e-7f};
  2609. XMGLOBALCONST XMVECTORI32 g_XMInfinity          = {0x7F800000, 0x7F800000, 0x7F800000, 0x7F800000};
  2610. XMGLOBALCONST XMVECTORI32 g_XMQNaN              = {0x7FC00000, 0x7FC00000, 0x7FC00000, 0x7FC00000};
  2611. XMGLOBALCONST XMVECTORI32 g_XMQNaNTest          = {0x007FFFFF, 0x007FFFFF, 0x007FFFFF, 0x007FFFFF};
  2612. XMGLOBALCONST XMVECTORI32 g_XMAbsMask           = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
  2613. XMGLOBALCONST XMVECTORI32 g_XMFltMin            = {0x00800000, 0x00800000, 0x00800000, 0x00800000};
  2614. XMGLOBALCONST XMVECTORI32 g_XMFltMax            = {0x7F7FFFFF, 0x7F7FFFFF, 0x7F7FFFFF, 0x7F7FFFFF};
  2615. XMGLOBALCONST XMVECTORI32 g_XMNegOneMask                = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
  2616. XMGLOBALCONST XMVECTORI32 g_XMMaskA8R8G8B8      = {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000};
  2617. XMGLOBALCONST XMVECTORI32 g_XMFlipA8R8G8B8      = {0x00000000, 0x00000000, 0x00000000, 0x80000000};
  2618. XMGLOBALCONST XMVECTORF32 g_XMFixAA8R8G8B8      = {0.0f,0.0f,0.0f,(float)(0x80000000U)};
  2619. 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))};
  2620. XMGLOBALCONST XMVECTORI32 g_XMMaskA2B10G10R10   = {0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000};
  2621. XMGLOBALCONST XMVECTORI32 g_XMFlipA2B10G10R10   = {0x00000200, 0x00080000, 0x20000000, 0x80000000};
  2622. XMGLOBALCONST XMVECTORF32 g_XMFixAA2B10G10R10   = {-512.0f,-512.0f*(float)(0x400),-512.0f*(float)(0x100000),(float)(0x80000000U)};
  2623. 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))};
  2624. XMGLOBALCONST XMVECTORI32 g_XMMaskX16Y16        = {0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000};
  2625. XMGLOBALCONST XMVECTORI32 g_XMFlipX16Y16        = {0x00008000, 0x00000000, 0x00000000, 0x00000000};
  2626. XMGLOBALCONST XMVECTORF32 g_XMFixX16Y16         = {-32768.0f,0.0f,0.0f,0.0f};
  2627. XMGLOBALCONST XMVECTORF32 g_XMNormalizeX16Y16   = {1.0f/32767.0f,1.0f/(32767.0f*65536.0f),0.0f,0.0f};
  2628. XMGLOBALCONST XMVECTORI32 g_XMMaskX16Y16Z16W16  = {0x0000FFFF, 0x0000FFFF, 0xFFFF0000, 0xFFFF0000};
  2629. XMGLOBALCONST XMVECTORI32 g_XMFlipX16Y16Z16W16  = {0x00008000, 0x00008000, 0x00000000, 0x00000000};
  2630. XMGLOBALCONST XMVECTORF32 g_XMFixX16Y16Z16W16   = {-32768.0f,-32768.0f,0.0f,0.0f};
  2631. XMGLOBALCONST XMVECTORF32 g_XMNormalizeX16Y16Z16W16 = {1.0f/32767.0f,1.0f/32767.0f,1.0f/(32767.0f*65536.0f),1.0f/(32767.0f*65536.0f)};
  2632. XMGLOBALCONST XMVECTORF32 g_XMNoFraction        = {8388608.0f,8388608.0f,8388608.0f,8388608.0f};
  2633. XMGLOBALCONST XMVECTORI32 g_XMMaskByte          = {0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF};
  2634. XMGLOBALCONST XMVECTORF32 g_XMNegateX           = {-1.0f, 1.0f, 1.0f, 1.0f};
  2635. XMGLOBALCONST XMVECTORF32 g_XMNegateY           = { 1.0f,-1.0f, 1.0f, 1.0f};
  2636. XMGLOBALCONST XMVECTORF32 g_XMNegateZ           = { 1.0f, 1.0f,-1.0f, 1.0f};
  2637. XMGLOBALCONST XMVECTORF32 g_XMNegateW           = { 1.0f, 1.0f, 1.0f,-1.0f};
  2638. XMGLOBALCONST XMVECTORI32 g_XMSelect0101        = {XM_SELECT_0, XM_SELECT_1, XM_SELECT_0, XM_SELECT_1};
  2639. XMGLOBALCONST XMVECTORI32 g_XMSelect1010        = {XM_SELECT_1, XM_SELECT_0, XM_SELECT_1, XM_SELECT_0};
  2640. XMGLOBALCONST XMVECTORI32 g_XMOneHalfMinusEpsilon = { 0x3EFFFFFD, 0x3EFFFFFD, 0x3EFFFFFD, 0x3EFFFFFD};
  2641.  
  2642. #ifdef _XM_NO_INTRINSICS_
  2643. XMGLOBALCONST XMVECTORI32 g_XMSelect1000        = {XM_SELECT_1, XM_SELECT_0, XM_SELECT_0, XM_SELECT_0};
  2644. XMGLOBALCONST XMVECTORI32 g_XMSelect1100        = {XM_SELECT_1, XM_SELECT_1, XM_SELECT_0, XM_SELECT_0};
  2645. XMGLOBALCONST XMVECTORI32 g_XMSelect1110        = {XM_SELECT_1, XM_SELECT_1, XM_SELECT_1, XM_SELECT_0};
  2646. XMGLOBALCONST XMVECTORI32 g_XMSwizzleXYXY       = {XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0X, XM_PERMUTE_0Y};
  2647. XMGLOBALCONST XMVECTORI32 g_XMSwizzleXYZX       = {XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0Z, XM_PERMUTE_0X};
  2648. XMGLOBALCONST XMVECTORI32 g_XMSwizzleYXZW       = {XM_PERMUTE_0Y, XM_PERMUTE_0X, XM_PERMUTE_0Z, XM_PERMUTE_0W};
  2649. XMGLOBALCONST XMVECTORI32 g_XMSwizzleYZXW       = {XM_PERMUTE_0Y, XM_PERMUTE_0Z, XM_PERMUTE_0X, XM_PERMUTE_0W};
  2650. XMGLOBALCONST XMVECTORI32 g_XMSwizzleZXYW       = {XM_PERMUTE_0Z, XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0W};
  2651. XMGLOBALCONST XMVECTORI32 g_XMPermute0X0Y1X1Y   = {XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_1X, XM_PERMUTE_1Y};
  2652. XMGLOBALCONST XMVECTORI32 g_XMPermute0Z0W1Z1W   = {XM_PERMUTE_0Z, XM_PERMUTE_0W, XM_PERMUTE_1Z, XM_PERMUTE_1W};
  2653. #endif // !_XM_NO_INTRINSICS_
  2654.  
  2655. #ifdef _XM_SSE_INTRINSICS_
  2656. XMGLOBALCONST XMVECTORF32 g_XMFixupY16          = {1.0f,1.0f/65536.0f,0.0f,0.0f};
  2657. XMGLOBALCONST XMVECTORF32 g_XMFixupY16W16       = {1.0f,1.0f,1.0f/65536.0f,1.0f/65536.0f};
  2658. XMGLOBALCONST XMVECTORI32 g_XMFlipY             = {0,0x80000000,0,0};
  2659. XMGLOBALCONST XMVECTORI32 g_XMFlipZ             = {0,0,0x80000000,0};
  2660. XMGLOBALCONST XMVECTORI32 g_XMFlipW             = {0,0,0,0x80000000};
  2661. XMGLOBALCONST XMVECTORI32 g_XMFlipYZ            = {0,0x80000000,0x80000000,0};
  2662. XMGLOBALCONST XMVECTORI32 g_XMFlipZW            = {0,0,0x80000000,0x80000000};
  2663. XMGLOBALCONST XMVECTORI32 g_XMFlipYW            = {0,0x80000000,0,0x80000000};
  2664. XMGLOBALCONST XMVECTORI32 g_XMMaskHenD3         = {0x7FF,0x7ff<<11,0x3FF<<22,0};
  2665. XMGLOBALCONST XMVECTORI32 g_XMMaskDHen3         = {0x3FF,0x7ff<<10,0x7FF<<21,0};
  2666. XMGLOBALCONST XMVECTORF32 g_XMAddUHenD3         = {0,0,32768.0f*65536.0f,0};
  2667. XMGLOBALCONST XMVECTORF32 g_XMAddHenD3          = {-1024.0f,-1024.0f*2048.0f,0,0};
  2668. XMGLOBALCONST XMVECTORF32 g_XMAddDHen3          = {-512.0f,-1024.0f*1024.0f,0,0};
  2669. XMGLOBALCONST XMVECTORF32 g_XMMulHenD3          = {1.0f,1.0f/2048.0f,1.0f/(2048.0f*2048.0f),0};
  2670. XMGLOBALCONST XMVECTORF32 g_XMMulDHen3          = {1.0f,1.0f/1024.0f,1.0f/(1024.0f*2048.0f),0};
  2671. XMGLOBALCONST XMVECTORI32 g_XMXorHenD3          = {0x400,0x400<<11,0,0};
  2672. XMGLOBALCONST XMVECTORI32 g_XMXorDHen3          = {0x200,0x400<<10,0,0};
  2673. XMGLOBALCONST XMVECTORI32 g_XMMaskIco4          = {0xFFFFF,0xFFFFF000,0xFFFFF,0xF0000000};
  2674. XMGLOBALCONST XMVECTORI32 g_XMXorXIco4          = {0x80000,0,0x80000,0x80000000};
  2675. XMGLOBALCONST XMVECTORI32 g_XMXorIco4           = {0x80000,0,0x80000,0};
  2676. XMGLOBALCONST XMVECTORF32 g_XMAddXIco4          = {-8.0f*65536.0f,0,-8.0f*65536.0f,32768.0f*65536.0f};
  2677. XMGLOBALCONST XMVECTORF32 g_XMAddUIco4          = {0,32768.0f*65536.0f,0,32768.0f*65536.0f};
  2678. XMGLOBALCONST XMVECTORF32 g_XMAddIco4           = {-8.0f*65536.0f,0,-8.0f*65536.0f,0};
  2679. XMGLOBALCONST XMVECTORF32 g_XMMulIco4           = {1.0f,1.0f/4096.0f,1.0f,1.0f/(4096.0f*65536.0f)};
  2680. XMGLOBALCONST XMVECTORI32 g_XMMaskDec4          = {0x3FF,0x3FF<<10,0x3FF<<20,0x3<<30};
  2681. XMGLOBALCONST XMVECTORI32 g_XMXorDec4           = {0x200,0x200<<10,0x200<<20,0};
  2682. XMGLOBALCONST XMVECTORF32 g_XMAddUDec4          = {0,0,0,32768.0f*65536.0f};
  2683. XMGLOBALCONST XMVECTORF32 g_XMAddDec4           = {-512.0f,-512.0f*1024.0f,-512.0f*1024.0f*1024.0f,0};
  2684. XMGLOBALCONST XMVECTORF32 g_XMMulDec4           = {1.0f,1.0f/1024.0f,1.0f/(1024.0f*1024.0f),1.0f/(1024.0f*1024.0f*1024.0f)};
  2685. XMGLOBALCONST XMVECTORI32 g_XMMaskByte4         = {0xFF,0xFF00,0xFF0000,0xFF000000};
  2686. XMGLOBALCONST XMVECTORI32 g_XMXorByte4          = {0x80,0x8000,0x800000,0x00000000};
  2687. XMGLOBALCONST XMVECTORF32 g_XMAddByte4          = {-128.0f,-128.0f*256.0f,-128.0f*65536.0f,0};
  2688. #endif
  2689.  
  2690. #endif // _XM_NO_INTRINSICS_
  2691.  
  2692. /****************************************************************************
  2693.  *
  2694.  * Implementation
  2695.  *
  2696.  ****************************************************************************/
  2697.  
  2698. #pragma warning(push)
  2699. #pragma warning(disable:4214 4204 4616 6001)
  2700.  
  2701. #if !defined(__cplusplus) && !defined(_XBOX) && defined(_XM_ISVS2005_)
  2702.  
  2703. /* Work around VC 2005 bug where math.h defines logf with a semicolon at the end.
  2704.  * Note this is fixed as of Visual Studio 2005 Service Pack 1
  2705.  */
  2706.  
  2707. #undef logf
  2708. #define logf(x)     ((float)log((double)(x)))
  2709.  
  2710. #endif // !defined(__cplusplus) && !defined(_XBOX) && defined(_XM_ISVS2005_)
  2711.  
  2712. //------------------------------------------------------------------------------
  2713.  
  2714. #if defined(_XM_NO_INTRINSICS_) || defined(_XM_SSE_INTRINSICS_)
  2715.  
  2716. XMFINLINE XMVECTOR XMVectorSetBinaryConstant(UINT C0, UINT C1, UINT C2, UINT C3)
  2717. {
  2718. #if defined(_XM_NO_INTRINSICS_)
  2719.     XMVECTORU32 vResult;
  2720.     vResult.u[0] = (0-(C0&1)) & 0x3F800000;
  2721.     vResult.u[1] = (0-(C1&1)) & 0x3F800000;
  2722.     vResult.u[2] = (0-(C2&1)) & 0x3F800000;
  2723.     vResult.u[3] = (0-(C3&1)) & 0x3F800000;
  2724.     return vResult.v;
  2725. #else // XM_SSE_INTRINSICS_
  2726.     static const XMVECTORU32 g_vMask1 = {1,1,1,1};
  2727.     // Move the parms to a vector
  2728.     __m128i vTemp = _mm_set_epi32(C3,C2,C1,C0);
  2729.     // Mask off the low bits
  2730.     vTemp = _mm_and_si128(vTemp,g_vMask1);
  2731.     // 0xFFFFFFFF on true bits
  2732.     vTemp = _mm_cmpeq_epi32(vTemp,g_vMask1);
  2733.     // 0xFFFFFFFF -> 1.0f, 0x00000000 -> 0.0f
  2734.     vTemp = _mm_and_si128(vTemp,g_XMOne);
  2735.     return reinterpret_cast<const __m128 *>(&vTemp)[0];
  2736. #endif
  2737. }
  2738.  
  2739. //------------------------------------------------------------------------------
  2740.  
  2741. XMFINLINE XMVECTOR XMVectorSplatConstant(INT IntConstant, UINT DivExponent)
  2742. {
  2743. #if defined(_XM_NO_INTRINSICS_)
  2744.     XMASSERT( IntConstant >= -16 && IntConstant <= 15 );
  2745.     XMASSERT(DivExponent<32);
  2746.     {
  2747.     XMVECTORI32 V = { IntConstant, IntConstant, IntConstant, IntConstant };
  2748.     return XMConvertVectorIntToFloat( V.v, DivExponent);
  2749.     }
  2750. #else // XM_SSE_INTRINSICS_
  2751.     XMASSERT( IntConstant >= -16 && IntConstant <= 15 );
  2752.     XMASSERT(DivExponent<32);
  2753.     // Splat the int
  2754.     __m128i vScale = _mm_set1_epi32(IntConstant);
  2755.     // Convert to a float
  2756.     XMVECTOR vResult = _mm_cvtepi32_ps(vScale);
  2757.     // Convert DivExponent into 1.0f/(1<<DivExponent)
  2758.     UINT uScale = 0x3F800000U - (DivExponent << 23);
  2759.     // Splat the scalar value (It's really a float)
  2760.     vScale = _mm_set1_epi32(uScale);
  2761.     // Multiply by the reciprocal (Perform a right shift by DivExponent)
  2762.     vResult = _mm_mul_ps(vResult,reinterpret_cast<const __m128 *>(&vScale)[0]);
  2763.     return vResult;
  2764. #endif
  2765. }
  2766.  
  2767. //------------------------------------------------------------------------------
  2768.  
  2769. XMFINLINE XMVECTOR XMVectorSplatConstantInt(INT IntConstant)
  2770. {
  2771. #if defined(_XM_NO_INTRINSICS_)
  2772.     XMASSERT( IntConstant >= -16 && IntConstant <= 15 );
  2773.     {
  2774.     XMVECTORI32 V = { IntConstant, IntConstant, IntConstant, IntConstant };
  2775.     return V.v;
  2776.     }
  2777. #else // XM_SSE_INTRINSICS_
  2778.     XMASSERT( IntConstant >= -16 && IntConstant <= 15 );
  2779.     __m128i V = _mm_set1_epi32( IntConstant );
  2780.     return reinterpret_cast<__m128 *>(&V)[0];
  2781. #endif
  2782. }
  2783.  
  2784. //------------------------------------------------------------------------------
  2785.  
  2786. XMFINLINE XMVECTOR XMVectorShiftLeft(FXMVECTOR V1, FXMVECTOR V2, UINT Elements)
  2787. {
  2788.     return XMVectorPermute(V1, V2, XMVectorPermuteControl((Elements), ((Elements) + 1), ((Elements) + 2), ((Elements) + 3)));
  2789. }
  2790.  
  2791. //------------------------------------------------------------------------------
  2792.  
  2793. XMFINLINE XMVECTOR XMVectorRotateLeft(FXMVECTOR V, UINT Elements)
  2794. {
  2795. #if defined(_XM_NO_INTRINSICS_)
  2796.     XMASSERT( Elements < 4 );
  2797.     {
  2798.     XMVECTORF32 vResult = { V.vector4_f32[Elements & 3], V.vector4_f32[(Elements + 1) & 3],
  2799.                             V.vector4_f32[(Elements + 2) & 3], V.vector4_f32[(Elements + 3) & 3] };
  2800.     return vResult.v;
  2801.     }
  2802. #else // XM_SSE_INTRINSICS_
  2803.     FLOAT fx = XMVectorGetByIndex(V,(Elements) & 3);
  2804.     FLOAT fy = XMVectorGetByIndex(V,((Elements) + 1) & 3);
  2805.     FLOAT fz = XMVectorGetByIndex(V,((Elements) + 2) & 3);
  2806.     FLOAT fw = XMVectorGetByIndex(V,((Elements) + 3) & 3);
  2807.     return _mm_set_ps( fw, fz, fy, fx );
  2808. #endif
  2809. }
  2810.  
  2811. //------------------------------------------------------------------------------
  2812.  
  2813. XMFINLINE XMVECTOR XMVectorRotateRight(FXMVECTOR V, UINT Elements)
  2814. {
  2815. #if defined(_XM_NO_INTRINSICS_)
  2816.     XMASSERT( Elements < 4 );
  2817.     {
  2818.     XMVECTORF32 vResult = { V.vector4_f32[(4 - (Elements)) & 3], V.vector4_f32[(5 - (Elements)) & 3],
  2819.                             V.vector4_f32[(6 - (Elements)) & 3], V.vector4_f32[(7 - (Elements)) & 3] };
  2820.     return vResult.v;
  2821.     }
  2822. #else // XM_SSE_INTRINSICS_
  2823.     FLOAT fx = XMVectorGetByIndex(V,(4 - (Elements)) & 3);
  2824.     FLOAT fy = XMVectorGetByIndex(V,(5 - (Elements)) & 3);
  2825.     FLOAT fz = XMVectorGetByIndex(V,(6 - (Elements)) & 3);
  2826.     FLOAT fw = XMVectorGetByIndex(V,(7 - (Elements)) & 3);
  2827.     return _mm_set_ps( fw, fz, fy, fx );
  2828. #endif
  2829. }
  2830.  
  2831. //------------------------------------------------------------------------------
  2832.  
  2833. XMFINLINE XMVECTOR XMVectorSwizzle(FXMVECTOR V, UINT E0, UINT E1, UINT E2, UINT E3)
  2834. {
  2835. #if defined(_XM_NO_INTRINSICS_)
  2836.     XMASSERT( (E0 < 4) && (E1 < 4) && (E2 < 4) && (E3 < 4) );
  2837.     {
  2838.     XMVECTORF32 vResult = { V.vector4_f32[E0], V.vector4_f32[E1], V.vector4_f32[E2], V.vector4_f32[E3] };
  2839.     return vResult.v;
  2840.     }
  2841. #else // XM_SSE_INTRINSICS_
  2842.     FLOAT fx = XMVectorGetByIndex(V,E0);
  2843.     FLOAT fy = XMVectorGetByIndex(V,E1);
  2844.     FLOAT fz = XMVectorGetByIndex(V,E2);
  2845.     FLOAT fw = XMVectorGetByIndex(V,E3);
  2846.     return _mm_set_ps( fw, fz, fy, fx );
  2847. #endif
  2848. }
  2849.  
  2850. //------------------------------------------------------------------------------
  2851.  
  2852. XMFINLINE XMVECTOR XMVectorInsert(FXMVECTOR VD, FXMVECTOR VS, UINT VSLeftRotateElements,
  2853.                                   UINT Select0, UINT Select1, UINT Select2, UINT Select3)
  2854. {
  2855.     XMVECTOR Control = XMVectorSelectControl(Select0&1, Select1&1, Select2&1, Select3&1);
  2856.     return XMVectorSelect( VD, XMVectorRotateLeft(VS, VSLeftRotateElements), Control );
  2857. }
  2858.  
  2859. // Implemented for VMX128 intrinsics as #defines aboves
  2860. #endif _XM_NO_INTRINSICS_ || _XM_SSE_INTRINSICS_
  2861.  
  2862. //------------------------------------------------------------------------------
  2863.  
  2864. #include <xnamathconvert.inl>
  2865. #include <xnamathvector.inl>
  2866. #include <xnamathmatrix.inl>
  2867. #include <xnamathmisc.inl>
  2868.  
  2869. #pragma warning(pop)
  2870.  
  2871. #endif // __XNAMATH_H__
  2872.  
  2873.