Simd.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __MATH_SIMD_H__
  21. #define __MATH_SIMD_H__
  22. /*
  23. ===============================================================================
  24. Single Instruction Multiple Data (SIMD)
  25. For optimal use data should be aligned on a 16 byte boundary.
  26. All idSIMDProcessor routines are thread safe.
  27. ===============================================================================
  28. */
  29. class idSIMD {
  30. public:
  31. static void Init();
  32. static void InitProcessor( const char *module, bool forceGeneric );
  33. static void Shutdown();
  34. static void Test_f( const class idCmdArgs &args );
  35. };
  36. /*
  37. ===============================================================================
  38. virtual base class for different SIMD processors
  39. ===============================================================================
  40. */
  41. #define VPCALL __fastcall
  42. class idVec2;
  43. class idVec3;
  44. class idVec4;
  45. class idVec5;
  46. class idVec6;
  47. class idVecX;
  48. class idMat2;
  49. class idMat3;
  50. class idMat4;
  51. class idMat5;
  52. class idMat6;
  53. class idMatX;
  54. class idPlane;
  55. class idDrawVert;
  56. class idJointQuat;
  57. class idJointMat;
  58. struct dominantTri_t;
  59. class idSIMDProcessor {
  60. public:
  61. idSIMDProcessor() { cpuid = CPUID_NONE; }
  62. cpuid_t cpuid;
  63. virtual const char * VPCALL GetName() const = 0;
  64. virtual void VPCALL MinMax( float &min, float &max, const float *src, const int count ) = 0;
  65. virtual void VPCALL MinMax( idVec2 &min, idVec2 &max, const idVec2 *src, const int count ) = 0;
  66. virtual void VPCALL MinMax( idVec3 &min, idVec3 &max, const idVec3 *src, const int count ) = 0;
  67. virtual void VPCALL MinMax( idVec3 &min, idVec3 &max, const idDrawVert *src, const int count ) = 0;
  68. virtual void VPCALL MinMax( idVec3 &min, idVec3 &max, const idDrawVert *src, const triIndex_t *indexes, const int count ) = 0;
  69. virtual void VPCALL Memcpy( void *dst, const void *src, const int count ) = 0;
  70. virtual void VPCALL Memset( void *dst, const int val, const int count ) = 0;
  71. // animation
  72. virtual void VPCALL BlendJoints( idJointQuat *joints, const idJointQuat *blendJoints, const float lerp, const int *index, const int numJoints ) = 0;
  73. virtual void VPCALL BlendJointsFast( idJointQuat *joints, const idJointQuat *blendJoints, const float lerp, const int *index, const int numJoints ) = 0;
  74. virtual void VPCALL ConvertJointQuatsToJointMats( idJointMat *jointMats, const idJointQuat *jointQuats, const int numJoints ) = 0;
  75. virtual void VPCALL ConvertJointMatsToJointQuats( idJointQuat *jointQuats, const idJointMat *jointMats, const int numJoints ) = 0;
  76. virtual void VPCALL TransformJoints( idJointMat *jointMats, const int *parents, const int firstJoint, const int lastJoint ) = 0;
  77. virtual void VPCALL UntransformJoints( idJointMat *jointMats, const int *parents, const int firstJoint, const int lastJoint ) = 0;
  78. };
  79. // pointer to SIMD processor
  80. extern idSIMDProcessor *SIMDProcessor;
  81. #endif /* !__MATH_SIMD_H__ */