the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 1861 lines 90 kB view raw
1//------------------------------------------------------------------------------------- 2// DirectXMath.h -- SIMD C++ Math library 3// 4// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 5// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 6// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 7// PARTICULAR PURPOSE. 8// 9// Copyright (c) Microsoft Corporation. All rights reserved. 10//------------------------------------------------------------------------------------- 11 12 13// MGH ------------------- 14#define _XM_BIGENDIAN_ 15#define _XM_NO_INTRINSICS_ 16// ----------------------- 17 18#ifdef _MSC_VER 19#pragma once 20#endif 21 22#ifndef __cplusplus 23#error DirectX Math requires C++ 24#endif 25 26#define DIRECTX_MATH_VERSION 303 27 28#if !defined(_XM_BIGENDIAN_) && !defined(_XM_LITTLEENDIAN_) 29#if defined(_M_AMD64) || defined(_M_IX86) || defined(_M_ARM) 30#define _XM_LITTLEENDIAN_ 31#elif defined(_M_PPCBE) 32#define _XM_BIGENDIAN_ 33#else 34#error DirectX Math does not support this target 35#endif 36#endif // !_XM_BIGENDIAN_ && !_XM_LITTLEENDIAN_ 37 38 39 40#if !defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_SSE_INTRINSICS_) && !defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 41#if defined(_M_IX86) || defined(_M_AMD64) 42#define _XM_SSE_INTRINSICS_ 43#elif defined(_M_PPCBE) 44#define _XM_VMX128_INTRINSICS_ 45#elif defined(_M_ARM) 46#define _XM_ARM_NEON_INTRINSICS_ 47#elif !defined(_XM_NO_INTRINSICS_) 48#error DirectX Math does not support this target 49#endif 50#endif // !_XM_ARM_NEON_INTRINSICS_ && !_XM_SSE_INTRINSICS_ && !_XM_VMX128_INTRINSICS_ && !_XM_NO_INTRINSICS_ 51 52#pragma warning(push) 53#pragma warning(disable:4514 4820 4985) 54#include <cmath> 55#include <float.h> 56// MGH - #include <malloc.h> 57#pragma warning(pop) 58 59 60#if defined(_XM_SSE_INTRINSICS_) 61#ifndef _XM_NO_INTRINSICS_ 62#include <xmmintrin.h> 63#include <emmintrin.h> 64#endif 65#elif defined(_XM_VMX128_INTRINSICS_) 66#error This version of DirectX Math does not support Xbox 360 67#elif defined(_XM_ARM_NEON_INTRINSICS_) 68#ifndef _XM_NO_INTRINSICS_ 69#include <arm_neon.h> 70#endif 71#endif 72 73 74 75#include <DirectX/no_sal2.h> 76#include <assert.h> 77 78 79#pragma warning(push) 80#pragma warning(disable : 4005 4668) 81#include <stdint.h> 82#pragma warning(pop) 83 84 85namespace DirectX 86{ 87 88/**************************************************************************** 89 * 90 * Constant definitions 91 * 92 ****************************************************************************/ 93 94#if defined(__XNAMATH_H__) && defined(XM_PI) 95#undef XM_PI 96#undef XM_2PI 97#undef XM_1DIVPI 98#undef XM_1DIV2PI 99#undef XM_PIDIV2 100#undef XM_PIDIV4 101#undef XM_SELECT_0 102#undef XM_SELECT_1 103#undef XM_PERMUTE_0X 104#undef XM_PERMUTE_0Y 105#undef XM_PERMUTE_0Z 106#undef XM_PERMUTE_0W 107#undef XM_PERMUTE_1X 108#undef XM_PERMUTE_1Y 109#undef XM_PERMUTE_1Z 110#undef XM_PERMUTE_1W 111#undef XM_CRMASK_CR6 112#undef XM_CRMASK_CR6TRUE 113#undef XM_CRMASK_CR6FALSE 114#undef XM_CRMASK_CR6BOUNDS 115#undef XM_CACHE_LINE_SIZE 116#endif 117 118const float XM_PI = 3.141592654f; 119const float XM_2PI = 6.283185307f; 120const float XM_1DIVPI = 0.318309886f; 121const float XM_1DIV2PI = 0.159154943f; 122const float XM_PIDIV2 = 1.570796327f; 123const float XM_PIDIV4 = 0.785398163f; 124 125const uint32_t XM_SELECT_0 = 0x00000000; 126const uint32_t XM_SELECT_1 = 0xFFFFFFFF; 127 128const uint32_t XM_PERMUTE_0X = 0; 129const uint32_t XM_PERMUTE_0Y = 1; 130const uint32_t XM_PERMUTE_0Z = 2; 131const uint32_t XM_PERMUTE_0W = 3; 132const uint32_t XM_PERMUTE_1X = 4; 133const uint32_t XM_PERMUTE_1Y = 5; 134const uint32_t XM_PERMUTE_1Z = 6; 135const uint32_t XM_PERMUTE_1W = 7; 136 137const uint32_t XM_SWIZZLE_X = 0; 138const uint32_t XM_SWIZZLE_Y = 1; 139const uint32_t XM_SWIZZLE_Z = 2; 140const uint32_t XM_SWIZZLE_W = 3; 141 142const uint32_t XM_CRMASK_CR6 = 0x000000F0; 143const uint32_t XM_CRMASK_CR6TRUE = 0x00000080; 144const uint32_t XM_CRMASK_CR6FALSE = 0x00000020; 145const uint32_t XM_CRMASK_CR6BOUNDS = XM_CRMASK_CR6FALSE; 146 147 148 149/**************************************************************************** 150 * 151 * Macros 152 * 153 ****************************************************************************/ 154 155#if defined(__XNAMATH_H__) && defined(XMComparisonAllTrue) 156#undef XMComparisonAllTrue 157#undef XMComparisonAnyTrue 158#undef XMComparisonAllFalse 159#undef XMComparisonAnyFalse 160#undef XMComparisonMixed 161#undef XMComparisonAllInBounds 162#undef XMComparisonAnyOutOfBounds 163#endif 164 165// Unit conversion 166 167inline float XMConvertToRadians(float fDegrees) { return fDegrees * (XM_PI / 180.0f); } 168inline float XMConvertToDegrees(float fRadians) { return fRadians * (180.0f / XM_PI); } 169 170// Condition register evaluation proceeding a recording (R) comparison 171 172inline bool XMComparisonAllTrue(uint32_t CR) { return (((CR) & XM_CRMASK_CR6TRUE) == XM_CRMASK_CR6TRUE); } 173inline bool XMComparisonAnyTrue(uint32_t CR) { return (((CR) & XM_CRMASK_CR6FALSE) != XM_CRMASK_CR6FALSE); } 174inline bool XMComparisonAllFalse(uint32_t CR) { return (((CR) & XM_CRMASK_CR6FALSE) == XM_CRMASK_CR6FALSE); } 175inline bool XMComparisonAnyFalse(uint32_t CR) { return (((CR) & XM_CRMASK_CR6TRUE) != XM_CRMASK_CR6TRUE); } 176inline bool XMComparisonMixed(uint32_t CR) { return (((CR) & XM_CRMASK_CR6) == 0); } 177inline bool XMComparisonAllInBounds(uint32_t CR) { return (((CR) & XM_CRMASK_CR6BOUNDS) == XM_CRMASK_CR6BOUNDS); } 178inline bool XMComparisonAnyOutOfBounds(uint32_t CR) { return (((CR) & XM_CRMASK_CR6BOUNDS) != XM_CRMASK_CR6BOUNDS); } 179 180 181/**************************************************************************** 182 * 183 * Data types 184 * 185 ****************************************************************************/ 186 187#pragma warning(push) 188#pragma warning(disable:4068 4201 4365 4324 4820) 189 190#pragma prefast(push) 191#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes") 192 193#ifdef _XM_BIGENDIAN_ 194#pragma bitfield_order(push) 195#pragma bitfield_order(lsb_to_msb) 196#endif 197 198//------------------------------------------------------------------------------ 199#if defined(_XM_NO_INTRINSICS_) && !defined(_M_PPCBE) 200// The __vector4 structure is an intrinsic on Xbox but must be separately defined 201// for x86/x64 202struct __vector4 203{ 204 union 205 { 206 float vector4_f32[4]; 207 uint32_t vector4_u32[4]; 208 // MGH - added to match 360 version 209//---------------------- 210struct 211 { 212 float x; 213 float y; 214 float z; 215 float w; 216 }; 217 float v[4]; 218 uint32_t u[4]; 219//---------------------- 220 221 }; 222}; 223#endif // _XM_NO_INTRINSICS_ 224 225//------------------------------------------------------------------------------ 226#if (defined (_M_IX86) || defined(_M_AMD64) || defined(_M_ARM)) && defined(_XM_NO_INTRINSICS_) 227typedef uint32_t __vector4i[4]; 228#else 229typedef __declspec(align(16)) uint32_t __vector4i[4]; 230#endif 231 232//------------------------------------------------------------------------------ 233// Vector intrinsic: Four 32 bit floating point components aligned on a 16 byte 234// boundary and mapped to hardware vector registers 235#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 236typedef __m128 XMVECTOR; 237#elif defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 238typedef __n128 XMVECTOR; 239#else 240typedef __vector4 XMVECTOR; 241#endif 242 243// Fix-up for (1st-3rd) XMVECTOR parameters that are pass-in-register for x86, ARM, and Xbox 360; by reference otherwise 244#if ( defined(_M_IX86) || defined(_M_ARM) || defined(_XM_VMX128_INTRINSICS_) ) && !defined(_XM_NO_INTRINSICS_) 245typedef const XMVECTOR FXMVECTOR; 246#else 247typedef const XMVECTOR& FXMVECTOR; 248#endif 249 250// Fix-up for (4th) XMVECTOR parameter to pass in-register for ARM and Xbox 360; by reference otherwise 251#if ( defined(_M_ARM) || defined(_XM_VMX128_INTRINSICS_) ) && !defined(_XM_NO_INTRINSICS_) 252typedef const XMVECTOR GXMVECTOR; 253#else 254typedef const XMVECTOR& GXMVECTOR; 255#endif 256 257// Fix-up for (5th+) XMVECTOR parameters to pass in-register for Xbox 360 and by reference otherwise 258#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 259typedef const XMVECTOR CXMVECTOR; 260#else 261typedef const XMVECTOR& CXMVECTOR; 262#endif 263 264//------------------------------------------------------------------------------ 265// Conversion types for constants 266__declspec(align(16)) struct XMVECTORF32 267{ 268 union 269 { 270 float f[4]; 271 XMVECTOR v; 272 }; 273 274 inline operator XMVECTOR() const { return v; } 275 inline operator const float*() const { return f; } 276#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_) 277 inline operator __m128i() const { return _mm_castps_si128(v); } 278 inline operator __m128d() const { return _mm_castps_pd(v); } 279#endif 280}; 281 282__declspec(align(16)) struct XMVECTORI32 283{ 284 union 285 { 286 int32_t i[4]; 287 XMVECTOR v; 288 }; 289 290 inline operator XMVECTOR() const { return v; } 291#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_) 292 inline operator __m128i() const { return _mm_castps_si128(v); } 293 inline operator __m128d() const { return _mm_castps_pd(v); } 294#endif 295}; 296 297__declspec(align(16)) struct XMVECTORU8 298{ 299 union 300 { 301 uint8_t u[16]; 302 XMVECTOR v; 303 }; 304 305 inline operator XMVECTOR() const { return v; } 306#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_) 307 inline operator __m128i() const { return _mm_castps_si128(v); } 308 inline operator __m128d() const { return _mm_castps_pd(v); } 309#endif 310}; 311 312__declspec(align(16)) struct XMVECTORU32 313{ 314 union 315 { 316 uint32_t u[4]; 317 XMVECTOR v; 318 }; 319 320 inline operator XMVECTOR() const { return v; } 321#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_) 322 inline operator __m128i() const { return _mm_castps_si128(v); } 323 inline operator __m128d() const { return _mm_castps_pd(v); } 324#endif 325}; 326 327//------------------------------------------------------------------------------ 328// Vector operators 329XMVECTOR operator+ (FXMVECTOR V); 330XMVECTOR operator- (FXMVECTOR V); 331 332XMVECTOR& operator+= (XMVECTOR& V1, FXMVECTOR V2); 333XMVECTOR& operator-= (XMVECTOR& V1, FXMVECTOR V2); 334XMVECTOR& operator*= (XMVECTOR& V1, FXMVECTOR V2); 335XMVECTOR& operator/= (XMVECTOR& V1, FXMVECTOR V2); 336XMVECTOR& operator*= (XMVECTOR& V, float S); 337XMVECTOR& operator/= (XMVECTOR& V, float S); 338 339XMVECTOR operator+ (FXMVECTOR V1, FXMVECTOR V2); 340XMVECTOR operator- (FXMVECTOR V1, FXMVECTOR V2); 341XMVECTOR operator* (FXMVECTOR V1, FXMVECTOR V2); 342XMVECTOR operator/ (FXMVECTOR V1, FXMVECTOR V2); 343XMVECTOR operator* (FXMVECTOR V, float S); 344XMVECTOR operator* (float S, FXMVECTOR V); 345XMVECTOR operator/ (FXMVECTOR V, float S); 346 347//------------------------------------------------------------------------------ 348// Matrix type: Sixteen 32 bit floating point components aligned on a 349// 16 byte boundary and mapped to four hardware vector registers 350 351struct XMMATRIX; 352 353// Fix-up for XMMATRIX parameters to pass in-register on Xbox 360, by reference otherwise 354#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 355typedef const XMMATRIX CXMMATRIX; 356#else 357typedef const XMMATRIX& CXMMATRIX; 358#endif 359 360#if (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM)) && defined(_XM_NO_INTRINSICS_) 361struct XMMATRIX 362#else 363__declspec(align(16)) struct XMMATRIX 364#endif 365{ 366#ifdef _XM_NO_INTRINSICS_ 367 union 368 { 369 XMVECTOR r[4]; 370 struct 371 { 372 float _11, _12, _13, _14; 373 float _21, _22, _23, _24; 374 float _31, _32, _33, _34; 375 float _41, _42, _43, _44; 376 }; 377 float m[4][4]; 378 }; 379#else 380 XMVECTOR r[4]; 381#endif 382 383 XMMATRIX() {} 384 XMMATRIX(FXMVECTOR R0, FXMVECTOR R1, FXMVECTOR R2, GXMVECTOR R3) { r[0] = R0; r[1] = R1; r[2] = R2; r[3] = R3; } 385 XMMATRIX(float m00, float m01, float m02, float m03, 386 float m10, float m11, float m12, float m13, 387 float m20, float m21, float m22, float m23, 388 float m30, float m31, float m32, float m33); 389 explicit XMMATRIX(_In_reads_(16) const float *pArray); 390 391#ifdef _XM_NO_INTRINSICS_ 392 float operator() (size_t Row, size_t Column) const { return m[Row][Column]; } 393 float& operator() (size_t Row, size_t Column) { return m[Row][Column]; } 394#endif 395 396 XMMATRIX& operator= (const XMMATRIX& M) { r[0] = M.r[0]; r[1] = M.r[1]; r[2] = M.r[2]; r[3] = M.r[3]; return *this; } 397 398 XMMATRIX operator+ () const { return *this; } 399 XMMATRIX operator- () const; 400 401 XMMATRIX& operator+= (CXMMATRIX M); 402 XMMATRIX& operator-= (CXMMATRIX M); 403 XMMATRIX& operator*= (CXMMATRIX M); 404 XMMATRIX& operator*= (float S); 405 XMMATRIX& operator/= (float S); 406 407 XMMATRIX operator+ (CXMMATRIX M) const; 408 XMMATRIX operator- (CXMMATRIX M) const; 409 XMMATRIX operator* (CXMMATRIX M) const; 410 XMMATRIX operator* (float S) const; 411 XMMATRIX operator/ (float S) const; 412 413 friend XMMATRIX operator* (float S, CXMMATRIX M); 414}; 415 416//------------------------------------------------------------------------------ 417// 2D Vector; 32 bit floating point components 418struct XMFLOAT2 419{ 420 float x; 421 float y; 422 423 XMFLOAT2() {} 424 XMFLOAT2(float _x, float _y) : x(_x), y(_y) {} 425 explicit XMFLOAT2(_In_reads_(2) const float *pArray) : x(pArray[0]), y(pArray[1]) {} 426 427 XMFLOAT2& operator= (const XMFLOAT2& Float2) { x = Float2.x; y = Float2.y; return *this; } 428}; 429 430// 2D Vector; 32 bit floating point components aligned on a 16 byte boundary 431__declspec(align(16)) struct XMFLOAT2A : public XMFLOAT2 432{ 433 XMFLOAT2A() : XMFLOAT2() {} 434 XMFLOAT2A(float _x, float _y) : XMFLOAT2(_x, _y) {} 435 explicit XMFLOAT2A(_In_reads_(2) const float *pArray) : XMFLOAT2(pArray) {} 436 437 XMFLOAT2A& operator= (const XMFLOAT2A& Float2) { x = Float2.x; y = Float2.y; return *this; } 438}; 439 440//------------------------------------------------------------------------------ 441// 2D Vector; 32 bit signed integer components 442struct XMINT2 443{ 444 int32_t x; 445 int32_t y; 446 447 XMINT2() {} 448 XMINT2(int32_t _x, int32_t _y) : x(_x), y(_y) {} 449 explicit XMINT2(_In_reads_(2) const int32_t *pArray) : x(pArray[0]), y(pArray[1]) {} 450 451 XMINT2& operator= (const XMINT2& Int2) { x = Int2.x; y = Int2.y; return *this; } 452}; 453 454// 2D Vector; 32 bit unsigned integer components 455struct XMUINT2 456{ 457 uint32_t x; 458 uint32_t y; 459 460 XMUINT2() {} 461 XMUINT2(uint32_t _x, uint32_t _y) : x(_x), y(_y) {} 462 explicit XMUINT2(_In_reads_(2) const uint32_t *pArray) : x(pArray[0]), y(pArray[1]) {} 463 464 XMUINT2& operator= (const XMUINT2& UInt2) { x = UInt2.x; y = UInt2.y; return *this; } 465}; 466 467//------------------------------------------------------------------------------ 468// 3D Vector; 32 bit floating point components 469struct XMFLOAT3 470{ 471 float x; 472 float y; 473 float z; 474 475 XMFLOAT3() {} 476 XMFLOAT3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {} 477 explicit XMFLOAT3(_In_reads_(3) const float *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {} 478 479 XMFLOAT3& operator= (const XMFLOAT3& Float3) { x = Float3.x; y = Float3.y; z = Float3.z; return *this; } 480}; 481 482// 3D Vector; 32 bit floating point components aligned on a 16 byte boundary 483__declspec(align(16)) struct XMFLOAT3A : public XMFLOAT3 484{ 485 XMFLOAT3A() : XMFLOAT3() {} 486 XMFLOAT3A(float _x, float _y, float _z) : XMFLOAT3(_x, _y, _z) {} 487 explicit XMFLOAT3A(_In_reads_(3) const float *pArray) : XMFLOAT3(pArray) {} 488 489 XMFLOAT3A& operator= (const XMFLOAT3A& Float3) { x = Float3.x; y = Float3.y; z = Float3.z; return *this; } 490}; 491 492//------------------------------------------------------------------------------ 493// 3D Vector; 32 bit signed integer components 494struct XMINT3 495{ 496 int32_t x; 497 int32_t y; 498 int32_t z; 499 500 XMINT3() {} 501 XMINT3(int32_t _x, int32_t _y, int32_t _z) : x(_x), y(_y), z(_z) {} 502 explicit XMINT3(_In_reads_(3) const int32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {} 503 504 XMINT3& operator= (const XMINT3& i3) { x = i3.x; y = i3.y; z = i3.z; return *this; } 505}; 506 507// 3D Vector; 32 bit unsigned integer components 508struct XMUINT3 509{ 510 uint32_t x; 511 uint32_t y; 512 uint32_t z; 513 514 XMUINT3() {} 515 XMUINT3(uint32_t _x, uint32_t _y, uint32_t _z) : x(_x), y(_y), z(_z) {} 516 explicit XMUINT3(_In_reads_(3) const uint32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]) {} 517 518 XMUINT3& operator= (const XMUINT3& u3) { x = u3.x; y = u3.y; z = u3.z; return *this; } 519}; 520 521//------------------------------------------------------------------------------ 522// 4D Vector; 32 bit floating point components 523struct XMFLOAT4 524{ 525 float x; 526 float y; 527 float z; 528 float w; 529 530 XMFLOAT4() {} 531 XMFLOAT4(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) {} 532 explicit XMFLOAT4(_In_reads_(4) const float *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {} 533 534 XMFLOAT4& operator= (const XMFLOAT4& Float4) { x = Float4.x; y = Float4.y; z = Float4.z; w = Float4.w; return *this; } 535}; 536 537// 4D Vector; 32 bit floating point components aligned on a 16 byte boundary 538__declspec(align(16)) struct XMFLOAT4A : public XMFLOAT4 539{ 540 XMFLOAT4A() : XMFLOAT4() {} 541 XMFLOAT4A(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {} 542 explicit XMFLOAT4A(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} 543 544 XMFLOAT4A& operator= (const XMFLOAT4A& Float4) { x = Float4.x; y = Float4.y; z = Float4.z; w = Float4.w; return *this; } 545}; 546 547//------------------------------------------------------------------------------ 548// 4D Vector; 32 bit signed integer components 549struct XMINT4 550{ 551 int32_t x; 552 int32_t y; 553 int32_t z; 554 int32_t w; 555 556 XMINT4() {} 557 XMINT4(int32_t _x, int32_t _y, int32_t _z, int32_t _w) : x(_x), y(_y), z(_z), w(_w) {} 558 explicit XMINT4(_In_reads_(4) const int32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {} 559 560 XMINT4& operator= (const XMINT4& Int4) { x = Int4.x; y = Int4.y; z = Int4.z; w = Int4.w; return *this; } 561}; 562 563// 4D Vector; 32 bit unsigned integer components 564struct XMUINT4 565{ 566 uint32_t x; 567 uint32_t y; 568 uint32_t z; 569 uint32_t w; 570 571 XMUINT4() {} 572 XMUINT4(uint32_t _x, uint32_t _y, uint32_t _z, uint32_t _w) : x(_x), y(_y), z(_z), w(_w) {} 573 explicit XMUINT4(_In_reads_(4) const uint32_t *pArray) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {} 574 575 XMUINT4& operator= (const XMUINT4& UInt4) { x = UInt4.x; y = UInt4.y; z = UInt4.z; w = UInt4.w; return *this; } 576}; 577 578//------------------------------------------------------------------------------ 579// 3x3 Matrix: 32 bit floating point components 580struct XMFLOAT3X3 581{ 582 union 583 { 584 struct 585 { 586 float _11, _12, _13; 587 float _21, _22, _23; 588 float _31, _32, _33; 589 }; 590 float m[3][3]; 591 }; 592 593 XMFLOAT3X3() {} 594 XMFLOAT3X3(float m00, float m01, float m02, 595 float m10, float m11, float m12, 596 float m20, float m21, float m22); 597 explicit XMFLOAT3X3(_In_reads_(9) const float *pArray); 598 599 float operator() (size_t Row, size_t Column) const { return m[Row][Column]; } 600 float& operator() (size_t Row, size_t Column) { return m[Row][Column]; } 601 602 XMFLOAT3X3& operator= (const XMFLOAT3X3& Float3x3); 603}; 604 605//------------------------------------------------------------------------------ 606// 4x3 Matrix: 32 bit floating point components 607struct XMFLOAT4X3 608{ 609 union 610 { 611 struct 612 { 613 float _11, _12, _13; 614 float _21, _22, _23; 615 float _31, _32, _33; 616 float _41, _42, _43; 617 }; 618 float m[4][3]; 619 }; 620 621 XMFLOAT4X3() {} 622 XMFLOAT4X3(float m00, float m01, float m02, 623 float m10, float m11, float m12, 624 float m20, float m21, float m22, 625 float m30, float m31, float m32); 626 explicit XMFLOAT4X3(_In_reads_(12) const float *pArray); 627 628 float operator() (size_t Row, size_t Column) const { return m[Row][Column]; } 629 float& operator() (size_t Row, size_t Column) { return m[Row][Column]; } 630 631 XMFLOAT4X3& operator= (const XMFLOAT4X3& Float4x3); 632 633}; 634 635// 4x3 Matrix: 32 bit floating point components aligned on a 16 byte boundary 636__declspec(align(16)) struct XMFLOAT4X3A : public XMFLOAT4X3 637{ 638 XMFLOAT4X3A() : XMFLOAT4X3() {} 639 XMFLOAT4X3A(float m00, float m01, float m02, 640 float m10, float m11, float m12, 641 float m20, float m21, float m22, 642 float m30, float m31, float m32) : 643 XMFLOAT4X3(m00,m01,m02,m10,m11,m12,m20,m21,m22,m30,m31,m32) {} 644 explicit XMFLOAT4X3A(_In_reads_(12) const float *pArray) : XMFLOAT4X3(pArray) {} 645 646 float operator() (size_t Row, size_t Column) const { return m[Row][Column]; } 647 float& operator() (size_t Row, size_t Column) { return m[Row][Column]; } 648 649 XMFLOAT4X3A& operator= (const XMFLOAT4X3A& Float4x3); 650}; 651 652//------------------------------------------------------------------------------ 653// 4x4 Matrix: 32 bit floating point components 654struct XMFLOAT4X4 655{ 656 union 657 { 658 struct 659 { 660 float _11, _12, _13, _14; 661 float _21, _22, _23, _24; 662 float _31, _32, _33, _34; 663 float _41, _42, _43, _44; 664 }; 665 float m[4][4]; 666 }; 667 668 XMFLOAT4X4() {} 669 XMFLOAT4X4(float m00, float m01, float m02, float m03, 670 float m10, float m11, float m12, float m13, 671 float m20, float m21, float m22, float m23, 672 float m30, float m31, float m32, float m33); 673 explicit XMFLOAT4X4(_In_reads_(16) const float *pArray); 674 675 float operator() (size_t Row, size_t Column) const { return m[Row][Column]; } 676 float& operator() (size_t Row, size_t Column) { return m[Row][Column]; } 677 678 XMFLOAT4X4& operator= (const XMFLOAT4X4& Float4x4); 679}; 680 681// 4x4 Matrix: 32 bit floating point components aligned on a 16 byte boundary 682__declspec(align(16)) struct XMFLOAT4X4A : public XMFLOAT4X4 683{ 684 XMFLOAT4X4A() : XMFLOAT4X4() {} 685 XMFLOAT4X4A(float m00, float m01, float m02, float m03, 686 float m10, float m11, float m12, float m13, 687 float m20, float m21, float m22, float m23, 688 float m30, float m31, float m32, float m33) 689 : XMFLOAT4X4(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33) {} 690 explicit XMFLOAT4X4A(_In_reads_(16) const float *pArray) : XMFLOAT4X4(pArray) {} 691 692 float operator() (size_t Row, size_t Column) const { return m[Row][Column]; } 693 float& operator() (size_t Row, size_t Column) { return m[Row][Column]; } 694 695 XMFLOAT4X4A& operator= (const XMFLOAT4X4A& Float4x4); 696}; 697 698//////////////////////////////////////////////////////////////////////////////// 699 700 701#ifdef _XM_BIGENDIAN_ 702#pragma bitfield_order(pop) 703#endif 704 705#pragma prefast(pop) 706#pragma warning(pop) 707 708/**************************************************************************** 709 * 710 * Data conversion operations 711 * 712 ****************************************************************************/ 713 714#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_VMX128_INTRINSICS_) 715#else 716XMVECTOR XMConvertVectorIntToFloat(FXMVECTOR VInt, uint32_t DivExponent); 717XMVECTOR XMConvertVectorFloatToInt(FXMVECTOR VFloat, uint32_t MulExponent); 718XMVECTOR XMConvertVectorUIntToFloat(FXMVECTOR VUInt, uint32_t DivExponent); 719XMVECTOR XMConvertVectorFloatToUInt(FXMVECTOR VFloat, uint32_t MulExponent); 720#endif 721 722#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_VMX128_INTRINSICS_) 723#else 724 725#if defined(__XNAMATH_H__) && defined(XMVectorSetBinaryConstant) 726#undef XMVectorSetBinaryConstant 727#undef XMVectorSplatConstant 728#undef XMVectorSplatConstantInt 729#endif 730 731XMVECTOR XMVectorSetBinaryConstant(uint32_t C0, uint32_t C1, uint32_t C2, uint32_t C3); 732XMVECTOR XMVectorSplatConstant(int32_t IntConstant, uint32_t DivExponent); 733XMVECTOR XMVectorSplatConstantInt(int32_t IntConstant); 734#endif 735 736/**************************************************************************** 737 * 738 * Load operations 739 * 740 ****************************************************************************/ 741 742XMVECTOR XMLoadInt(_In_ const uint32_t* pSource); 743XMVECTOR XMLoadFloat(_In_ const float* pSource); 744 745XMVECTOR XMLoadInt2(_In_reads_(2) const uint32_t* pSource); 746XMVECTOR XMLoadInt2A(_In_reads_(2) const uint32_t* PSource); 747XMVECTOR XMLoadFloat2(_In_ const XMFLOAT2* pSource); 748XMVECTOR XMLoadFloat2A(_In_ const XMFLOAT2A* pSource); 749XMVECTOR XMLoadSInt2(_In_ const XMINT2* pSource); 750XMVECTOR XMLoadUInt2(_In_ const XMUINT2* pSource); 751 752XMVECTOR XMLoadInt3(_In_reads_(3) const uint32_t* pSource); 753XMVECTOR XMLoadInt3A(_In_reads_(3) const uint32_t* pSource); 754XMVECTOR XMLoadFloat3(_In_ const XMFLOAT3* pSource); 755XMVECTOR XMLoadFloat3A(_In_ const XMFLOAT3A* pSource); 756XMVECTOR XMLoadSInt3(_In_ const XMINT3* pSource); 757XMVECTOR XMLoadUInt3(_In_ const XMUINT3* pSource); 758 759XMVECTOR XMLoadInt4(_In_reads_(4) const uint32_t* pSource); 760XMVECTOR XMLoadInt4A(_In_reads_(4) const uint32_t* pSource); 761XMVECTOR XMLoadFloat4(_In_ const XMFLOAT4* pSource); 762XMVECTOR XMLoadFloat4A(_In_ const XMFLOAT4A* pSource); 763XMVECTOR XMLoadSInt4(_In_ const XMINT4* pSource); 764XMVECTOR XMLoadUInt4(_In_ const XMUINT4* pSource); 765 766XMMATRIX XMLoadFloat3x3(_In_ const XMFLOAT3X3* pSource); 767XMMATRIX XMLoadFloat4x3(_In_ const XMFLOAT4X3* pSource); 768XMMATRIX XMLoadFloat4x3A(_In_ const XMFLOAT4X3A* pSource); 769XMMATRIX XMLoadFloat4x4(_In_ const XMFLOAT4X4* pSource); 770XMMATRIX XMLoadFloat4x4A(_In_ const XMFLOAT4X4A* pSource); 771 772/**************************************************************************** 773 * 774 * Store operations 775 * 776 ****************************************************************************/ 777 778void XMStoreInt(_Out_ uint32_t* pDestination, _In_ FXMVECTOR V); 779void XMStoreFloat(_Out_ float* pDestination, _In_ FXMVECTOR V); 780 781void XMStoreInt2(_Out_writes_(2) uint32_t* pDestination, _In_ FXMVECTOR V); 782void XMStoreInt2A(_Out_writes_(2) uint32_t* pDestination, _In_ FXMVECTOR V); 783void XMStoreFloat2(_Out_ XMFLOAT2* pDestination, _In_ FXMVECTOR V); 784void XMStoreFloat2A(_Out_ XMFLOAT2A* pDestination, _In_ FXMVECTOR V); 785void XMStoreSInt2(_Out_ XMINT2* pDestination, _In_ FXMVECTOR V); 786void XMStoreUInt2(_Out_ XMUINT2* pDestination, _In_ FXMVECTOR V); 787 788void XMStoreInt3(_Out_writes_(3) uint32_t* pDestination, _In_ FXMVECTOR V); 789void XMStoreInt3A(_Out_writes_(3) uint32_t* pDestination, _In_ FXMVECTOR V); 790void XMStoreFloat3(_Out_ XMFLOAT3* pDestination, _In_ FXMVECTOR V); 791void XMStoreFloat3A(_Out_ XMFLOAT3A* pDestination, _In_ FXMVECTOR V); 792void XMStoreSInt3(_Out_ XMINT3* pDestination, _In_ FXMVECTOR V); 793void XMStoreUInt3(_Out_ XMUINT3* pDestination, _In_ FXMVECTOR V); 794 795void XMStoreInt4(_Out_writes_(4) uint32_t* pDestination, _In_ FXMVECTOR V); 796void XMStoreInt4A(_Out_writes_(4) uint32_t* pDestination, _In_ FXMVECTOR V); 797void XMStoreFloat4(_Out_ XMFLOAT4* pDestination, _In_ FXMVECTOR V); 798void XMStoreFloat4A(_Out_ XMFLOAT4A* pDestination, _In_ FXMVECTOR V); 799void XMStoreSInt4(_Out_ XMINT4* pDestination, _In_ FXMVECTOR V); 800void XMStoreUInt4(_Out_ XMUINT4* pDestination, _In_ FXMVECTOR V); 801 802void XMStoreFloat3x3(_Out_ XMFLOAT3X3* pDestination, _In_ CXMMATRIX M); 803void XMStoreFloat4x3(_Out_ XMFLOAT4X3* pDestination, _In_ CXMMATRIX M); 804void XMStoreFloat4x3A(_Out_ XMFLOAT4X3A* pDestination, _In_ CXMMATRIX M); 805void XMStoreFloat4x4(_Out_ XMFLOAT4X4* pDestination, _In_ CXMMATRIX M); 806void XMStoreFloat4x4A(_Out_ XMFLOAT4X4A* pDestination, _In_ CXMMATRIX M); 807 808/**************************************************************************** 809 * 810 * General vector operations 811 * 812 ****************************************************************************/ 813 814XMVECTOR XMVectorZero(); 815XMVECTOR XMVectorSet(float x, float y, float z, float w); 816XMVECTOR XMVectorSetInt(uint32_t x, uint32_t y, uint32_t z, uint32_t w); 817XMVECTOR XMVectorReplicate(float Value); 818XMVECTOR XMVectorReplicatePtr(_In_ const float *pValue); 819XMVECTOR XMVectorReplicateInt(uint32_t Value); 820XMVECTOR XMVectorReplicateIntPtr(_In_ const uint32_t *pValue); 821XMVECTOR XMVectorTrueInt(); 822XMVECTOR XMVectorFalseInt(); 823XMVECTOR XMVectorSplatX(FXMVECTOR V); 824XMVECTOR XMVectorSplatY(FXMVECTOR V); 825XMVECTOR XMVectorSplatZ(FXMVECTOR V); 826XMVECTOR XMVectorSplatW(FXMVECTOR V); 827XMVECTOR XMVectorSplatOne(); 828XMVECTOR XMVectorSplatInfinity(); 829XMVECTOR XMVectorSplatQNaN(); 830XMVECTOR XMVectorSplatEpsilon(); 831XMVECTOR XMVectorSplatSignMask(); 832 833float XMVectorGetByIndex(FXMVECTOR V, size_t i); 834float XMVectorGetX(FXMVECTOR V); 835float XMVectorGetY(FXMVECTOR V); 836float XMVectorGetZ(FXMVECTOR V); 837float XMVectorGetW(FXMVECTOR V); 838 839void XMVectorGetByIndexPtr(_Out_ float *f, _In_ FXMVECTOR V, _In_ size_t i); 840void XMVectorGetXPtr(_Out_ float *x, _In_ FXMVECTOR V); 841void XMVectorGetYPtr(_Out_ float *y, _In_ FXMVECTOR V); 842void XMVectorGetZPtr(_Out_ float *z, _In_ FXMVECTOR V); 843void XMVectorGetWPtr(_Out_ float *w, _In_ FXMVECTOR V); 844 845uint32_t XMVectorGetIntByIndex(FXMVECTOR V, size_t i); 846uint32_t XMVectorGetIntX(FXMVECTOR V); 847uint32_t XMVectorGetIntY(FXMVECTOR V); 848uint32_t XMVectorGetIntZ(FXMVECTOR V); 849uint32_t XMVectorGetIntW(FXMVECTOR V); 850 851void XMVectorGetIntByIndexPtr(_Out_ uint32_t *x, _In_ FXMVECTOR V, _In_ size_t i); 852void XMVectorGetIntXPtr(_Out_ uint32_t *x, _In_ FXMVECTOR V); 853void XMVectorGetIntYPtr(_Out_ uint32_t *y, _In_ FXMVECTOR V); 854void XMVectorGetIntZPtr(_Out_ uint32_t *z, _In_ FXMVECTOR V); 855void XMVectorGetIntWPtr(_Out_ uint32_t *w, _In_ FXMVECTOR V); 856 857XMVECTOR XMVectorSetByIndex(FXMVECTOR V,float f, size_t i); 858XMVECTOR XMVectorSetX(FXMVECTOR V, float x); 859XMVECTOR XMVectorSetY(FXMVECTOR V, float y); 860XMVECTOR XMVectorSetZ(FXMVECTOR V, float z); 861XMVECTOR XMVectorSetW(FXMVECTOR V, float w); 862 863XMVECTOR XMVectorSetByIndexPtr(_In_ FXMVECTOR V, _In_ const float *f, _In_ size_t i); 864XMVECTOR XMVectorSetXPtr(_In_ FXMVECTOR V, _In_ const float *x); 865XMVECTOR XMVectorSetYPtr(_In_ FXMVECTOR V, _In_ const float *y); 866XMVECTOR XMVectorSetZPtr(_In_ FXMVECTOR V, _In_ const float *z); 867XMVECTOR XMVectorSetWPtr(_In_ FXMVECTOR V, _In_ const float *w); 868 869XMVECTOR XMVectorSetIntByIndex(FXMVECTOR V, uint32_t x, size_t i); 870XMVECTOR XMVectorSetIntX(FXMVECTOR V, uint32_t x); 871XMVECTOR XMVectorSetIntY(FXMVECTOR V, uint32_t y); 872XMVECTOR XMVectorSetIntZ(FXMVECTOR V, uint32_t z); 873XMVECTOR XMVectorSetIntW(FXMVECTOR V, uint32_t w); 874 875XMVECTOR XMVectorSetIntByIndexPtr(_In_ FXMVECTOR V, _In_ const uint32_t *x, _In_ size_t i); 876XMVECTOR XMVectorSetIntXPtr(_In_ FXMVECTOR V, _In_ const uint32_t *x); 877XMVECTOR XMVectorSetIntYPtr(_In_ FXMVECTOR V, _In_ const uint32_t *y); 878XMVECTOR XMVectorSetIntZPtr(_In_ FXMVECTOR V, _In_ const uint32_t *z); 879XMVECTOR XMVectorSetIntWPtr(_In_ FXMVECTOR V, _In_ const uint32_t *w); 880 881#if defined(__XNAMATH_H__) && defined(XMVectorSwizzle) 882#undef XMVectorSwizzle 883#endif 884 885XMVECTOR XMVectorSwizzle(FXMVECTOR V, uint32_t E0, uint32_t E1, uint32_t E2, uint32_t E3); 886XMVECTOR XMVectorPermute(FXMVECTOR V1, FXMVECTOR V2, uint32_t PermuteX, uint32_t PermuteY, uint32_t PermuteZ, uint32_t PermuteW); 887XMVECTOR XMVectorSelectControl(uint32_t VectorIndex0, uint32_t VectorIndex1, uint32_t VectorIndex2, uint32_t VectorIndex3); 888XMVECTOR XMVectorSelect(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Control); 889XMVECTOR XMVectorMergeXY(FXMVECTOR V1, FXMVECTOR V2); 890XMVECTOR XMVectorMergeZW(FXMVECTOR V1, FXMVECTOR V2); 891 892#if defined(__XNAMATH_H__) && defined(XMVectorShiftLeft) 893#undef XMVectorShiftLeft 894#undef XMVectorRotateLeft 895#undef XMVectorRotateRight 896#undef XMVectorInsert 897#endif 898 899XMVECTOR XMVectorShiftLeft(FXMVECTOR V1, FXMVECTOR V2, uint32_t Elements); 900XMVECTOR XMVectorRotateLeft(FXMVECTOR V, uint32_t Elements); 901XMVECTOR XMVectorRotateRight(FXMVECTOR V, uint32_t Elements); 902XMVECTOR XMVectorInsert(FXMVECTOR VD, FXMVECTOR VS, uint32_t VSLeftRotateElements, 903 uint32_t Select0, uint32_t Select1, uint32_t Select2, uint32_t Select3); 904 905XMVECTOR XMVectorEqual(FXMVECTOR V1, FXMVECTOR V2); 906XMVECTOR XMVectorEqualR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2); 907XMVECTOR XMVectorEqualInt(FXMVECTOR V1, FXMVECTOR V2); 908XMVECTOR XMVectorEqualIntR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V, _In_ FXMVECTOR V2); 909XMVECTOR XMVectorNearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon); 910XMVECTOR XMVectorNotEqual(FXMVECTOR V1, FXMVECTOR V2); 911XMVECTOR XMVectorNotEqualInt(FXMVECTOR V1, FXMVECTOR V2); 912XMVECTOR XMVectorGreater(FXMVECTOR V1, FXMVECTOR V2); 913XMVECTOR XMVectorGreaterR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2); 914XMVECTOR XMVectorGreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2); 915XMVECTOR XMVectorGreaterOrEqualR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2); 916XMVECTOR XMVectorLess(FXMVECTOR V1, FXMVECTOR V2); 917XMVECTOR XMVectorLessOrEqual(FXMVECTOR V1, FXMVECTOR V2); 918XMVECTOR XMVectorInBounds(FXMVECTOR V, FXMVECTOR Bounds); 919XMVECTOR XMVectorInBoundsR(_Out_ uint32_t* pCR, _In_ FXMVECTOR V, _In_ FXMVECTOR Bounds); 920 921XMVECTOR XMVectorIsNaN(FXMVECTOR V); 922XMVECTOR XMVectorIsInfinite(FXMVECTOR V); 923 924XMVECTOR XMVectorMin(FXMVECTOR V1,FXMVECTOR V2); 925XMVECTOR XMVectorMax(FXMVECTOR V1, FXMVECTOR V2); 926XMVECTOR XMVectorRound(FXMVECTOR V); 927XMVECTOR XMVectorTruncate(FXMVECTOR V); 928XMVECTOR XMVectorFloor(FXMVECTOR V); 929XMVECTOR XMVectorCeiling(FXMVECTOR V); 930XMVECTOR XMVectorClamp(FXMVECTOR V, FXMVECTOR Min, FXMVECTOR Max); 931XMVECTOR XMVectorSaturate(FXMVECTOR V); 932 933XMVECTOR XMVectorAndInt(FXMVECTOR V1, FXMVECTOR V2); 934XMVECTOR XMVectorAndCInt(FXMVECTOR V1, FXMVECTOR V2); 935XMVECTOR XMVectorOrInt(FXMVECTOR V1, FXMVECTOR V2); 936XMVECTOR XMVectorNorInt(FXMVECTOR V1, FXMVECTOR V2); 937XMVECTOR XMVectorXorInt(FXMVECTOR V1, FXMVECTOR V2); 938 939XMVECTOR XMVectorNegate(FXMVECTOR V); 940XMVECTOR XMVectorAdd(FXMVECTOR V1, FXMVECTOR V2); 941XMVECTOR XMVectorAddAngles(FXMVECTOR V1, FXMVECTOR V2); 942XMVECTOR XMVectorSubtract(FXMVECTOR V1, FXMVECTOR V2); 943XMVECTOR XMVectorSubtractAngles(FXMVECTOR V1, FXMVECTOR V2); 944XMVECTOR XMVectorMultiply(FXMVECTOR V1, FXMVECTOR V2); 945XMVECTOR XMVectorMultiplyAdd(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3); 946XMVECTOR XMVectorDivide(FXMVECTOR V1, FXMVECTOR V2); 947XMVECTOR XMVectorNegativeMultiplySubtract(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3); 948XMVECTOR XMVectorScale(FXMVECTOR V, float ScaleFactor); 949XMVECTOR XMVectorReciprocalEst(FXMVECTOR V); 950XMVECTOR XMVectorReciprocal(FXMVECTOR V); 951XMVECTOR XMVectorSqrtEst(FXMVECTOR V); 952XMVECTOR XMVectorSqrt(FXMVECTOR V); 953XMVECTOR XMVectorReciprocalSqrtEst(FXMVECTOR V); 954XMVECTOR XMVectorReciprocalSqrt(FXMVECTOR V); 955XMVECTOR XMVectorExp(FXMVECTOR V); 956XMVECTOR XMVectorLog(FXMVECTOR V); 957XMVECTOR XMVectorPow(FXMVECTOR V1, FXMVECTOR V2); 958XMVECTOR XMVectorAbs(FXMVECTOR V); 959XMVECTOR XMVectorMod(FXMVECTOR V1, FXMVECTOR V2); 960XMVECTOR XMVectorModAngles(FXMVECTOR Angles); 961XMVECTOR XMVectorSin(FXMVECTOR V); 962XMVECTOR XMVectorSinEst(FXMVECTOR V); 963XMVECTOR XMVectorCos(FXMVECTOR V); 964XMVECTOR XMVectorCosEst(FXMVECTOR V); 965void XMVectorSinCos(_Out_ XMVECTOR* pSin, _Out_ XMVECTOR* pCos, _In_ FXMVECTOR V); 966void XMVectorSinCosEst(_Out_ XMVECTOR* pSin, _Out_ XMVECTOR* pCos, _In_ FXMVECTOR V); 967XMVECTOR XMVectorTan(FXMVECTOR V); 968XMVECTOR XMVectorTanEst(FXMVECTOR V); 969XMVECTOR XMVectorSinH(FXMVECTOR V); 970XMVECTOR XMVectorCosH(FXMVECTOR V); 971XMVECTOR XMVectorTanH(FXMVECTOR V); 972XMVECTOR XMVectorASin(FXMVECTOR V); 973XMVECTOR XMVectorASinEst(FXMVECTOR V); 974XMVECTOR XMVectorACos(FXMVECTOR V); 975XMVECTOR XMVectorACosEst(FXMVECTOR V); 976XMVECTOR XMVectorATan(FXMVECTOR V); 977XMVECTOR XMVectorATanEst(FXMVECTOR V); 978XMVECTOR XMVectorATan2(FXMVECTOR Y, FXMVECTOR X); 979XMVECTOR XMVectorATan2Est(FXMVECTOR Y, FXMVECTOR X); 980XMVECTOR XMVectorLerp(FXMVECTOR V0, FXMVECTOR V1, float t); 981XMVECTOR XMVectorLerpV(FXMVECTOR V0, FXMVECTOR V1, FXMVECTOR T); 982XMVECTOR XMVectorHermite(FXMVECTOR Position0, FXMVECTOR Tangent0, FXMVECTOR Position1, GXMVECTOR Tangent1, float t); 983XMVECTOR XMVectorHermiteV(FXMVECTOR Position0, FXMVECTOR Tangent0, FXMVECTOR Position1, GXMVECTOR Tangent1, CXMVECTOR T); 984XMVECTOR XMVectorCatmullRom(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, GXMVECTOR Position3, float t); 985XMVECTOR XMVectorCatmullRomV(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, GXMVECTOR Position3, CXMVECTOR T); 986XMVECTOR XMVectorBaryCentric(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, float f, float g); 987XMVECTOR XMVectorBaryCentricV(FXMVECTOR Position0, FXMVECTOR Position1, FXMVECTOR Position2, GXMVECTOR F, CXMVECTOR G); 988 989/**************************************************************************** 990 * 991 * 2D vector operations 992 * 993 ****************************************************************************/ 994 995bool XMVector2Equal(FXMVECTOR V1, FXMVECTOR V2); 996uint32_t XMVector2EqualR(FXMVECTOR V1, FXMVECTOR V2); 997bool XMVector2EqualInt(FXMVECTOR V1, FXMVECTOR V2); 998uint32_t XMVector2EqualIntR(FXMVECTOR V1, FXMVECTOR V2); 999bool XMVector2NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon); 1000bool XMVector2NotEqual(FXMVECTOR V1, FXMVECTOR V2); 1001bool XMVector2NotEqualInt(FXMVECTOR V1, FXMVECTOR V2); 1002bool XMVector2Greater(FXMVECTOR V1, FXMVECTOR V2); 1003uint32_t XMVector2GreaterR(FXMVECTOR V1, FXMVECTOR V2); 1004bool XMVector2GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2); 1005uint32_t XMVector2GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2); 1006bool XMVector2Less(FXMVECTOR V1, FXMVECTOR V2); 1007bool XMVector2LessOrEqual(FXMVECTOR V1, FXMVECTOR V2); 1008bool XMVector2InBounds(FXMVECTOR V, FXMVECTOR Bounds); 1009 1010bool XMVector2IsNaN(FXMVECTOR V); 1011bool XMVector2IsInfinite(FXMVECTOR V); 1012 1013XMVECTOR XMVector2Dot(FXMVECTOR V1, FXMVECTOR V2); 1014XMVECTOR XMVector2Cross(FXMVECTOR V1, FXMVECTOR V2); 1015XMVECTOR XMVector2LengthSq(FXMVECTOR V); 1016XMVECTOR XMVector2ReciprocalLengthEst(FXMVECTOR V); 1017XMVECTOR XMVector2ReciprocalLength(FXMVECTOR V); 1018XMVECTOR XMVector2LengthEst(FXMVECTOR V); 1019XMVECTOR XMVector2Length(FXMVECTOR V); 1020XMVECTOR XMVector2NormalizeEst(FXMVECTOR V); 1021XMVECTOR XMVector2Normalize(FXMVECTOR V); 1022XMVECTOR XMVector2ClampLength(FXMVECTOR V, float LengthMin, float LengthMax); 1023XMVECTOR XMVector2ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax); 1024XMVECTOR XMVector2Reflect(FXMVECTOR Incident, FXMVECTOR Normal); 1025XMVECTOR XMVector2Refract(FXMVECTOR Incident, FXMVECTOR Normal, float RefractionIndex); 1026XMVECTOR XMVector2RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex); 1027XMVECTOR XMVector2Orthogonal(FXMVECTOR V); 1028XMVECTOR XMVector2AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2); 1029XMVECTOR XMVector2AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2); 1030XMVECTOR XMVector2AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2); 1031XMVECTOR XMVector2LinePointDistance(FXMVECTOR LinePoint1, FXMVECTOR LinePoint2, FXMVECTOR Point); 1032XMVECTOR XMVector2IntersectLine(FXMVECTOR Line1Point1, FXMVECTOR Line1Point2, FXMVECTOR Line2Point1, GXMVECTOR Line2Point2); 1033XMVECTOR XMVector2Transform(FXMVECTOR V, CXMMATRIX M); 1034XMFLOAT4* XMVector2TransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream, 1035 _In_ size_t OutputStride, 1036 _In_reads_bytes_(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) const XMFLOAT2* pInputStream, 1037 _In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M); 1038XMVECTOR XMVector2TransformCoord(FXMVECTOR V, CXMMATRIX M); 1039XMFLOAT2* XMVector2TransformCoordStream(_Out_writes_bytes_(sizeof(XMFLOAT2)+OutputStride*(VectorCount-1)) XMFLOAT2* pOutputStream, 1040 _In_ size_t OutputStride, 1041 _In_reads_bytes_(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) const XMFLOAT2* pInputStream, 1042 _In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M); 1043XMVECTOR XMVector2TransformNormal(FXMVECTOR V, CXMMATRIX M); 1044XMFLOAT2* XMVector2TransformNormalStream(_Out_writes_bytes_(sizeof(XMFLOAT2)+OutputStride*(VectorCount-1)) XMFLOAT2* pOutputStream, 1045 _In_ size_t OutputStride, 1046 _In_reads_bytes_(sizeof(XMFLOAT2)+InputStride*(VectorCount-1)) const XMFLOAT2* pInputStream, 1047 _In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M); 1048 1049/**************************************************************************** 1050 * 1051 * 3D vector operations 1052 * 1053 ****************************************************************************/ 1054 1055bool XMVector3Equal(FXMVECTOR V1, FXMVECTOR V2); 1056uint32_t XMVector3EqualR(FXMVECTOR V1, FXMVECTOR V2); 1057bool XMVector3EqualInt(FXMVECTOR V1, FXMVECTOR V2); 1058uint32_t XMVector3EqualIntR(FXMVECTOR V1, FXMVECTOR V2); 1059bool XMVector3NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon); 1060bool XMVector3NotEqual(FXMVECTOR V1, FXMVECTOR V2); 1061bool XMVector3NotEqualInt(FXMVECTOR V1, FXMVECTOR V2); 1062bool XMVector3Greater(FXMVECTOR V1, FXMVECTOR V2); 1063uint32_t XMVector3GreaterR(FXMVECTOR V1, FXMVECTOR V2); 1064bool XMVector3GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2); 1065uint32_t XMVector3GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2); 1066bool XMVector3Less(FXMVECTOR V1, FXMVECTOR V2); 1067bool XMVector3LessOrEqual(FXMVECTOR V1, FXMVECTOR V2); 1068bool XMVector3InBounds(FXMVECTOR V, FXMVECTOR Bounds); 1069 1070bool XMVector3IsNaN(FXMVECTOR V); 1071bool XMVector3IsInfinite(FXMVECTOR V); 1072 1073XMVECTOR XMVector3Dot(FXMVECTOR V1, FXMVECTOR V2); 1074XMVECTOR XMVector3Cross(FXMVECTOR V1, FXMVECTOR V2); 1075XMVECTOR XMVector3LengthSq(FXMVECTOR V); 1076XMVECTOR XMVector3ReciprocalLengthEst(FXMVECTOR V); 1077XMVECTOR XMVector3ReciprocalLength(FXMVECTOR V); 1078XMVECTOR XMVector3LengthEst(FXMVECTOR V); 1079XMVECTOR XMVector3Length(FXMVECTOR V); 1080XMVECTOR XMVector3NormalizeEst(FXMVECTOR V); 1081XMVECTOR XMVector3Normalize(FXMVECTOR V); 1082XMVECTOR XMVector3ClampLength(FXMVECTOR V, float LengthMin, float LengthMax); 1083XMVECTOR XMVector3ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax); 1084XMVECTOR XMVector3Reflect(FXMVECTOR Incident, FXMVECTOR Normal); 1085XMVECTOR XMVector3Refract(FXMVECTOR Incident, FXMVECTOR Normal, float RefractionIndex); 1086XMVECTOR XMVector3RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex); 1087XMVECTOR XMVector3Orthogonal(FXMVECTOR V); 1088XMVECTOR XMVector3AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2); 1089XMVECTOR XMVector3AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2); 1090XMVECTOR XMVector3AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2); 1091XMVECTOR XMVector3LinePointDistance(FXMVECTOR LinePoint1, FXMVECTOR LinePoint2, FXMVECTOR Point); 1092void XMVector3ComponentsFromNormal(_Out_ XMVECTOR* pParallel, _Out_ XMVECTOR* pPerpendicular, _In_ FXMVECTOR V, _In_ FXMVECTOR Normal); 1093XMVECTOR XMVector3Rotate(FXMVECTOR V, FXMVECTOR RotationQuaternion); 1094XMVECTOR XMVector3InverseRotate(FXMVECTOR V, FXMVECTOR RotationQuaternion); 1095XMVECTOR XMVector3Transform(FXMVECTOR V, CXMMATRIX M); 1096XMFLOAT4* XMVector3TransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream, 1097 _In_ size_t OutputStride, 1098 _In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream, 1099 _In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M); 1100XMVECTOR XMVector3TransformCoord(FXMVECTOR V, CXMMATRIX M); 1101XMFLOAT3* XMVector3TransformCoordStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream, 1102 _In_ size_t OutputStride, 1103 _In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream, 1104 _In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M); 1105XMVECTOR XMVector3TransformNormal(FXMVECTOR V, CXMMATRIX M); 1106XMFLOAT3* XMVector3TransformNormalStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream, 1107 _In_ size_t OutputStride, 1108 _In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream, 1109 _In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M); 1110XMVECTOR XMVector3Project(FXMVECTOR V, float ViewportX, float ViewportY, float ViewportWidth, float ViewportHeight, float ViewportMinZ, float ViewportMaxZ, 1111 CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World); 1112XMFLOAT3* XMVector3ProjectStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream, 1113 _In_ size_t OutputStride, 1114 _In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream, 1115 _In_ size_t InputStride, _In_ size_t VectorCount, 1116 _In_ float ViewportX, _In_ float ViewportY, _In_ float ViewportWidth, _In_ float ViewportHeight, _In_ float ViewportMinZ, _In_ float ViewportMaxZ, 1117 _In_ CXMMATRIX Projection, _In_ CXMMATRIX View, _In_ CXMMATRIX World); 1118XMVECTOR XMVector3Unproject(FXMVECTOR V, float ViewportX, float ViewportY, float ViewportWidth, float ViewportHeight, float ViewportMinZ, float ViewportMaxZ, 1119 CXMMATRIX Projection, CXMMATRIX View, CXMMATRIX World); 1120XMFLOAT3* XMVector3UnprojectStream(_Out_writes_bytes_(sizeof(XMFLOAT3)+OutputStride*(VectorCount-1)) XMFLOAT3* pOutputStream, 1121 _In_ size_t OutputStride, 1122 _In_reads_bytes_(sizeof(XMFLOAT3)+InputStride*(VectorCount-1)) const XMFLOAT3* pInputStream, 1123 _In_ size_t InputStride, _In_ size_t VectorCount, 1124 _In_ float ViewportX, _In_ float ViewportY, _In_ float ViewportWidth, _In_ float ViewportHeight, _In_ float ViewportMinZ, _In_ float ViewportMaxZ, 1125 _In_ CXMMATRIX Projection, _In_ CXMMATRIX View, _In_ CXMMATRIX World); 1126 1127/**************************************************************************** 1128 * 1129 * 4D vector operations 1130 * 1131 ****************************************************************************/ 1132 1133bool XMVector4Equal(FXMVECTOR V1, FXMVECTOR V2); 1134uint32_t XMVector4EqualR(FXMVECTOR V1, FXMVECTOR V2); 1135bool XMVector4EqualInt(FXMVECTOR V1, FXMVECTOR V2); 1136uint32_t XMVector4EqualIntR(FXMVECTOR V1, FXMVECTOR V2); 1137bool XMVector4NearEqual(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR Epsilon); 1138bool XMVector4NotEqual(FXMVECTOR V1, FXMVECTOR V2); 1139bool XMVector4NotEqualInt(FXMVECTOR V1, FXMVECTOR V2); 1140bool XMVector4Greater(FXMVECTOR V1, FXMVECTOR V2); 1141uint32_t XMVector4GreaterR(FXMVECTOR V1, FXMVECTOR V2); 1142bool XMVector4GreaterOrEqual(FXMVECTOR V1, FXMVECTOR V2); 1143uint32_t XMVector4GreaterOrEqualR(FXMVECTOR V1, FXMVECTOR V2); 1144bool XMVector4Less(FXMVECTOR V1, FXMVECTOR V2); 1145bool XMVector4LessOrEqual(FXMVECTOR V1, FXMVECTOR V2); 1146bool XMVector4InBounds(FXMVECTOR V, FXMVECTOR Bounds); 1147 1148bool XMVector4IsNaN(FXMVECTOR V); 1149bool XMVector4IsInfinite(FXMVECTOR V); 1150 1151XMVECTOR XMVector4Dot(FXMVECTOR V1, FXMVECTOR V2); 1152XMVECTOR XMVector4Cross(FXMVECTOR V1, FXMVECTOR V2, FXMVECTOR V3); 1153XMVECTOR XMVector4LengthSq(FXMVECTOR V); 1154XMVECTOR XMVector4ReciprocalLengthEst(FXMVECTOR V); 1155XMVECTOR XMVector4ReciprocalLength(FXMVECTOR V); 1156XMVECTOR XMVector4LengthEst(FXMVECTOR V); 1157XMVECTOR XMVector4Length(FXMVECTOR V); 1158XMVECTOR XMVector4NormalizeEst(FXMVECTOR V); 1159XMVECTOR XMVector4Normalize(FXMVECTOR V); 1160XMVECTOR XMVector4ClampLength(FXMVECTOR V, float LengthMin, float LengthMax); 1161XMVECTOR XMVector4ClampLengthV(FXMVECTOR V, FXMVECTOR LengthMin, FXMVECTOR LengthMax); 1162XMVECTOR XMVector4Reflect(FXMVECTOR Incident, FXMVECTOR Normal); 1163XMVECTOR XMVector4Refract(FXMVECTOR Incident, FXMVECTOR Normal, float RefractionIndex); 1164XMVECTOR XMVector4RefractV(FXMVECTOR Incident, FXMVECTOR Normal, FXMVECTOR RefractionIndex); 1165XMVECTOR XMVector4Orthogonal(FXMVECTOR V); 1166XMVECTOR XMVector4AngleBetweenNormalsEst(FXMVECTOR N1, FXMVECTOR N2); 1167XMVECTOR XMVector4AngleBetweenNormals(FXMVECTOR N1, FXMVECTOR N2); 1168XMVECTOR XMVector4AngleBetweenVectors(FXMVECTOR V1, FXMVECTOR V2); 1169XMVECTOR XMVector4Transform(FXMVECTOR V, CXMMATRIX M); 1170XMFLOAT4* XMVector4TransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(VectorCount-1)) XMFLOAT4* pOutputStream, 1171 _In_ size_t OutputStride, 1172 _In_reads_bytes_(sizeof(XMFLOAT4)+InputStride*(VectorCount-1)) const XMFLOAT4* pInputStream, 1173 _In_ size_t InputStride, _In_ size_t VectorCount, _In_ CXMMATRIX M); 1174 1175/**************************************************************************** 1176 * 1177 * Matrix operations 1178 * 1179 ****************************************************************************/ 1180 1181bool XMMatrixIsNaN(CXMMATRIX M); 1182bool XMMatrixIsInfinite(CXMMATRIX M); 1183bool XMMatrixIsIdentity(CXMMATRIX M); 1184 1185XMMATRIX XMMatrixMultiply(CXMMATRIX M1, CXMMATRIX M2); 1186XMMATRIX XMMatrixMultiplyTranspose(CXMMATRIX M1, CXMMATRIX M2); 1187XMMATRIX XMMatrixTranspose(CXMMATRIX M); 1188XMMATRIX XMMatrixInverse(_Out_opt_ XMVECTOR* pDeterminant, _In_ CXMMATRIX M); 1189XMVECTOR XMMatrixDeterminant(CXMMATRIX M); 1190_Success_(return) 1191bool XMMatrixDecompose(_Out_ XMVECTOR *outScale, _Out_ XMVECTOR *outRotQuat, _Out_ XMVECTOR *outTrans, _In_ CXMMATRIX M); 1192 1193XMMATRIX XMMatrixIdentity(); 1194XMMATRIX XMMatrixSet(float m00, float m01, float m02, float m03, 1195 float m10, float m11, float m12, float m13, 1196 float m20, float m21, float m22, float m23, 1197 float m30, float m31, float m32, float m33); 1198XMMATRIX XMMatrixTranslation(float OffsetX, float OffsetY, float OffsetZ); 1199XMMATRIX XMMatrixTranslationFromVector(FXMVECTOR Offset); 1200XMMATRIX XMMatrixScaling(float ScaleX, float ScaleY, float ScaleZ); 1201XMMATRIX XMMatrixScalingFromVector(FXMVECTOR Scale); 1202XMMATRIX XMMatrixRotationX(float Angle); 1203XMMATRIX XMMatrixRotationY(float Angle); 1204XMMATRIX XMMatrixRotationZ(float Angle); 1205XMMATRIX XMMatrixRotationRollPitchYaw(float Pitch, float Yaw, float Roll); 1206XMMATRIX XMMatrixRotationRollPitchYawFromVector(FXMVECTOR Angles); 1207XMMATRIX XMMatrixRotationNormal(FXMVECTOR NormalAxis, float Angle); 1208XMMATRIX XMMatrixRotationAxis(FXMVECTOR Axis, float Angle); 1209XMMATRIX XMMatrixRotationQuaternion(FXMVECTOR Quaternion); 1210XMMATRIX XMMatrixTransformation2D(FXMVECTOR ScalingOrigin, float ScalingOrientation, FXMVECTOR Scaling, 1211 FXMVECTOR RotationOrigin, float Rotation, GXMVECTOR Translation); 1212XMMATRIX XMMatrixTransformation(FXMVECTOR ScalingOrigin, FXMVECTOR ScalingOrientationQuaternion, FXMVECTOR Scaling, 1213 GXMVECTOR RotationOrigin, CXMVECTOR RotationQuaternion, CXMVECTOR Translation); 1214XMMATRIX XMMatrixAffineTransformation2D(FXMVECTOR Scaling, FXMVECTOR RotationOrigin, float Rotation, FXMVECTOR Translation); 1215XMMATRIX XMMatrixAffineTransformation(FXMVECTOR Scaling, FXMVECTOR RotationOrigin, FXMVECTOR RotationQuaternion, GXMVECTOR Translation); 1216XMMATRIX XMMatrixReflect(FXMVECTOR ReflectionPlane); 1217XMMATRIX XMMatrixShadow(FXMVECTOR ShadowPlane, FXMVECTOR LightPosition); 1218 1219XMMATRIX XMMatrixLookAtLH(FXMVECTOR EyePosition, FXMVECTOR FocusPosition, FXMVECTOR UpDirection); 1220XMMATRIX XMMatrixLookAtRH(FXMVECTOR EyePosition, FXMVECTOR FocusPosition, FXMVECTOR UpDirection); 1221XMMATRIX XMMatrixLookToLH(FXMVECTOR EyePosition, FXMVECTOR EyeDirection, FXMVECTOR UpDirection); 1222XMMATRIX XMMatrixLookToRH(FXMVECTOR EyePosition, FXMVECTOR EyeDirection, FXMVECTOR UpDirection); 1223XMMATRIX XMMatrixPerspectiveLH(float ViewWidth, float ViewHeight, float NearZ, float FarZ); 1224XMMATRIX XMMatrixPerspectiveRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ); 1225XMMATRIX XMMatrixPerspectiveFovLH(float FovAngleY, float AspectHByW, float NearZ, float FarZ); 1226XMMATRIX XMMatrixPerspectiveFovRH(float FovAngleY, float AspectHByW, float NearZ, float FarZ); 1227XMMATRIX XMMatrixPerspectiveOffCenterLH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ); 1228XMMATRIX XMMatrixPerspectiveOffCenterRH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ); 1229XMMATRIX XMMatrixOrthographicLH(float ViewWidth, float ViewHeight, float NearZ, float FarZ); 1230XMMATRIX XMMatrixOrthographicRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ); 1231XMMATRIX XMMatrixOrthographicOffCenterLH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ); 1232XMMATRIX XMMatrixOrthographicOffCenterRH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ); 1233 1234 1235/**************************************************************************** 1236 * 1237 * Quaternion operations 1238 * 1239 ****************************************************************************/ 1240 1241bool XMQuaternionEqual(FXMVECTOR Q1, FXMVECTOR Q2); 1242bool XMQuaternionNotEqual(FXMVECTOR Q1, FXMVECTOR Q2); 1243 1244bool XMQuaternionIsNaN(FXMVECTOR Q); 1245bool XMQuaternionIsInfinite(FXMVECTOR Q); 1246bool XMQuaternionIsIdentity(FXMVECTOR Q); 1247 1248XMVECTOR XMQuaternionDot(FXMVECTOR Q1, FXMVECTOR Q2); 1249XMVECTOR XMQuaternionMultiply(FXMVECTOR Q1, FXMVECTOR Q2); 1250XMVECTOR XMQuaternionLengthSq(FXMVECTOR Q); 1251XMVECTOR XMQuaternionReciprocalLength(FXMVECTOR Q); 1252XMVECTOR XMQuaternionLength(FXMVECTOR Q); 1253XMVECTOR XMQuaternionNormalizeEst(FXMVECTOR Q); 1254XMVECTOR XMQuaternionNormalize(FXMVECTOR Q); 1255XMVECTOR XMQuaternionConjugate(FXMVECTOR Q); 1256XMVECTOR XMQuaternionInverse(FXMVECTOR Q); 1257XMVECTOR XMQuaternionLn(FXMVECTOR Q); 1258XMVECTOR XMQuaternionExp(FXMVECTOR Q); 1259XMVECTOR XMQuaternionSlerp(FXMVECTOR Q0, FXMVECTOR Q1, float t); 1260XMVECTOR XMQuaternionSlerpV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR T); 1261XMVECTOR XMQuaternionSquad(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, GXMVECTOR Q3, float t); 1262XMVECTOR XMQuaternionSquadV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, GXMVECTOR Q3, CXMVECTOR T); 1263void XMQuaternionSquadSetup(_Out_ XMVECTOR* pA, _Out_ XMVECTOR* pB, _Out_ XMVECTOR* pC, _In_ FXMVECTOR Q0, _In_ FXMVECTOR Q1, _In_ FXMVECTOR Q2, _In_ GXMVECTOR Q3); 1264XMVECTOR XMQuaternionBaryCentric(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, float f, float g); 1265XMVECTOR XMQuaternionBaryCentricV(FXMVECTOR Q0, FXMVECTOR Q1, FXMVECTOR Q2, GXMVECTOR F, CXMVECTOR G); 1266 1267XMVECTOR XMQuaternionIdentity(); 1268XMVECTOR XMQuaternionRotationRollPitchYaw(float Pitch, float Yaw, float Roll); 1269XMVECTOR XMQuaternionRotationRollPitchYawFromVector(FXMVECTOR Angles); 1270XMVECTOR XMQuaternionRotationNormal(FXMVECTOR NormalAxis, float Angle); 1271XMVECTOR XMQuaternionRotationAxis(FXMVECTOR Axis, float Angle); 1272XMVECTOR XMQuaternionRotationMatrix(CXMMATRIX M); 1273 1274void XMQuaternionToAxisAngle(_Out_ XMVECTOR* pAxis, _Out_ float* pAngle, _In_ FXMVECTOR Q); 1275 1276/**************************************************************************** 1277 * 1278 * Plane operations 1279 * 1280 ****************************************************************************/ 1281 1282bool XMPlaneEqual(FXMVECTOR P1, FXMVECTOR P2); 1283bool XMPlaneNearEqual(FXMVECTOR P1, FXMVECTOR P2, FXMVECTOR Epsilon); 1284bool XMPlaneNotEqual(FXMVECTOR P1, FXMVECTOR P2); 1285 1286bool XMPlaneIsNaN(FXMVECTOR P); 1287bool XMPlaneIsInfinite(FXMVECTOR P); 1288 1289XMVECTOR XMPlaneDot(FXMVECTOR P, FXMVECTOR V); 1290XMVECTOR XMPlaneDotCoord(FXMVECTOR P, FXMVECTOR V); 1291XMVECTOR XMPlaneDotNormal(FXMVECTOR P, FXMVECTOR V); 1292XMVECTOR XMPlaneNormalizeEst(FXMVECTOR P); 1293XMVECTOR XMPlaneNormalize(FXMVECTOR P); 1294XMVECTOR XMPlaneIntersectLine(FXMVECTOR P, FXMVECTOR LinePoint1, FXMVECTOR LinePoint2); 1295void XMPlaneIntersectPlane(_Out_ XMVECTOR* pLinePoint1, _Out_ XMVECTOR* pLinePoint2, _In_ FXMVECTOR P1, _In_ FXMVECTOR P2); 1296XMVECTOR XMPlaneTransform(FXMVECTOR P, CXMMATRIX M); 1297XMFLOAT4* XMPlaneTransformStream(_Out_writes_bytes_(sizeof(XMFLOAT4)+OutputStride*(PlaneCount-1)) XMFLOAT4* pOutputStream, 1298 _In_ size_t OutputStride, 1299 _In_reads_bytes_(sizeof(XMFLOAT4)+InputStride*(PlaneCount-1)) const XMFLOAT4* pInputStream, 1300 _In_ size_t InputStride, _In_ size_t PlaneCount, _In_ CXMMATRIX M); 1301 1302XMVECTOR XMPlaneFromPointNormal(FXMVECTOR Point, FXMVECTOR Normal); 1303XMVECTOR XMPlaneFromPoints(FXMVECTOR Point1, FXMVECTOR Point2, FXMVECTOR Point3); 1304 1305/**************************************************************************** 1306 * 1307 * Color operations 1308 * 1309 ****************************************************************************/ 1310 1311bool XMColorEqual(FXMVECTOR C1, FXMVECTOR C2); 1312bool XMColorNotEqual(FXMVECTOR C1, FXMVECTOR C2); 1313bool XMColorGreater(FXMVECTOR C1, FXMVECTOR C2); 1314bool XMColorGreaterOrEqual(FXMVECTOR C1, FXMVECTOR C2); 1315bool XMColorLess(FXMVECTOR C1, FXMVECTOR C2); 1316bool XMColorLessOrEqual(FXMVECTOR C1, FXMVECTOR C2); 1317 1318bool XMColorIsNaN(FXMVECTOR C); 1319bool XMColorIsInfinite(FXMVECTOR C); 1320 1321XMVECTOR XMColorNegative(FXMVECTOR C); 1322XMVECTOR XMColorModulate(FXMVECTOR C1, FXMVECTOR C2); 1323XMVECTOR XMColorAdjustSaturation(FXMVECTOR C, float Saturation); 1324XMVECTOR XMColorAdjustContrast(FXMVECTOR C, float Contrast); 1325 1326XMVECTOR XMColorRGBToHSL( FXMVECTOR rgb ); 1327XMVECTOR XMColorHSLToRGB( FXMVECTOR hsl ); 1328 1329XMVECTOR XMColorRGBToHSV( FXMVECTOR rgb ); 1330XMVECTOR XMColorHSVToRGB( FXMVECTOR hsv ); 1331 1332XMVECTOR XMColorRGBToYUV( FXMVECTOR rgb ); 1333XMVECTOR XMColorYUVToRGB( FXMVECTOR yuv ); 1334 1335XMVECTOR XMColorRGBToYUV_HD( FXMVECTOR rgb ); 1336XMVECTOR XMColorYUVToRGB_HD( FXMVECTOR yuv ); 1337 1338XMVECTOR XMColorRGBToXYZ( FXMVECTOR rgb ); 1339XMVECTOR XMColorXYZToRGB( FXMVECTOR xyz ); 1340 1341XMVECTOR XMColorXYZToSRGB( FXMVECTOR xyz ); 1342XMVECTOR XMColorSRGBToXYZ( FXMVECTOR srgb ); 1343 1344/**************************************************************************** 1345 * 1346 * Miscellaneous operations 1347 * 1348 ****************************************************************************/ 1349 1350bool XMVerifyCPUSupport(); 1351 1352XMVECTOR XMFresnelTerm(FXMVECTOR CosIncidentAngle, FXMVECTOR RefractionIndex); 1353 1354bool XMScalarNearEqual(float S1, float S2, float Epsilon); 1355float XMScalarModAngle(float Value); 1356 1357float XMScalarSin(float Value); 1358float XMScalarSinEst(float Value); 1359 1360float XMScalarCos(float Value); 1361float XMScalarCosEst(float Value); 1362 1363void XMScalarSinCos(_Out_ float* pSin, _Out_ float* pCos, float Value); 1364void XMScalarSinCosEst(_Out_ float* pSin, _Out_ float* pCos, float Value); 1365 1366float XMScalarASin(float Value); 1367float XMScalarASinEst(float Value); 1368 1369float XMScalarACos(float Value); 1370float XMScalarACosEst(float Value); 1371 1372/**************************************************************************** 1373 * 1374 * Templates 1375 * 1376 ****************************************************************************/ 1377 1378#if defined(__XNAMATH_H__) && defined(XMMin) 1379#undef XMMin 1380#undef XMMax 1381#endif 1382 1383template<class T> inline T XMMin(T a, T b) { return (a < b) ? a : b; } 1384template<class T> inline T XMMax(T a, T b) { return (a > b) ? a : b; } 1385 1386//------------------------------------------------------------------------------ 1387 1388#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1389 1390#define XM_PERMUTE_PS( v, c ) _mm_shuffle_ps( v, v, c ) 1391 1392// PermuteHelper internal template (SSE only) 1393namespace Internal 1394{ 1395 // Slow path fallback for permutes that do not map to a single SSE shuffle opcode. 1396 template<uint32_t Shuffle, bool WhichX, bool WhichY, bool WhichZ, bool WhichW> struct PermuteHelper 1397 { 1398 static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2) 1399 { 1400 static const XMVECTORU32 selectMask = 1401 { 1402 WhichX ? 0xFFFFFFFF : 0, 1403 WhichY ? 0xFFFFFFFF : 0, 1404 WhichZ ? 0xFFFFFFFF : 0, 1405 WhichW ? 0xFFFFFFFF : 0, 1406 }; 1407 1408 XMVECTOR shuffled1 = XM_PERMUTE_PS(v1, Shuffle); 1409 XMVECTOR shuffled2 = XM_PERMUTE_PS(v2, Shuffle); 1410 1411 XMVECTOR masked1 = _mm_andnot_ps(selectMask, shuffled1); 1412 XMVECTOR masked2 = _mm_and_ps(selectMask, shuffled2); 1413 1414 return _mm_or_ps(masked1, masked2); 1415 } 1416 }; 1417 1418 // Fast path for permutes that only read from the first vector. 1419 template<uint32_t Shuffle> struct PermuteHelper<Shuffle, false, false, false, false> 1420 { 1421 static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2) { (v2); return XM_PERMUTE_PS(v1, Shuffle); } 1422 }; 1423 1424 // Fast path for permutes that only read from the second vector. 1425 template<uint32_t Shuffle> struct PermuteHelper<Shuffle, true, true, true, true> 1426 { 1427 static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2){ (v1); return XM_PERMUTE_PS(v2, Shuffle); } 1428 }; 1429 1430 // Fast path for permutes that read XY from the first vector, ZW from the second. 1431 template<uint32_t Shuffle> struct PermuteHelper<Shuffle, false, false, true, true> 1432 { 1433 static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2) { return _mm_shuffle_ps(v1, v2, Shuffle); } 1434 }; 1435 1436 // Fast path for permutes that read XY from the second vector, ZW from the first. 1437 template<uint32_t Shuffle> struct PermuteHelper<Shuffle, true, true, false, false> 1438 { 1439 static XMVECTOR Permute(FXMVECTOR v1, FXMVECTOR v2) { return _mm_shuffle_ps(v2, v1, Shuffle); } 1440 }; 1441}; 1442 1443#endif // _XM_SSE_INTRINSICS_ && !_XM_NO_INTRINSICS_ 1444 1445// General permute template 1446template<uint32_t PermuteX, uint32_t PermuteY, uint32_t PermuteZ, uint32_t PermuteW> 1447 inline XMVECTOR XMVectorPermute(FXMVECTOR V1, FXMVECTOR V2) 1448{ 1449 static_assert(PermuteX <= 7, "PermuteX template parameter out of range"); 1450 static_assert(PermuteY <= 7, "PermuteY template parameter out of range"); 1451 static_assert(PermuteZ <= 7, "PermuteZ template parameter out of range"); 1452 static_assert(PermuteW <= 7, "PermuteW template parameter out of range"); 1453 1454#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1455 const uint32_t Shuffle = _MM_SHUFFLE(PermuteW & 3, PermuteZ & 3, PermuteY & 3, PermuteX & 3); 1456 1457 const bool WhichX = PermuteX > 3; 1458 const bool WhichY = PermuteY > 3; 1459 const bool WhichZ = PermuteZ > 3; 1460 const bool WhichW = PermuteW > 3; 1461 1462 return Internal::PermuteHelper<Shuffle, WhichX, WhichY, WhichZ, WhichW>::Permute(V1, V2); 1463#else 1464 1465 return XMVectorPermute( V1, V2, PermuteX, PermuteY, PermuteZ, PermuteW ); 1466 1467#endif 1468} 1469 1470// Special-case permute templates 1471template<> inline XMVECTOR XMVectorPermute<0,1,2,3>(FXMVECTOR V1, FXMVECTOR V2) { (V2); return V1; } 1472template<> inline XMVECTOR XMVectorPermute<4,5,6,7>(FXMVECTOR V1, FXMVECTOR V2) { (V1); return V2; } 1473 1474#if defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1475 1476// If the indices are all in the range 0-3 or 4-7, then use XMVectorSwizzle instead 1477// The mirror cases are not spelled out here as the programmer can always swap the arguments 1478// (i.e. prefer permutes where the X element comes from the V1 vector instead of the V2 vector) 1479 1480template<> inline XMVECTOR XMVectorPermute<0,1,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vget_low_f32(V2) ); } 1481template<> inline XMVECTOR XMVectorPermute<1,0,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vget_low_f32(V2) ); } 1482template<> inline XMVECTOR XMVectorPermute<0,1,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vrev64_f32( vget_low_f32(V2) ) ); } 1483template<> inline XMVECTOR XMVectorPermute<1,0,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vrev64_f32( vget_low_f32(V2) ) ); } 1484 1485template<> inline XMVECTOR XMVectorPermute<2,3,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_high_f32(V1), vget_high_f32(V2) ); } 1486template<> inline XMVECTOR XMVectorPermute<3,2,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vget_high_f32(V2) ); } 1487template<> inline XMVECTOR XMVectorPermute<2,3,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_high_f32(V1), vrev64_f32( vget_high_f32(V2) ) ); } 1488template<> inline XMVECTOR XMVectorPermute<3,2,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vrev64_f32( vget_high_f32(V2) ) ); } 1489 1490template<> inline XMVECTOR XMVectorPermute<0,1,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vget_high_f32(V2) ); } 1491template<> inline XMVECTOR XMVectorPermute<1,0,6,7>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vget_high_f32(V2) ); } 1492template<> inline XMVECTOR XMVectorPermute<0,1,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_low_f32(V1), vrev64_f32( vget_high_f32(V2) ) ); } 1493template<> inline XMVECTOR XMVectorPermute<1,0,7,6>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_low_f32(V1) ), vrev64_f32( vget_high_f32(V2) ) ); } 1494 1495template<> inline XMVECTOR XMVectorPermute<3,2,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vget_low_f32(V2) ); } 1496template<> inline XMVECTOR XMVectorPermute<2,3,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vget_high_f32(V1), vrev64_f32( vget_low_f32(V2) ) ); } 1497template<> inline XMVECTOR XMVectorPermute<3,2,5,4>(FXMVECTOR V1, FXMVECTOR V2) { return vcombine_f32( vrev64_f32( vget_high_f32(V1) ), vrev64_f32( vget_low_f32(V2) ) ); } 1498 1499template<> inline XMVECTOR XMVectorPermute<0,4,2,6>(FXMVECTOR V1, FXMVECTOR V2) { return vtrnq_f32(V1,V2).val[0]; } 1500template<> inline XMVECTOR XMVectorPermute<1,5,3,7>(FXMVECTOR V1, FXMVECTOR V2) { return vtrnq_f32(V1,V2).val[1]; } 1501 1502template<> inline XMVECTOR XMVectorPermute<0,4,1,5>(FXMVECTOR V1, FXMVECTOR V2) { return vzipq_f32(V1,V2).val[0]; } 1503template<> inline XMVECTOR XMVectorPermute<2,6,3,7>(FXMVECTOR V1, FXMVECTOR V2) { return vzipq_f32(V1,V2).val[1]; } 1504 1505template<> inline XMVECTOR XMVectorPermute<0,2,4,6>(FXMVECTOR V1, FXMVECTOR V2) { return vuzpq_f32(V1,V2).val[0]; } 1506template<> inline XMVECTOR XMVectorPermute<1,3,5,7>(FXMVECTOR V1, FXMVECTOR V2) { return vuzpq_f32(V1,V2).val[1]; } 1507 1508template<> inline XMVECTOR XMVectorPermute<1,2,3,4>(FXMVECTOR V1, FXMVECTOR V2) { return vextq_f32(V1, V2, 1); } 1509template<> inline XMVECTOR XMVectorPermute<2,3,4,5>(FXMVECTOR V1, FXMVECTOR V2) { return vextq_f32(V1, V2, 2); } 1510template<> inline XMVECTOR XMVectorPermute<3,4,5,6>(FXMVECTOR V1, FXMVECTOR V2) { return vextq_f32(V1, V2, 3); } 1511 1512#endif // _XM_ARM_NEON_INTRINSICS_ && !_XM_NO_INTRINSICS_ 1513 1514//------------------------------------------------------------------------------ 1515 1516// General swizzle template 1517template<uint32_t SwizzleX, uint32_t SwizzleY, uint32_t SwizzleZ, uint32_t SwizzleW> 1518 inline XMVECTOR XMVectorSwizzle(FXMVECTOR V) 1519{ 1520 static_assert(SwizzleX <= 3, "SwizzleX template parameter out of range"); 1521 static_assert(SwizzleY <= 3, "SwizzleY template parameter out of range"); 1522 static_assert(SwizzleZ <= 3, "SwizzleZ template parameter out of range"); 1523 static_assert(SwizzleW <= 3, "SwizzleW template parameter out of range"); 1524 1525#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1526 return XM_PERMUTE_PS( V, _MM_SHUFFLE( SwizzleW, SwizzleZ, SwizzleY, SwizzleX ) ); 1527#elif defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1528 return __vpermwi(V, ((SwizzleX & 3) << 6) | ((SwizzleY & 3) << 4) | ((SwizzleZ & 3) << 2) | (SwizzleW & 3) ); 1529#else 1530 1531 return XMVectorSwizzle( V, SwizzleX, SwizzleY, SwizzleZ, SwizzleW ); 1532 1533#endif 1534} 1535 1536// Specialized swizzles 1537template<> inline XMVECTOR XMVectorSwizzle<0,1,2,3>(FXMVECTOR V) { return V; } 1538 1539 1540#if defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1541 1542template<> inline XMVECTOR XMVectorSwizzle<0,0,0,0>(FXMVECTOR V) { return vdupq_lane_f32( vget_low_f32(V), 0); } 1543template<> inline XMVECTOR XMVectorSwizzle<1,1,1,1>(FXMVECTOR V) { return vdupq_lane_f32( vget_low_f32(V), 1); } 1544template<> inline XMVECTOR XMVectorSwizzle<2,2,2,2>(FXMVECTOR V) { return vdupq_lane_f32( vget_high_f32(V), 0); } 1545template<> inline XMVECTOR XMVectorSwizzle<3,3,3,3>(FXMVECTOR V) { return vdupq_lane_f32( vget_high_f32(V), 1); } 1546 1547template<> inline XMVECTOR XMVectorSwizzle<1,0,3,2>(FXMVECTOR V) { return vrev64q_f32(V); } 1548 1549template<> inline XMVECTOR XMVectorSwizzle<0,1,0,1>(FXMVECTOR V) { __n64 vt = vget_low_f32(V); return vcombine_f32( vt, vt ); } 1550template<> inline XMVECTOR XMVectorSwizzle<2,3,2,3>(FXMVECTOR V) { __n64 vt = vget_high_f32(V); return vcombine_f32( vt, vt ); } 1551template<> inline XMVECTOR XMVectorSwizzle<1,0,1,0>(FXMVECTOR V) { __n64 vt = vrev64_f32( vget_low_f32(V) ); return vcombine_f32( vt, vt ); } 1552template<> inline XMVECTOR XMVectorSwizzle<3,2,3,2>(FXMVECTOR V) { __n64 vt = vrev64_f32( vget_high_f32(V) ); return vcombine_f32( vt, vt ); } 1553 1554template<> inline XMVECTOR XMVectorSwizzle<0,1,3,2>(FXMVECTOR V) { return vcombine_f32( vget_low_f32(V), vrev64_f32( vget_high_f32(V) ) ); } 1555template<> inline XMVECTOR XMVectorSwizzle<1,0,2,3>(FXMVECTOR V) { return vcombine_f32( vrev64_f32( vget_low_f32(V) ), vget_high_f32(V) ); } 1556template<> inline XMVECTOR XMVectorSwizzle<2,3,1,0>(FXMVECTOR V) { return vcombine_f32( vget_high_f32(V), vrev64_f32( vget_low_f32(V) ) ); } 1557template<> inline XMVECTOR XMVectorSwizzle<3,2,0,1>(FXMVECTOR V) { return vcombine_f32( vrev64_f32( vget_high_f32(V) ), vget_low_f32(V) ); } 1558template<> inline XMVECTOR XMVectorSwizzle<3,2,1,0>(FXMVECTOR V) { return vcombine_f32( vrev64_f32( vget_high_f32(V) ), vrev64_f32( vget_low_f32(V) ) ); } 1559 1560template<> inline XMVECTOR XMVectorSwizzle<0,0,2,2>(FXMVECTOR V) { return vtrnq_f32(V,V).val[0]; } 1561template<> inline XMVECTOR XMVectorSwizzle<1,1,3,3>(FXMVECTOR V) { return vtrnq_f32(V,V).val[1]; } 1562 1563template<> inline XMVECTOR XMVectorSwizzle<0,0,1,1>(FXMVECTOR V) { return vzipq_f32(V,V).val[0]; } 1564template<> inline XMVECTOR XMVectorSwizzle<2,2,3,3>(FXMVECTOR V) { return vzipq_f32(V,V).val[1]; } 1565 1566template<> inline XMVECTOR XMVectorSwizzle<0,2,0,2>(FXMVECTOR V) { return vuzpq_f32(V,V).val[0]; } 1567template<> inline XMVECTOR XMVectorSwizzle<1,3,1,3>(FXMVECTOR V) { return vuzpq_f32(V,V).val[1]; } 1568 1569template<> inline XMVECTOR XMVectorSwizzle<1,2,3,0>(FXMVECTOR V) { return vextq_f32(V, V, 1); } 1570template<> inline XMVECTOR XMVectorSwizzle<2,3,0,1>(FXMVECTOR V) { return vextq_f32(V, V, 2); } 1571template<> inline XMVECTOR XMVectorSwizzle<3,0,1,2>(FXMVECTOR V) { return vextq_f32(V, V, 3); } 1572 1573#endif // _XM_ARM_NEON_INTRINSICS_ && !_XM_NO_INTRINSICS_ 1574 1575//------------------------------------------------------------------------------ 1576 1577template<uint32_t Elements> 1578 inline XMVECTOR XMVectorShiftLeft(FXMVECTOR V1, FXMVECTOR V2) 1579{ 1580 static_assert( Elements < 4, "Elements template parameter out of range" ); 1581#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1582#else 1583 return XMVectorPermute<Elements, (Elements + 1), (Elements + 2), (Elements + 3)>(V1, V2); 1584#endif 1585} 1586 1587template<uint32_t Elements> 1588 inline XMVECTOR XMVectorRotateLeft(FXMVECTOR V) 1589{ 1590 static_assert( Elements < 4, "Elements template parameter out of range" ); 1591#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1592#else 1593 return XMVectorSwizzle<Elements & 3, (Elements + 1) & 3, (Elements + 2) & 3, (Elements + 3) & 3>(V); 1594#endif 1595} 1596 1597template<uint32_t Elements> 1598 inline XMVECTOR XMVectorRotateRight(FXMVECTOR V) 1599{ 1600 static_assert( Elements < 4, "Elements template parameter out of range" ); 1601#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1602#else 1603 return XMVectorSwizzle<(4 - Elements) & 3, (5 - Elements) & 3, (6 - Elements) & 3, (7 - Elements) & 3>(V); 1604#endif 1605} 1606 1607template<uint32_t VSLeftRotateElements, uint32_t Select0, uint32_t Select1, uint32_t Select2, uint32_t Select3> 1608 inline XMVECTOR XMVectorInsert(FXMVECTOR VD, FXMVECTOR VS) 1609{ 1610#if defined(_XM_VMX128_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) 1611#else 1612 XMVECTOR Control = XMVectorSelectControl(Select0&1, Select1&1, Select2&1, Select3&1); 1613 return XMVectorSelect( VD, XMVectorRotateLeft<VSLeftRotateElements>(VS), Control ); 1614#endif 1615} 1616 1617/**************************************************************************** 1618 * 1619 * Globals 1620 * 1621 ****************************************************************************/ 1622 1623// The purpose of the following global constants is to prevent redundant 1624// reloading of the constants when they are referenced by more than one 1625// separate inline math routine called within the same function. Declaring 1626// a constant locally within a routine is sufficient to prevent redundant 1627// reloads of that constant when that single routine is called multiple 1628// times in a function, but if the constant is used (and declared) in a 1629// separate math routine it would be reloaded. 1630 1631#ifndef XMGLOBALCONST 1632#define XMGLOBALCONST static const // extern const // MGH - __declspec(selectany) 1633#endif 1634 1635XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients0 = {-0.16666667f, +0.0083333310f, -0.00019840874f, +2.7525562e-06f}; 1636XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients1 = {-2.3889859e-08f, -0.16665852f /*Est1*/, +0.0083139502f /*Est2*/, -0.00018524670f /*Est3*/}; 1637XMGLOBALCONST XMVECTORF32 g_XMCosCoefficients0 = {-0.5f, +0.041666638f, -0.0013888378f, +2.4760495e-05f}; 1638XMGLOBALCONST XMVECTORF32 g_XMCosCoefficients1 = {-2.6051615e-07f, -0.49992746f /*Est1*/, +0.041493919f /*Est2*/, -0.0012712436f /*Est3*/}; 1639XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients0 = {1.0f, 0.333333333f, 0.133333333f, 5.396825397e-2f}; 1640XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients1 = {2.186948854e-2f, 8.863235530e-3f, 3.592128167e-3f, 1.455834485e-3f}; 1641XMGLOBALCONST XMVECTORF32 g_XMTanCoefficients2 = {5.900274264e-4f, 2.391290764e-4f, 9.691537707e-5f, 3.927832950e-5f}; 1642XMGLOBALCONST XMVECTORF32 g_XMArcCoefficients0 = {+1.5707963050f, -0.2145988016f, +0.0889789874f, -0.0501743046f}; 1643XMGLOBALCONST XMVECTORF32 g_XMArcCoefficients1 = {+0.0308918810f, -0.0170881256f, +0.0066700901f, -0.0012624911f}; 1644XMGLOBALCONST XMVECTORF32 g_XMATanCoefficients0 = {-0.3333314528f, +0.1999355085f, -0.1420889944f, +0.1065626393f}; 1645XMGLOBALCONST XMVECTORF32 g_XMATanCoefficients1 = {-0.0752896400f, +0.0429096138f, -0.0161657367f, +0.0028662257f}; 1646XMGLOBALCONST XMVECTORF32 g_XMATanEstCoefficients0 = {+0.999866f, +0.999866f, +0.999866f, +0.999866f}; 1647XMGLOBALCONST XMVECTORF32 g_XMATanEstCoefficients1 = {-0.3302995f, +0.180141f, -0.085133f, +0.0208351f}; 1648XMGLOBALCONST XMVECTORF32 g_XMTanEstCoefficients = {2.484f, -1.954923183e-1f, 2.467401101f, XM_1DIVPI}; 1649XMGLOBALCONST XMVECTORF32 g_XMArcEstCoefficients = {+1.5707288f,-0.2121144f,+0.0742610f,-0.0187293f}; 1650XMGLOBALCONST XMVECTORF32 g_XMPiConstants0 = {XM_PI, XM_2PI, XM_1DIVPI, XM_1DIV2PI}; 1651XMGLOBALCONST XMVECTORF32 g_XMIdentityR0 = {1.0f, 0.0f, 0.0f, 0.0f}; 1652XMGLOBALCONST XMVECTORF32 g_XMIdentityR1 = {0.0f, 1.0f, 0.0f, 0.0f}; 1653XMGLOBALCONST XMVECTORF32 g_XMIdentityR2 = {0.0f, 0.0f, 1.0f, 0.0f}; 1654XMGLOBALCONST XMVECTORF32 g_XMIdentityR3 = {0.0f, 0.0f, 0.0f, 1.0f}; 1655XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR0 = {-1.0f,0.0f, 0.0f, 0.0f}; 1656XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR1 = {0.0f,-1.0f, 0.0f, 0.0f}; 1657XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR2 = {0.0f, 0.0f,-1.0f, 0.0f}; 1658XMGLOBALCONST XMVECTORF32 g_XMNegIdentityR3 = {0.0f, 0.0f, 0.0f,-1.0f}; 1659XMGLOBALCONST XMVECTORI32 g_XMNegativeZero = {0x80000000, 0x80000000, 0x80000000, 0x80000000}; 1660XMGLOBALCONST XMVECTORI32 g_XMNegate3 = {0x80000000, 0x80000000, 0x80000000, 0x00000000}; 1661XMGLOBALCONST XMVECTORI32 g_XMMask3 = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000}; 1662XMGLOBALCONST XMVECTORI32 g_XMMaskX = {0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000}; 1663XMGLOBALCONST XMVECTORI32 g_XMMaskY = {0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000}; 1664XMGLOBALCONST XMVECTORI32 g_XMMaskZ = {0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000}; 1665XMGLOBALCONST XMVECTORI32 g_XMMaskW = {0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF}; 1666XMGLOBALCONST XMVECTORF32 g_XMOne = { 1.0f, 1.0f, 1.0f, 1.0f}; 1667XMGLOBALCONST XMVECTORF32 g_XMOne3 = { 1.0f, 1.0f, 1.0f, 0.0f}; 1668XMGLOBALCONST XMVECTORF32 g_XMZero = { 0.0f, 0.0f, 0.0f, 0.0f}; 1669XMGLOBALCONST XMVECTORF32 g_XMTwo = { 2.f, 2.f, 2.f, 2.f }; 1670XMGLOBALCONST XMVECTORF32 g_XMFour = { 4.f, 4.f, 4.f, 4.f }; 1671XMGLOBALCONST XMVECTORF32 g_XMSix = { 6.f, 6.f, 6.f, 6.f }; 1672XMGLOBALCONST XMVECTORF32 g_XMNegativeOne = {-1.0f,-1.0f,-1.0f,-1.0f}; 1673XMGLOBALCONST XMVECTORF32 g_XMOneHalf = { 0.5f, 0.5f, 0.5f, 0.5f}; 1674XMGLOBALCONST XMVECTORF32 g_XMNegativeOneHalf = {-0.5f,-0.5f,-0.5f,-0.5f}; 1675XMGLOBALCONST XMVECTORF32 g_XMNegativeTwoPi = {-XM_2PI, -XM_2PI, -XM_2PI, -XM_2PI}; 1676XMGLOBALCONST XMVECTORF32 g_XMNegativePi = {-XM_PI, -XM_PI, -XM_PI, -XM_PI}; 1677XMGLOBALCONST XMVECTORF32 g_XMHalfPi = {XM_PIDIV2, XM_PIDIV2, XM_PIDIV2, XM_PIDIV2}; 1678XMGLOBALCONST XMVECTORF32 g_XMPi = {XM_PI, XM_PI, XM_PI, XM_PI}; 1679XMGLOBALCONST XMVECTORF32 g_XMReciprocalPi = {XM_1DIVPI, XM_1DIVPI, XM_1DIVPI, XM_1DIVPI}; 1680XMGLOBALCONST XMVECTORF32 g_XMTwoPi = {XM_2PI, XM_2PI, XM_2PI, XM_2PI}; 1681XMGLOBALCONST XMVECTORF32 g_XMReciprocalTwoPi = {XM_1DIV2PI, XM_1DIV2PI, XM_1DIV2PI, XM_1DIV2PI}; 1682XMGLOBALCONST XMVECTORF32 g_XMEpsilon = {1.192092896e-7f, 1.192092896e-7f, 1.192092896e-7f, 1.192092896e-7f}; 1683XMGLOBALCONST XMVECTORI32 g_XMInfinity = {0x7F800000, 0x7F800000, 0x7F800000, 0x7F800000}; 1684XMGLOBALCONST XMVECTORI32 g_XMQNaN = {0x7FC00000, 0x7FC00000, 0x7FC00000, 0x7FC00000}; 1685XMGLOBALCONST XMVECTORI32 g_XMQNaNTest = {0x007FFFFF, 0x007FFFFF, 0x007FFFFF, 0x007FFFFF}; 1686XMGLOBALCONST XMVECTORI32 g_XMAbsMask = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; 1687XMGLOBALCONST XMVECTORI32 g_XMFltMin = {0x00800000, 0x00800000, 0x00800000, 0x00800000}; 1688XMGLOBALCONST XMVECTORI32 g_XMFltMax = {0x7F7FFFFF, 0x7F7FFFFF, 0x7F7FFFFF, 0x7F7FFFFF}; 1689XMGLOBALCONST XMVECTORI32 g_XMNegOneMask = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; 1690XMGLOBALCONST XMVECTORI32 g_XMMaskA8R8G8B8 = {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}; 1691XMGLOBALCONST XMVECTORI32 g_XMFlipA8R8G8B8 = {0x00000000, 0x00000000, 0x00000000, 0x80000000}; 1692XMGLOBALCONST XMVECTORF32 g_XMFixAA8R8G8B8 = {0.0f,0.0f,0.0f,(float)(0x80000000U)}; 1693XMGLOBALCONST 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))}; 1694XMGLOBALCONST XMVECTORI32 g_XMMaskA2B10G10R10 = {0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000}; 1695XMGLOBALCONST XMVECTORI32 g_XMFlipA2B10G10R10 = {0x00000200, 0x00080000, 0x20000000, 0x80000000}; 1696XMGLOBALCONST XMVECTORF32 g_XMFixAA2B10G10R10 = {-512.0f,-512.0f*(float)(0x400),-512.0f*(float)(0x100000),(float)(0x80000000U)}; 1697XMGLOBALCONST 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))}; 1698XMGLOBALCONST XMVECTORI32 g_XMMaskX16Y16 = {0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000}; 1699XMGLOBALCONST XMVECTORI32 g_XMFlipX16Y16 = {0x00008000, 0x00000000, 0x00000000, 0x00000000}; 1700XMGLOBALCONST XMVECTORF32 g_XMFixX16Y16 = {-32768.0f,0.0f,0.0f,0.0f}; 1701XMGLOBALCONST XMVECTORF32 g_XMNormalizeX16Y16 = {1.0f/32767.0f,1.0f/(32767.0f*65536.0f),0.0f,0.0f}; 1702XMGLOBALCONST XMVECTORI32 g_XMMaskX16Y16Z16W16 = {0x0000FFFF, 0x0000FFFF, 0xFFFF0000, 0xFFFF0000}; 1703XMGLOBALCONST XMVECTORI32 g_XMFlipX16Y16Z16W16 = {0x00008000, 0x00008000, 0x00000000, 0x00000000}; 1704XMGLOBALCONST XMVECTORF32 g_XMFixX16Y16Z16W16 = {-32768.0f,-32768.0f,0.0f,0.0f}; 1705XMGLOBALCONST XMVECTORF32 g_XMNormalizeX16Y16Z16W16 = {1.0f/32767.0f,1.0f/32767.0f,1.0f/(32767.0f*65536.0f),1.0f/(32767.0f*65536.0f)}; 1706XMGLOBALCONST XMVECTORF32 g_XMNoFraction = {8388608.0f,8388608.0f,8388608.0f,8388608.0f}; 1707XMGLOBALCONST XMVECTORI32 g_XMMaskByte = {0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF}; 1708XMGLOBALCONST XMVECTORF32 g_XMNegateX = {-1.0f, 1.0f, 1.0f, 1.0f}; 1709XMGLOBALCONST XMVECTORF32 g_XMNegateY = { 1.0f,-1.0f, 1.0f, 1.0f}; 1710XMGLOBALCONST XMVECTORF32 g_XMNegateZ = { 1.0f, 1.0f,-1.0f, 1.0f}; 1711XMGLOBALCONST XMVECTORF32 g_XMNegateW = { 1.0f, 1.0f, 1.0f,-1.0f}; 1712XMGLOBALCONST XMVECTORI32 g_XMSelect0101 = {XM_SELECT_0, XM_SELECT_1, XM_SELECT_0, XM_SELECT_1}; 1713XMGLOBALCONST XMVECTORI32 g_XMSelect1010 = {XM_SELECT_1, XM_SELECT_0, XM_SELECT_1, XM_SELECT_0}; 1714XMGLOBALCONST XMVECTORI32 g_XMOneHalfMinusEpsilon = { 0x3EFFFFFD, 0x3EFFFFFD, 0x3EFFFFFD, 0x3EFFFFFD}; 1715XMGLOBALCONST XMVECTORI32 g_XMSelect1000 = {XM_SELECT_1, XM_SELECT_0, XM_SELECT_0, XM_SELECT_0}; 1716XMGLOBALCONST XMVECTORI32 g_XMSelect1100 = {XM_SELECT_1, XM_SELECT_1, XM_SELECT_0, XM_SELECT_0}; 1717XMGLOBALCONST XMVECTORI32 g_XMSelect1110 = {XM_SELECT_1, XM_SELECT_1, XM_SELECT_1, XM_SELECT_0}; 1718XMGLOBALCONST XMVECTORI32 g_XMSelect1011 = { XM_SELECT_1, XM_SELECT_0, XM_SELECT_1, XM_SELECT_1 }; 1719XMGLOBALCONST XMVECTORF32 g_XMFixupY16 = {1.0f,1.0f/65536.0f,0.0f,0.0f}; 1720XMGLOBALCONST XMVECTORF32 g_XMFixupY16W16 = {1.0f,1.0f,1.0f/65536.0f,1.0f/65536.0f}; 1721XMGLOBALCONST XMVECTORI32 g_XMFlipY = {0,0x80000000,0,0}; 1722XMGLOBALCONST XMVECTORI32 g_XMFlipZ = {0,0,0x80000000,0}; 1723XMGLOBALCONST XMVECTORI32 g_XMFlipW = {0,0,0,0x80000000}; 1724XMGLOBALCONST XMVECTORI32 g_XMFlipYZ = {0,0x80000000,0x80000000,0}; 1725XMGLOBALCONST XMVECTORI32 g_XMFlipZW = {0,0,0x80000000,0x80000000}; 1726XMGLOBALCONST XMVECTORI32 g_XMFlipYW = {0,0x80000000,0,0x80000000}; 1727XMGLOBALCONST XMVECTORI32 g_XMMaskDec4 = {0x3FF,0x3FF<<10,0x3FF<<20,0x3<<30}; 1728XMGLOBALCONST XMVECTORI32 g_XMXorDec4 = {0x200,0x200<<10,0x200<<20,0}; 1729XMGLOBALCONST XMVECTORF32 g_XMAddUDec4 = {0,0,0,32768.0f*65536.0f}; 1730XMGLOBALCONST XMVECTORF32 g_XMAddDec4 = {-512.0f,-512.0f*1024.0f,-512.0f*1024.0f*1024.0f,0}; 1731XMGLOBALCONST XMVECTORF32 g_XMMulDec4 = {1.0f,1.0f/1024.0f,1.0f/(1024.0f*1024.0f),1.0f/(1024.0f*1024.0f*1024.0f)}; 1732XMGLOBALCONST XMVECTORI32 g_XMMaskByte4 = {0xFF,0xFF00,0xFF0000,0xFF000000}; 1733XMGLOBALCONST XMVECTORI32 g_XMXorByte4 = {0x80,0x8000,0x800000,0x00000000}; 1734XMGLOBALCONST XMVECTORF32 g_XMAddByte4 = {-128.0f,-128.0f*256.0f,-128.0f*65536.0f,0}; 1735XMGLOBALCONST XMVECTORF32 g_XMFixUnsigned = {32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f}; 1736XMGLOBALCONST XMVECTORF32 g_XMMaxInt = {65536.0f*32768.0f-128.0f,65536.0f*32768.0f-128.0f,65536.0f*32768.0f-128.0f,65536.0f*32768.0f-128.0f}; 1737XMGLOBALCONST XMVECTORF32 g_XMMaxUInt = {65536.0f*65536.0f-256.0f,65536.0f*65536.0f-256.0f,65536.0f*65536.0f-256.0f,65536.0f*65536.0f-256.0f}; 1738XMGLOBALCONST XMVECTORF32 g_XMUnsignedFix = {32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f,32768.0f*65536.0f}; 1739XMGLOBALCONST XMVECTORF32 g_XMsrgbScale = { 12.92f, 12.92f, 12.92f, 1.0f }; 1740XMGLOBALCONST XMVECTORF32 g_XMsrgbA = { 0.055f, 0.055f, 0.055f, 0.0f }; 1741XMGLOBALCONST XMVECTORF32 g_XMsrgbA1 = { 1.055f, 1.055f, 1.055f, 1.0f }; 1742 1743/**************************************************************************** 1744 * 1745 * Implementation 1746 * 1747 ****************************************************************************/ 1748 1749#pragma warning(push) 1750#pragma warning(disable:4068 4214 4204 4365 4616 4640 6001) 1751 1752#pragma prefast(push) 1753#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes") 1754 1755//------------------------------------------------------------------------------ 1756 1757#if defined(_XM_NO_INTRINSICS_) || defined(_XM_SSE_INTRINSICS_) || defined(_XM_ARM_NEON_INTRINSICS_) 1758 1759inline XMVECTOR XMVectorSetBinaryConstant(uint32_t C0, uint32_t C1, uint32_t C2, uint32_t C3) 1760{ 1761#if defined(_XM_NO_INTRINSICS_) 1762 XMVECTORU32 vResult; 1763 vResult.u[0] = (0-(C0&1)) & 0x3F800000; 1764 vResult.u[1] = (0-(C1&1)) & 0x3F800000; 1765 vResult.u[2] = (0-(C2&1)) & 0x3F800000; 1766 vResult.u[3] = (0-(C3&1)) & 0x3F800000; 1767 return vResult.v; 1768#elif defined(_XM_ARM_NEON_INTRINSICS_) 1769 XMVECTORU32 vResult; 1770 vResult.u[0] = (0-(C0&1)) & 0x3F800000; 1771 vResult.u[1] = (0-(C1&1)) & 0x3F800000; 1772 vResult.u[2] = (0-(C2&1)) & 0x3F800000; 1773 vResult.u[3] = (0-(C3&1)) & 0x3F800000; 1774 return vResult.v; 1775#else // XM_SSE_INTRINSICS_ 1776 static const XMVECTORU32 g_vMask1 = {1,1,1,1}; 1777 // Move the parms to a vector 1778 __m128i vTemp = _mm_set_epi32(C3,C2,C1,C0); 1779 // Mask off the low bits 1780 vTemp = _mm_and_si128(vTemp,g_vMask1); 1781 // 0xFFFFFFFF on true bits 1782 vTemp = _mm_cmpeq_epi32(vTemp,g_vMask1); 1783 // 0xFFFFFFFF -> 1.0f, 0x00000000 -> 0.0f 1784 vTemp = _mm_and_si128(vTemp,g_XMOne); 1785 return _mm_castsi128_ps(vTemp); 1786#endif 1787} 1788 1789//------------------------------------------------------------------------------ 1790 1791inline XMVECTOR XMVectorSplatConstant(int32_t IntConstant, uint32_t DivExponent) 1792{ 1793 assert( IntConstant >= -16 && IntConstant <= 15 ); 1794 assert( DivExponent < 32 ); 1795#if defined(_XM_NO_INTRINSICS_) 1796 1797 using DirectX::XMConvertVectorIntToFloat; 1798 1799 XMVECTORI32 V = { IntConstant, IntConstant, IntConstant, IntConstant }; 1800 return XMConvertVectorIntToFloat( V.v, DivExponent); 1801 1802#elif defined(_XM_ARM_NEON_INTRINSICS_) 1803 // Splat the int 1804 int32x4_t vScale = vdupq_n_s32(IntConstant); 1805 // Convert to a float 1806 XMVECTOR vResult = vcvtq_f32_s32(vScale); 1807 // Convert DivExponent into 1.0f/(1<<DivExponent) 1808 uint32_t uScale = 0x3F800000U - (DivExponent << 23); 1809 // Splat the scalar value (It's really a float) 1810 vScale = vdupq_n_s32(uScale); 1811 // Multiply by the reciprocal (Perform a right shift by DivExponent) 1812 vResult = vmulq_f32(vResult,reinterpret_cast<const float32x4_t *>(&vScale)[0]); 1813 return vResult; 1814#else // XM_SSE_INTRINSICS_ 1815 // Splat the int 1816 __m128i vScale = _mm_set1_epi32(IntConstant); 1817 // Convert to a float 1818 XMVECTOR vResult = _mm_cvtepi32_ps(vScale); 1819 // Convert DivExponent into 1.0f/(1<<DivExponent) 1820 uint32_t uScale = 0x3F800000U - (DivExponent << 23); 1821 // Splat the scalar value (It's really a float) 1822 vScale = _mm_set1_epi32(uScale); 1823 // Multiply by the reciprocal (Perform a right shift by DivExponent) 1824 vResult = _mm_mul_ps(vResult,_mm_castsi128_ps(vScale)); 1825 return vResult; 1826#endif 1827} 1828 1829//------------------------------------------------------------------------------ 1830 1831inline XMVECTOR XMVectorSplatConstantInt(int32_t IntConstant) 1832{ 1833 assert( IntConstant >= -16 && IntConstant <= 15 ); 1834#if defined(_XM_NO_INTRINSICS_) 1835 1836 XMVECTORI32 V = { IntConstant, IntConstant, IntConstant, IntConstant }; 1837 return V.v; 1838 1839#elif defined(_XM_ARM_NEON_INTRINSICS_) 1840 int32x4_t V = vdupq_n_s32( IntConstant ); 1841 return reinterpret_cast<float32x4_t *>(&V)[0]; 1842#else // XM_SSE_INTRINSICS_ 1843 __m128i V = _mm_set1_epi32( IntConstant ); 1844 return reinterpret_cast<__m128 *>(&V)[0]; 1845#endif 1846} 1847 1848// Implemented for VMX128 intrinsics as #defines aboves 1849#endif // _XM_NO_INTRINSICS_ || _XM_SSE_INTRINSICS_ || _XM_ARM_NEON_INTRINSICS_ 1850 1851#include "DirectXMathConvert.inl" 1852#include "DirectXMathVector.inl" 1853#include "DirectXMathMatrix.inl" 1854#include "DirectXMathMisc.inl" 1855 1856 1857#pragma prefast(pop) 1858#pragma warning(pop) 1859 1860}; // namespace DirectX 1861