0.9.6
simd_vec4.hpp
Go to the documentation of this file.
1 
38 #pragma once
39 
40 // Dependency:
41 #include "../glm.hpp"
42 
43 #if(GLM_ARCH != GLM_ARCH_PURE)
44 
45 #if(GLM_ARCH & GLM_ARCH_SSE2)
46 # include "../detail/intrinsic_common.hpp"
47 # include "../detail/intrinsic_geometric.hpp"
48 # include "../detail/intrinsic_integer.hpp"
49 #else
50 # error "GLM: GLM_GTX_simd_vec4 requires compiler support of SSE2 through intrinsics"
51 #endif
52 
53 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
54 # pragma message("GLM: GLM_GTX_simd_vec4 extension included")
55 #endif
56 
57 
58 // Warning silencer for nameless struct/union.
59 #if (GLM_COMPILER & GLM_COMPILER_VC)
60 # pragma warning(push)
61 # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
62 #endif
63 
64 namespace glm
65 {
66  enum comp
67  {
68  X = 0,
69  R = 0,
70  S = 0,
71  Y = 1,
72  G = 1,
73  T = 1,
74  Z = 2,
75  B = 2,
76  P = 2,
77  W = 3,
78  A = 3,
79  Q = 3
80  };
81 
82 }//namespace glm
83 
84 namespace glm{
85 namespace detail
86 {
89  GLM_ALIGNED_STRUCT(16) fvec4SIMD
90  {
91  typedef __m128 value_type;
92  typedef std::size_t size_type;
93  static size_type value_size();
94 
95  typedef fvec4SIMD type;
96  typedef tvec4<bool, highp> bool_type;
97 
98 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
99  union
100  {
101  __m128 Data;
102  struct {float x, y, z, w;};
103  };
104 #else
105  __m128 Data;
106 #endif
107 
109  // Implicit basic constructors
110 
111  fvec4SIMD();
112  fvec4SIMD(__m128 const & Data);
113  fvec4SIMD(fvec4SIMD const & v);
114 
116  // Explicit basic constructors
117 
118  explicit fvec4SIMD(
119  ctor);
120  explicit fvec4SIMD(
121  float const & s);
122  explicit fvec4SIMD(
123  float const & x,
124  float const & y,
125  float const & z,
126  float const & w);
127  explicit fvec4SIMD(
128  vec4 const & v);
129 
132 
133  fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
134  fvec4SIMD(float const & s1, vec2 const & v, float const & s2);
135  fvec4SIMD(float const & s1, float const & s2, vec2 const & v);
136  fvec4SIMD(vec3 const & v, float const & s);
137  fvec4SIMD(float const & s, vec3 const & v);
138  fvec4SIMD(vec2 const & v1, vec2 const & v2);
139  //fvec4SIMD(ivec4SIMD const & v);
140 
142  // Unary arithmetic operators
143 
144  fvec4SIMD& operator= (fvec4SIMD const & v);
145  fvec4SIMD& operator+=(fvec4SIMD const & v);
146  fvec4SIMD& operator-=(fvec4SIMD const & v);
147  fvec4SIMD& operator*=(fvec4SIMD const & v);
148  fvec4SIMD& operator/=(fvec4SIMD const & v);
149 
150  fvec4SIMD& operator+=(float const & s);
151  fvec4SIMD& operator-=(float const & s);
152  fvec4SIMD& operator*=(float const & s);
153  fvec4SIMD& operator/=(float const & s);
154 
155  fvec4SIMD& operator++();
156  fvec4SIMD& operator--();
157 
159  // Swizzle operators
160 
161  template <comp X, comp Y, comp Z, comp W>
162  fvec4SIMD& swizzle();
163  template <comp X, comp Y, comp Z, comp W>
164  fvec4SIMD swizzle() const;
165  template <comp X, comp Y, comp Z>
166  fvec4SIMD swizzle() const;
167  template <comp X, comp Y>
168  fvec4SIMD swizzle() const;
169  template <comp X>
170  fvec4SIMD swizzle() const;
171  };
172 }//namespace detail
173 
174  typedef glm::detail::fvec4SIMD simdVec4;
175 
178 
181  vec4 vec4_cast(
182  detail::fvec4SIMD const & x);
183 
186  detail::fvec4SIMD abs(detail::fvec4SIMD const & x);
187 
190  detail::fvec4SIMD sign(detail::fvec4SIMD const & x);
191 
194  detail::fvec4SIMD floor(detail::fvec4SIMD const & x);
195 
199  detail::fvec4SIMD trunc(detail::fvec4SIMD const & x);
200 
208  detail::fvec4SIMD round(detail::fvec4SIMD const & x);
209 
215  //detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x);
216 
220  detail::fvec4SIMD ceil(detail::fvec4SIMD const & x);
221 
225  detail::fvec4SIMD fract(detail::fvec4SIMD const & x);
226 
231  detail::fvec4SIMD mod(
232  detail::fvec4SIMD const & x,
233  detail::fvec4SIMD const & y);
234 
239  detail::fvec4SIMD mod(
240  detail::fvec4SIMD const & x,
241  float const & y);
242 
248  //detail::fvec4SIMD modf(
249  // detail::fvec4SIMD const & x,
250  // detail::fvec4SIMD & i);
251 
255  detail::fvec4SIMD min(
256  detail::fvec4SIMD const & x,
257  detail::fvec4SIMD const & y);
258 
259  detail::fvec4SIMD min(
260  detail::fvec4SIMD const & x,
261  float const & y);
262 
266  detail::fvec4SIMD max(
267  detail::fvec4SIMD const & x,
268  detail::fvec4SIMD const & y);
269 
270  detail::fvec4SIMD max(
271  detail::fvec4SIMD const & x,
272  float const & y);
273 
278  detail::fvec4SIMD clamp(
279  detail::fvec4SIMD const & x,
280  detail::fvec4SIMD const & minVal,
281  detail::fvec4SIMD const & maxVal);
282 
283  detail::fvec4SIMD clamp(
284  detail::fvec4SIMD const & x,
285  float const & minVal,
286  float const & maxVal);
287 
314  detail::fvec4SIMD mix(
315  detail::fvec4SIMD const & x,
316  detail::fvec4SIMD const & y,
317  detail::fvec4SIMD const & a);
318 
322  detail::fvec4SIMD step(
323  detail::fvec4SIMD const & edge,
324  detail::fvec4SIMD const & x);
325 
326  detail::fvec4SIMD step(
327  float const & edge,
328  detail::fvec4SIMD const & x);
329 
341  detail::fvec4SIMD smoothstep(
342  detail::fvec4SIMD const & edge0,
343  detail::fvec4SIMD const & edge1,
344  detail::fvec4SIMD const & x);
345 
346  detail::fvec4SIMD smoothstep(
347  float const & edge0,
348  float const & edge1,
349  detail::fvec4SIMD const & x);
350 
358  //bvec4 isnan(detail::fvec4SIMD const & x);
359 
367  //bvec4 isinf(detail::fvec4SIMD const & x);
368 
374  //detail::ivec4SIMD floatBitsToInt(detail::fvec4SIMD const & value);
375 
383  //detail::fvec4SIMD intBitsToFloat(detail::ivec4SIMD const & value);
384 
388  detail::fvec4SIMD fma(
389  detail::fvec4SIMD const & a,
390  detail::fvec4SIMD const & b,
391  detail::fvec4SIMD const & c);
392 
403  //detail::fvec4SIMD frexp(detail::fvec4SIMD const & x, detail::ivec4SIMD & exp);
404 
412  //detail::fvec4SIMD ldexp(detail::fvec4SIMD const & x, detail::ivec4SIMD const & exp);
413 
417  float length(
418  detail::fvec4SIMD const & x);
419 
424  float fastLength(
425  detail::fvec4SIMD const & x);
426 
431  float niceLength(
432  detail::fvec4SIMD const & x);
433 
437  detail::fvec4SIMD length4(
438  detail::fvec4SIMD const & x);
439 
444  detail::fvec4SIMD fastLength4(
445  detail::fvec4SIMD const & x);
446 
451  detail::fvec4SIMD niceLength4(
452  detail::fvec4SIMD const & x);
453 
457  float distance(
458  detail::fvec4SIMD const & p0,
459  detail::fvec4SIMD const & p1);
460 
464  detail::fvec4SIMD distance4(
465  detail::fvec4SIMD const & p0,
466  detail::fvec4SIMD const & p1);
467 
471  float simdDot(
472  detail::fvec4SIMD const & x,
473  detail::fvec4SIMD const & y);
474 
478  detail::fvec4SIMD dot4(
479  detail::fvec4SIMD const & x,
480  detail::fvec4SIMD const & y);
481 
485  detail::fvec4SIMD cross(
486  detail::fvec4SIMD const & x,
487  detail::fvec4SIMD const & y);
488 
492  detail::fvec4SIMD normalize(
493  detail::fvec4SIMD const & x);
494 
499  detail::fvec4SIMD fastNormalize(
500  detail::fvec4SIMD const & x);
501 
505  detail::fvec4SIMD simdFaceforward(
506  detail::fvec4SIMD const & N,
507  detail::fvec4SIMD const & I,
508  detail::fvec4SIMD const & Nref);
509 
514  detail::fvec4SIMD reflect(
515  detail::fvec4SIMD const & I,
516  detail::fvec4SIMD const & N);
517 
523  detail::fvec4SIMD refract(
524  detail::fvec4SIMD const & I,
525  detail::fvec4SIMD const & N,
526  float const & eta);
527 
531  detail::fvec4SIMD sqrt(
532  detail::fvec4SIMD const & x);
533 
538  detail::fvec4SIMD niceSqrt(
539  detail::fvec4SIMD const & x);
540 
545  detail::fvec4SIMD fastSqrt(
546  detail::fvec4SIMD const & x);
547 
551  detail::fvec4SIMD inversesqrt(
552  detail::fvec4SIMD const & x);
553 
558  detail::fvec4SIMD fastInversesqrt(
559  detail::fvec4SIMD const & x);
560 
562 }//namespace glm
563 
564 #include "simd_vec4.inl"
565 
566 #if (GLM_COMPILER & GLM_COMPILER_VC)
567 # pragma warning(pop)
568 #endif
569 
570 #endif//(GLM_ARCH != GLM_ARCH_PURE)
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
GLM_FUNC_DECL vecType< T, P > normalize(vecType< T, P > const &x)
Returns a vector in the same direction as x but with length of 1.
GLM_FUNC_DECL genType mod(genType x, genType y)
Modulus.
GLM_FUNC_DECL genType fastNormalize(genType const &x)
Faster than the common normalize function but less accurate.
GLM_FUNC_DECL genType step(genType edge, genType x)
Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
highp_vec2 vec2
2 components vector of floating-point numbers.
Definition: type_vec.hpp:388
GLM_FUNC_DECL genType max(genType x, genType y)
Returns y if x < y; otherwise, it returns x.
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:393
GLM_FUNC_DECL genType::value_type fastLength(genType const &x)
Faster than the common length function but less accurate.
GLM_FUNC_DECL genType abs(genType x)
Returns x if x >= 0; otherwise, it returns -x.
GLM_FUNC_DECL vecType< T, P > inversesqrt(vecType< T, P > const &v)
Returns the reciprocal of the positive square root of v.
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &v)
Returns the positive square root of v.
highp_vec4 vec4
4 components vector of floating-point numbers.
Definition: type_vec.hpp:398
GLM_FUNC_DECL genType min(genType x, genType y)
Returns y if y < x; otherwise, it returns x.
GLM_FUNC_DECL vecType< T, P > refract(vecType< T, P > const &I, vecType< T, P > const &N, T eta)
For the incident vector I and surface normal N, and the ratio of indices of refraction eta...
Definition: _noise.hpp:31
GLM_FUNC_DECL genType fma(genType const &a, genType const &b, genType const &c)
Computes and returns a * b + c.
GLM_FUNC_DECL vecType< T, P > mix(vecType< T, P > const &x, vecType< T, P > const &y, vecType< U, P > const &a)
If genTypeU is a floating scalar or vector: Returns x * (1.0 - a) + y * a, i.e., the linear blend of ...
GLM_FUNC_DECL vecType< T, P > trunc(vecType< T, P > const &x)
Returns a value equal to the nearest integer to x whose absolute value is not larger than the absolut...
GLM_FUNC_DECL vecType< T, P > ceil(vecType< T, P > const &x)
Returns a value equal to the nearest integer that is greater than or equal to x.
GLM_FUNC_DECL genType fastSqrt(genType x)
Faster than the common sqrt function but less accurate.
GLM_FUNC_DECL genType clamp(genType x, genType minVal, genType maxVal)
Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal an...
GLM_FUNC_DECL vecType< T, P > round(vecType< T, P > const &x)
Returns a value equal to the nearest integer to x.
GLM_FUNC_DECL vecType< T, P > sign(vecType< T, P > const &x)
Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
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 vecType< T, P > floor(vecType< T, P > const &x)
Returns a value equal to the nearest integer that is less then or equal to x.
GLM_FUNC_DECL T distance(vecType< T, P > const &p0, vecType< T, P > const &p1)
Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
GLM_FUNC_DECL genType fract(genType x)
Return x - floor(x).
GLM_FUNC_DECL genType smoothstep(genType edge0, genType edge1, genType x)
Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 a...
GLM_FUNC_DECL tvec3< T, P > cross(tvec3< T, P > const &x, tvec3< T, P > const &y)
Returns the cross product of x and y.