Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.3 KiB

  1. //===== Copyright 1996-2010, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: - defines the type fltx4 - Avoid cyclic includion.
  4. //
  5. //===========================================================================//
  6. #ifndef FLTX4_H
  7. #define FLTX4_H
  8. #if defined(GNUC)
  9. #define USE_STDC_FOR_SIMD 0
  10. #else
  11. #define USE_STDC_FOR_SIMD 0
  12. #endif
  13. #if (!defined(PLATFORM_PPC) && (USE_STDC_FOR_SIMD == 0))
  14. #define _SSE1 1
  15. #endif
  16. // I thought about defining a class/union for the SIMD packed floats instead of using fltx4,
  17. // but decided against it because (a) the nature of SIMD code which includes comparisons is to blur
  18. // the relationship between packed floats and packed integer types and (b) not sure that the
  19. // compiler would handle generating good code for the intrinsics.
  20. #if USE_STDC_FOR_SIMD
  21. #error "hello"
  22. typedef union
  23. {
  24. float m128_f32[4];
  25. uint32 m128_u32[4];
  26. } fltx4;
  27. typedef fltx4 i32x4;
  28. typedef fltx4 u32x4;
  29. #ifdef _PS3
  30. typedef fltx4 u32x4;
  31. typedef fltx4 i32x4;
  32. #endif
  33. typedef fltx4 bi32x4;
  34. #elif ( defined( _PS3 ) )
  35. typedef union
  36. {
  37. // This union allows float/int access (which generally shouldn't be done in inner loops)
  38. vec_float4 vmxf;
  39. vec_int4 vmxi;
  40. vec_uint4 vmxui;
  41. #if defined(__SPU__)
  42. vec_uint4 vmxbi;
  43. #else
  44. __vector bool vmxbi;
  45. #endif
  46. struct
  47. {
  48. float x;
  49. float y;
  50. float z;
  51. float w;
  52. };
  53. float m128_f32[4];
  54. uint32 m128_u32[4];
  55. int32 m128_i32[4];
  56. } fltx4_union;
  57. typedef vec_float4 fltx4;
  58. typedef vec_uint4 u32x4;
  59. typedef vec_int4 i32x4;
  60. #if defined(__SPU__)
  61. typedef vec_uint4 bi32x4;
  62. #else
  63. typedef __vector bool bi32x4;
  64. #endif
  65. #define DIFFERENT_NATIVE_VECTOR_TYPES // true if the compiler has different types for float4, uint4, int4, etc
  66. #elif ( defined( _X360 ) )
  67. typedef union
  68. {
  69. // This union allows float/int access (which generally shouldn't be done in inner loops)
  70. __vector4 vmx;
  71. float m128_f32[4];
  72. uint32 m128_u32[4];
  73. } fltx4_union;
  74. typedef __vector4 fltx4;
  75. typedef __vector4 i32x4; // a VMX register; just a way of making it explicit that we're doing integer ops.
  76. typedef __vector4 u32x4; // a VMX register; just a way of making it explicit that we're doing unsigned integer ops.
  77. typedef fltx4 bi32x4;
  78. #else
  79. typedef __m128 fltx4;
  80. typedef __m128 i32x4;
  81. typedef __m128 u32x4;
  82. typedef __m128i shortx8;
  83. typedef fltx4 bi32x4;
  84. #endif
  85. #endif