Team Fortress 2 Source Code as on 22/4/2020
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.

97 lines
2.1 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. __vector bool vmxbi;
  42. struct
  43. {
  44. float x;
  45. float y;
  46. float z;
  47. float w;
  48. };
  49. float m128_f32[4];
  50. uint32 m128_u32[4];
  51. int32 m128_i32[4];
  52. } fltx4_union;
  53. typedef vec_float4 fltx4;
  54. typedef vec_uint4 u32x4;
  55. typedef vec_int4 i32x4;
  56. typedef __vector bool bi32x4;
  57. #define DIFFERENT_NATIVE_VECTOR_TYPES // true if the compiler has different types for float4, uint4, int4, etc
  58. #elif ( defined( _X360 ) )
  59. typedef union
  60. {
  61. // This union allows float/int access (which generally shouldn't be done in inner loops)
  62. __vector4 vmx;
  63. float m128_f32[4];
  64. uint32 m128_u32[4];
  65. } fltx4_union;
  66. typedef __vector4 fltx4;
  67. typedef __vector4 i32x4; // a VMX register; just a way of making it explicit that we're doing integer ops.
  68. typedef __vector4 u32x4; // a VMX register; just a way of making it explicit that we're doing unsigned integer ops.
  69. typedef fltx4 bi32x4;
  70. #else
  71. typedef __m128 fltx4;
  72. typedef __m128 i32x4;
  73. typedef __m128 u32x4;
  74. typedef fltx4 bi32x4;
  75. #endif
  76. #endif