0.9.6
simd_vec4.hpp
Go to the documentation of this file.
1 
42 #pragma once
43 
44 // Dependency:
45 #include "../glm.hpp"
46 
47 #if(GLM_ARCH != GLM_ARCH_PURE)
48 
49 #if(GLM_ARCH & GLM_ARCH_SSE2)
50 # include "../detail/intrinsic_common.hpp"
51 # include "../detail/intrinsic_geometric.hpp"
52 # include "../detail/intrinsic_integer.hpp"
53 #else
54 # error "GLM: GLM_GTX_simd_vec4 requires compiler support of SSE2 through intrinsics"
55 #endif
56 
57 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
58 # pragma message("GLM: GLM_GTX_simd_vec4 extension included")
59 #endif
60 
61 
62 // Warning silencer for nameless struct/union.
63 #if (GLM_COMPILER & GLM_COMPILER_VC)
64 # pragma warning(push)
65 # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
66 #endif
67 
68 namespace glm
69 {
70  enum comp
71  {
72  X = 0,
73  R = 0,
74  S = 0,
75  Y = 1,
76  G = 1,
77  T = 1,
78  Z = 2,
79  B = 2,
80  P = 2,
81  W = 3,
82  A = 3,
83  Q = 3
84  };
85 
86 }//namespace glm
87 
88 namespace glm{
89 namespace detail
90 {
93  GLM_ALIGNED_STRUCT(16) fvec4SIMD
94  {
95  typedef __m128 value_type;
96  typedef std::size_t size_type;
97  static size_type value_size();
98 
99  typedef fvec4SIMD type;
100  typedef tvec4<bool, highp> bool_type;
101 
102 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
103  union
104  {
105  __m128 Data;
106  struct {float x, y, z, w;};
107  };
108 #else
109  __m128 Data;
110 #endif
111 
113  // Implicit basic constructors
114 
115  fvec4SIMD();
116  fvec4SIMD(__m128 const & Data);
117  fvec4SIMD(fvec4SIMD const & v);
118 
120  // Explicit basic constructors
121 
122  explicit fvec4SIMD(
123  ctor);
124  explicit fvec4SIMD(
125  float const & s);
126  explicit fvec4SIMD(
127  float const & x,
128  float const & y,
129  float const & z,
130  float const & w);
131  explicit fvec4SIMD(
132  vec4 const & v);
133 
136 
137  fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
138  fvec4SIMD(float const & s1, vec2 const & v, float const & s2);
139  fvec4SIMD(float const & s1, float const & s2, vec2 const & v);
140  fvec4SIMD(vec3 const & v, float const & s);
141  fvec4SIMD(float const & s, vec3 const & v);
142  fvec4SIMD(vec2 const & v1, vec2 const & v2);
143  //fvec4SIMD(ivec4SIMD const & v);
144 
146  // Unary arithmetic operators
147 
148  fvec4SIMD& operator= (fvec4SIMD const & v);
149  fvec4SIMD& operator+=(fvec4SIMD const & v);
150  fvec4SIMD& operator-=(fvec4SIMD const & v);
151  fvec4SIMD& operator*=(fvec4SIMD const & v);
152  fvec4SIMD& operator/=(fvec4SIMD const & v);
153 
154  fvec4SIMD& operator+=(float const & s);
155  fvec4SIMD& operator-=(float const & s);
156  fvec4SIMD& operator*=(float const & s);
157  fvec4SIMD& operator/=(float const & s);
158 
159  fvec4SIMD& operator++();
160  fvec4SIMD& operator--();
161 
163  // Swizzle operators
164 
165  template <comp X, comp Y, comp Z, comp W>
166  fvec4SIMD& swizzle();
167  template <comp X, comp Y, comp Z, comp W>
168  fvec4SIMD swizzle() const;
169  template <comp X, comp Y, comp Z>
170  fvec4SIMD swizzle() const;
171  template <comp X, comp Y>
172  fvec4SIMD swizzle() const;
173  template <comp X>
174  fvec4SIMD swizzle() const;
175  };
176 }//namespace detail
177 
178  typedef glm::detail::fvec4SIMD simdVec4;
179 
182 
185  vec4 vec4_cast(
186  detail::fvec4SIMD const & x);
187 
190  detail::fvec4SIMD abs(detail::fvec4SIMD const & x);
191 
194  detail::fvec4SIMD sign(detail::fvec4SIMD const & x);
195 
198  detail::fvec4SIMD floor(detail::fvec4SIMD const & x);
199 
203  detail::fvec4SIMD trunc(detail::fvec4SIMD const & x);
204 
212  detail::fvec4SIMD round(detail::fvec4SIMD const & x);
213 
219  //detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x);
220 
224  detail::fvec4SIMD ceil(detail::fvec4SIMD const & x);
225 
229  detail::fvec4SIMD fract(detail::fvec4SIMD const & x);
230 
235  detail::fvec4SIMD mod(
236  detail::fvec4SIMD const & x,
237  detail::fvec4SIMD const & y);
238 
243  detail::fvec4SIMD mod(
244  detail::fvec4SIMD const & x,
245  float const & y);
246 
252  //detail::fvec4SIMD modf(
253  // detail::fvec4SIMD const & x,
254  // detail::fvec4SIMD & i);
255 
259  detail::fvec4SIMD min(
260  detail::fvec4SIMD const & x,
261  detail::fvec4SIMD const & y);
262 
263  detail::fvec4SIMD min(
264  detail::fvec4SIMD const & x,
265  float const & y);
266 
270  detail::fvec4SIMD max(
271  detail::fvec4SIMD const & x,
272  detail::fvec4SIMD const & y);
273 
274  detail::fvec4SIMD max(
275  detail::fvec4SIMD const & x,
276  float const & y);
277 
282  detail::fvec4SIMD clamp(
283  detail::fvec4SIMD const & x,
284  detail::fvec4SIMD const & minVal,
285  detail::fvec4SIMD const & maxVal);
286 
287  detail::fvec4SIMD clamp(
288  detail::fvec4SIMD const & x,
289  float const & minVal,
290  float const & maxVal);
291 
318  detail::fvec4SIMD mix(
319  detail::fvec4SIMD const & x,
320  detail::fvec4SIMD const & y,
321  detail::fvec4SIMD const & a);
322 
326  detail::fvec4SIMD step(
327  detail::fvec4SIMD const & edge,
328  detail::fvec4SIMD const & x);
329 
330  detail::fvec4SIMD step(
331  float const & edge,
332  detail::fvec4SIMD const & x);
333 
345  detail::fvec4SIMD smoothstep(
346  detail::fvec4SIMD const & edge0,
347  detail::fvec4SIMD const & edge1,
348  detail::fvec4SIMD const & x);
349 
350  detail::fvec4SIMD smoothstep(
351  float const & edge0,
352  float const & edge1,
353  detail::fvec4SIMD const & x);
354 
362  //bvec4 isnan(detail::fvec4SIMD const & x);
363 
371  //bvec4 isinf(detail::fvec4SIMD const & x);
372 
378  //detail::ivec4SIMD floatBitsToInt(detail::fvec4SIMD const & value);
379 
387  //detail::fvec4SIMD intBitsToFloat(detail::ivec4SIMD const & value);
388 
392  detail::fvec4SIMD fma(
393  detail::fvec4SIMD const & a,
394  detail::fvec4SIMD const & b,
395  detail::fvec4SIMD const & c);
396 
407  //detail::fvec4SIMD frexp(detail::fvec4SIMD const & x, detail::ivec4SIMD & exp);
408 
416  //detail::fvec4SIMD ldexp(detail::fvec4SIMD const & x, detail::ivec4SIMD const & exp);
417 
421  float length(
422  detail::fvec4SIMD const & x);
423 
428  float fastLength(
429  detail::fvec4SIMD const & x);
430 
435  float niceLength(
436  detail::fvec4SIMD const & x);
437 
441  detail::fvec4SIMD length4(
442  detail::fvec4SIMD const & x);
443 
448  detail::fvec4SIMD fastLength4(
449  detail::fvec4SIMD const & x);
450 
455  detail::fvec4SIMD niceLength4(
456  detail::fvec4SIMD const & x);
457 
461  float distance(
462  detail::fvec4SIMD const & p0,
463  detail::fvec4SIMD const & p1);
464 
468  detail::fvec4SIMD distance4(
469  detail::fvec4SIMD const & p0,
470  detail::fvec4SIMD const & p1);
471 
475  float simdDot(
476  detail::fvec4SIMD const & x,
477  detail::fvec4SIMD const & y);
478 
482  detail::fvec4SIMD dot4(
483  detail::fvec4SIMD const & x,
484  detail::fvec4SIMD const & y);
485 
489  detail::fvec4SIMD cross(
490  detail::fvec4SIMD const & x,
491  detail::fvec4SIMD const & y);
492 
496  detail::fvec4SIMD normalize(
497  detail::fvec4SIMD const & x);
498 
503  detail::fvec4SIMD fastNormalize(
504  detail::fvec4SIMD const & x);
505 
509  detail::fvec4SIMD simdFaceforward(
510  detail::fvec4SIMD const & N,
511  detail::fvec4SIMD const & I,
512  detail::fvec4SIMD const & Nref);
513 
518  detail::fvec4SIMD reflect(
519  detail::fvec4SIMD const & I,
520  detail::fvec4SIMD const & N);
521 
527  detail::fvec4SIMD refract(
528  detail::fvec4SIMD const & I,
529  detail::fvec4SIMD const & N,
530  float const & eta);
531 
535  detail::fvec4SIMD sqrt(
536  detail::fvec4SIMD const & x);
537 
542  detail::fvec4SIMD niceSqrt(
543  detail::fvec4SIMD const & x);
544 
549  detail::fvec4SIMD fastSqrt(
550  detail::fvec4SIMD const & x);
551 
555  detail::fvec4SIMD inversesqrt(
556  detail::fvec4SIMD const & x);
557 
562  detail::fvec4SIMD fastInversesqrt(
563  detail::fvec4SIMD const & x);
564 
566 }//namespace glm
567 
568 #include "simd_vec4.inl"
569 
570 #if (GLM_COMPILER & GLM_COMPILER_VC)
571 # pragma warning(pop)
572 #endif
573 
574 #endif//(GLM_ARCH != GLM_ARCH_PURE)
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...
GLM_FUNC_DECL vecType< T, P > inversesqrt(vecType< T, P > const &v)
Returns the reciprocal of the positive square root of v.
highp_vec4 vec4
4 components vector of floating-point numbers.
Definition: type_vec.hpp:402
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 genType fastSqrt(genType x)
Faster than the common sqrt function but less accurate.
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 genType min(genType x, genType y)
Returns y if y < x; otherwise, it returns x.
GLM_FUNC_DECL genType mod(genType x, genType y)
Modulus.
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 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 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 fma(genType const &a, genType const &b, genType const &c)
Computes and returns a * b + c.
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.
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 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 tvec3< T, P > cross(tvec3< T, P > const &x, tvec3< T, P > const &y)
Returns the cross product of x and y.
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 genType max(genType x, genType y)
Returns y if x < y; otherwise, it returns x.
GLM_FUNC_DECL genType fastNormalize(genType const &x)
Faster than the common normalize function but less accurate.
Definition: _noise.hpp:39
GLM_FUNC_DECL genType abs(genType x)
Returns x if x >= 0; otherwise, it returns -x.
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:397
highp_vec2 vec2
2 components vector of floating-point numbers.
Definition: type_vec.hpp:392
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &v)
Returns the positive square root of v.
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 fastLength(genType x)
Faster than the common length function but less accurate.
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 vecType< T, P > round(vecType< T, P > const &x)
Returns a value equal to the nearest integer to x.