GLM  0.9.5
simd_vec4.hpp
Go to the documentation of this file.
1 
38 #ifndef GLM_GTX_simd_vec4
39 #define GLM_GTX_simd_vec4
40 
41 // Dependency:
42 #include "../glm.hpp"
43 
44 #if(GLM_ARCH != GLM_ARCH_PURE)
45 
46 #if(GLM_ARCH & GLM_ARCH_SSE2)
47 # include "../detail/intrinsic_common.hpp"
48 # include "../detail/intrinsic_geometric.hpp"
49 # include "../detail/intrinsic_integer.hpp"
50 #else
51 # error "GLM: GLM_GTX_simd_vec4 requires compiler support of SSE2 through intrinsics"
52 #endif
53 
54 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
55 # pragma message("GLM: GLM_GTX_simd_vec4 extension included")
56 #endif
57 
58 
59 // Warning silencer for nameless struct/union.
60 #if (GLM_COMPILER & GLM_COMPILER_VC)
61 # pragma warning(push)
62 # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
63 #endif
64 
65 namespace glm
66 {
67  enum comp
68  {
69  X = 0,
70  R = 0,
71  S = 0,
72  Y = 1,
73  G = 1,
74  T = 1,
75  Z = 2,
76  B = 2,
77  P = 2,
78  W = 3,
79  A = 3,
80  Q = 3
81  };
82 
83 }//namespace glm
84 
85 namespace glm{
86 namespace detail
87 {
90  GLM_ALIGNED_STRUCT(16) fvec4SIMD
91  {
92  enum ctor{null};
93  typedef __m128 value_type;
94  typedef std::size_t size_type;
95  static size_type value_size();
96 
97  typedef fvec4SIMD type;
98  typedef tvec4<bool, highp> bool_type;
99 
100 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
101  union
102  {
103  __m128 Data;
104  struct {float x, y, z, w;};
105  };
106 #else
107  __m128 Data;
108 #endif
109 
111  // Implicit basic constructors
112 
113  fvec4SIMD();
114  fvec4SIMD(__m128 const & Data);
115  fvec4SIMD(fvec4SIMD const & v);
116 
118  // Explicit basic constructors
119 
120  explicit fvec4SIMD(
121  ctor);
122  explicit fvec4SIMD(
123  float const & s);
124  explicit fvec4SIMD(
125  float const & x,
126  float const & y,
127  float const & z,
128  float const & w);
129  explicit fvec4SIMD(
130  vec4 const & v);
131 
134 
135  fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
136  fvec4SIMD(float const & s1, vec2 const & v, float const & s2);
137  fvec4SIMD(float const & s1, float const & s2, vec2 const & v);
138  fvec4SIMD(vec3 const & v, float const & s);
139  fvec4SIMD(float const & s, vec3 const & v);
140  fvec4SIMD(vec2 const & v1, vec2 const & v2);
141  //fvec4SIMD(ivec4SIMD const & v);
142 
144  // Unary arithmetic operators
145 
146  fvec4SIMD& operator= (fvec4SIMD const & v);
147  fvec4SIMD& operator+=(fvec4SIMD const & v);
148  fvec4SIMD& operator-=(fvec4SIMD const & v);
149  fvec4SIMD& operator*=(fvec4SIMD const & v);
150  fvec4SIMD& operator/=(fvec4SIMD const & v);
151 
152  fvec4SIMD& operator+=(float const & s);
153  fvec4SIMD& operator-=(float const & s);
154  fvec4SIMD& operator*=(float const & s);
155  fvec4SIMD& operator/=(float const & s);
156 
157  fvec4SIMD& operator++();
158  fvec4SIMD& operator--();
159 
161  // Swizzle operators
162 
163  template <comp X, comp Y, comp Z, comp W>
164  fvec4SIMD& swizzle();
165  template <comp X, comp Y, comp Z, comp W>
166  fvec4SIMD swizzle() const;
167  template <comp X, comp Y, comp Z>
168  fvec4SIMD swizzle() const;
169  template <comp X, comp Y>
170  fvec4SIMD swizzle() const;
171  template <comp X>
172  fvec4SIMD swizzle() const;
173  };
174 }//namespace detail
175 
176  typedef glm::detail::fvec4SIMD simdVec4;
177 
180 
183  vec4 vec4_cast(
184  detail::fvec4SIMD const & x);
185 
188  detail::fvec4SIMD abs(detail::fvec4SIMD const & x);
189 
192  detail::fvec4SIMD sign(detail::fvec4SIMD const & x);
193 
196  detail::fvec4SIMD floor(detail::fvec4SIMD const & x);
197 
201  detail::fvec4SIMD trunc(detail::fvec4SIMD const & x);
202 
210  detail::fvec4SIMD round(detail::fvec4SIMD const & x);
211 
217  //detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x);
218 
222  detail::fvec4SIMD ceil(detail::fvec4SIMD const & x);
223 
227  detail::fvec4SIMD fract(detail::fvec4SIMD const & x);
228 
233  detail::fvec4SIMD mod(
234  detail::fvec4SIMD const & x,
235  detail::fvec4SIMD const & y);
236 
241  detail::fvec4SIMD mod(
242  detail::fvec4SIMD const & x,
243  float const & y);
244 
250  //detail::fvec4SIMD modf(
251  // detail::fvec4SIMD const & x,
252  // detail::fvec4SIMD & i);
253 
257  detail::fvec4SIMD min(
258  detail::fvec4SIMD const & x,
259  detail::fvec4SIMD const & y);
260 
261  detail::fvec4SIMD min(
262  detail::fvec4SIMD const & x,
263  float const & y);
264 
268  detail::fvec4SIMD max(
269  detail::fvec4SIMD const & x,
270  detail::fvec4SIMD const & y);
271 
272  detail::fvec4SIMD max(
273  detail::fvec4SIMD const & x,
274  float const & y);
275 
280  detail::fvec4SIMD clamp(
281  detail::fvec4SIMD const & x,
282  detail::fvec4SIMD const & minVal,
283  detail::fvec4SIMD const & maxVal);
284 
285  detail::fvec4SIMD clamp(
286  detail::fvec4SIMD const & x,
287  float const & minVal,
288  float const & maxVal);
289 
316  detail::fvec4SIMD mix(
317  detail::fvec4SIMD const & x,
318  detail::fvec4SIMD const & y,
319  detail::fvec4SIMD const & a);
320 
324  detail::fvec4SIMD step(
325  detail::fvec4SIMD const & edge,
326  detail::fvec4SIMD const & x);
327 
328  detail::fvec4SIMD step(
329  float const & edge,
330  detail::fvec4SIMD const & x);
331 
343  detail::fvec4SIMD smoothstep(
344  detail::fvec4SIMD const & edge0,
345  detail::fvec4SIMD const & edge1,
346  detail::fvec4SIMD const & x);
347 
348  detail::fvec4SIMD smoothstep(
349  float const & edge0,
350  float const & edge1,
351  detail::fvec4SIMD const & x);
352 
360  //bvec4 isnan(detail::fvec4SIMD const & x);
361 
369  //bvec4 isinf(detail::fvec4SIMD const & x);
370 
376  //detail::ivec4SIMD floatBitsToInt(detail::fvec4SIMD const & value);
377 
385  //detail::fvec4SIMD intBitsToFloat(detail::ivec4SIMD const & value);
386 
390  detail::fvec4SIMD fma(
391  detail::fvec4SIMD const & a,
392  detail::fvec4SIMD const & b,
393  detail::fvec4SIMD const & c);
394 
405  //detail::fvec4SIMD frexp(detail::fvec4SIMD const & x, detail::ivec4SIMD & exp);
406 
414  //detail::fvec4SIMD ldexp(detail::fvec4SIMD const & x, detail::ivec4SIMD const & exp);
415 
419  float length(
420  detail::fvec4SIMD const & x);
421 
426  float fastLength(
427  detail::fvec4SIMD const & x);
428 
433  float niceLength(
434  detail::fvec4SIMD const & x);
435 
439  detail::fvec4SIMD length4(
440  detail::fvec4SIMD const & x);
441 
446  detail::fvec4SIMD fastLength4(
447  detail::fvec4SIMD const & x);
448 
453  detail::fvec4SIMD niceLength4(
454  detail::fvec4SIMD const & x);
455 
459  float distance(
460  detail::fvec4SIMD const & p0,
461  detail::fvec4SIMD const & p1);
462 
466  detail::fvec4SIMD distance4(
467  detail::fvec4SIMD const & p0,
468  detail::fvec4SIMD const & p1);
469 
473  float simdDot(
474  detail::fvec4SIMD const & x,
475  detail::fvec4SIMD const & y);
476 
480  detail::fvec4SIMD dot4(
481  detail::fvec4SIMD const & x,
482  detail::fvec4SIMD const & y);
483 
487  detail::fvec4SIMD cross(
488  detail::fvec4SIMD const & x,
489  detail::fvec4SIMD const & y);
490 
494  detail::fvec4SIMD normalize(
495  detail::fvec4SIMD const & x);
496 
501  detail::fvec4SIMD fastNormalize(
502  detail::fvec4SIMD const & x);
503 
507  detail::fvec4SIMD simdFaceforward(
508  detail::fvec4SIMD const & N,
509  detail::fvec4SIMD const & I,
510  detail::fvec4SIMD const & Nref);
511 
516  detail::fvec4SIMD reflect(
517  detail::fvec4SIMD const & I,
518  detail::fvec4SIMD const & N);
519 
525  detail::fvec4SIMD refract(
526  detail::fvec4SIMD const & I,
527  detail::fvec4SIMD const & N,
528  float const & eta);
529 
533  detail::fvec4SIMD sqrt(
534  detail::fvec4SIMD const & x);
535 
540  detail::fvec4SIMD niceSqrt(
541  detail::fvec4SIMD const & x);
542 
547  detail::fvec4SIMD fastSqrt(
548  detail::fvec4SIMD const & x);
549 
553  detail::fvec4SIMD inversesqrt(
554  detail::fvec4SIMD const & x);
555 
560  detail::fvec4SIMD fastInversesqrt(
561  detail::fvec4SIMD const & x);
562 
564 }//namespace glm
565 
566 #include "simd_vec4.inl"
567 
568 #if (GLM_COMPILER & GLM_COMPILER_VC)
569 # pragma warning(pop)
570 #endif
571 
572 #endif//(GLM_ARCH != GLM_ARCH_PURE)
573 
574 #endif//GLM_GTX_simd_vec4
GLM_FUNC_DECL genType sqrt(genType const &x)
Returns the positive square root of x.
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:414
GLM_FUNC_DECL genType floor(genType const &x)
Returns a value equal to the nearest integer that is less then or equal to x.
GLM_FUNC_DECL detail::tvec3< T, P > cross(detail::tvec3< T, P > const &x, detail::tvec3< T, P > const &y)
Returns the cross product of x and y.
GLM_FUNC_DECL genTypeT mix(genTypeT const &x, genTypeT const &y, genTypeU const &a)
If genTypeU is a floating scalar or vector: Returns x * (1.0 - a) + y * a, i.e., the linear blend of ...
highp_vec4 vec4
4 components vector of floating-point numbers.
Definition: type_vec.hpp:419
genType fastSqrt(genType const &x)
Faster than the common sqrt function but less accurate.
GLM_FUNC_DECL genType mod(genType const &x, genType const &y)
Modulus.
GLM_FUNC_DECL genType inversesqrt(genType const &x)
Returns the reciprocal of the positive square root of x.
GLM_FUNC_DECL genType normalize(genType const &x)
Returns a vector in the same direction as x but with length of 1.
GLM_FUNC_DECL genType fract(genType const &x)
Return x - floor(x).
GLM_FUNC_DECL genType ceil(genType const &x)
Returns a value equal to the nearest integer that is greater than or equal to x.
GLM_FUNC_DECL genType fma(genType const &a, genType const &b, genType const &c)
Computes and returns a * b + c.
genType fastNormalize(genType const &x)
Faster than the common normalize function but less accurate.
GLM_FUNC_DECL genType step(genType const &edge, genType const &x)
Returns 0.0 if x &lt; edge, otherwise it returns 1.0 for each component of a genType.
GLM_FUNC_DECL genType trunc(genType const &x)
Returns a value equal to the nearest integer to x whose absolute value is not larger than the absolut...
GLM_FUNC_DECL genType::value_type length(genType const &x)
Returns the length of x, i.e., sqrt(x * x).
GLM_FUNC_DECL genType round(genType const &x)
Returns a value equal to the nearest integer to x.
GLM_FUNC_DECL vecType< T, P > refract(vecType< T, P > const &I, vecType< T, P > const &N, T const &eta)
For the incident vector I and surface normal N, and the ratio of indices of refraction eta...
GLM_FUNC_DECL genType abs(genType const &x)
Returns x if x &gt;= 0; otherwise, it returns -x.
GLM_FUNC_DECL genType smoothstep(genType const &edge0, genType const &edge1, genType const &x)
Returns 0.0 if x &lt;= edge0 and 1.0 if x &gt;= edge1 and performs smooth Hermite interpolation between 0 a...
GLM_FUNC_DECL genType clamp(genType const &x, genType const &minVal, genType const &maxVal)
Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal an...
GLM_FUNC_DECL genType reflect(genType const &I, genType const &N)
For the incident vector I and surface orientation N, returns the reflection direction : result = I - ...
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
Returns y if x &lt; y; otherwise, it returns x.
GLM_FUNC_DECL genType::value_type distance(genType const &p0, genType const &p1)
Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
GLM_FUNC_DECL genType sign(genType const &x)
Returns 1.0 if x &gt; 0, 0.0 if x == 0, or -1.0 if x &lt; 0.
genType::value_type fastLength(genType const &x)
Faster than the common length function but less accurate.
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
Returns y if y &lt; x; otherwise, it returns x.
highp_vec2 vec2
2 components vector of floating-point numbers.
Definition: type_vec.hpp:409