| 0.9.7

- Main Page
- Modules
- Files

- File List

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 float value_type;
96 typedef std::size_t size_type;
97
98 typedef fvec4SIMD type;
99 typedef tvec4<float, defaultp> pure_type;
100 typedef tvec4<bool, highp> bool_type;
101
102 # ifdef GLM_META_PROG_HELPERS
103 static GLM_RELAXED_CONSTEXPR length_t components = 4;
104 static GLM_RELAXED_CONSTEXPR precision prec = defaultp;
105 # endif//GLM_META_PROG_HELPERS
106
107 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
108 union
109 {
110 __m128 Data;
111 struct {float x, y, z, w;};
112 };
113 #else
114 __m128 Data;
115 #endif
116
118 // Implicit basic constructors
119
120 fvec4SIMD() GLM_DEFAULT_CTOR;
121 fvec4SIMD(fvec4SIMD const & v) GLM_DEFAULT;
122 fvec4SIMD(__m128 const & Data);
123
125 // Explicit basic constructors
126
127 explicit fvec4SIMD(
128 ctor);
129 explicit fvec4SIMD(
130 float const & s);
131 explicit fvec4SIMD(
132 float const & x,
133 float const & y,
134 float const & z,
135 float const & w);
136 explicit fvec4SIMD(
137 vec4 const & v);
138
141
142 fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
143 fvec4SIMD(float const & s1, vec2 const & v, float const & s2);
144 fvec4SIMD(float const & s1, float const & s2, vec2 const & v);
145 fvec4SIMD(vec3 const & v, float const & s);
146 fvec4SIMD(float const & s, vec3 const & v);
147 fvec4SIMD(vec2 const & v1, vec2 const & v2);
148 //fvec4SIMD(ivec4SIMD const & v);
149
151 // Unary arithmetic operators
152
153 fvec4SIMD& operator= (fvec4SIMD const & v) GLM_DEFAULT;
154 fvec4SIMD& operator+=(fvec4SIMD const & v);
155 fvec4SIMD& operator-=(fvec4SIMD const & v);
156 fvec4SIMD& operator*=(fvec4SIMD const & v);
157 fvec4SIMD& operator/=(fvec4SIMD const & v);
158
159 fvec4SIMD& operator+=(float const & s);
160 fvec4SIMD& operator-=(float const & s);
161 fvec4SIMD& operator*=(float const & s);
162 fvec4SIMD& operator/=(float const & s);
163
164 fvec4SIMD& operator++();
165 fvec4SIMD& operator--();
166
168 // Swizzle operators
169
170 template <comp X, comp Y, comp Z, comp W>
171 fvec4SIMD& swizzle();
172 template <comp X, comp Y, comp Z, comp W>
173 fvec4SIMD swizzle() const;
174 template <comp X, comp Y, comp Z>
175 fvec4SIMD swizzle() const;
176 template <comp X, comp Y>
177 fvec4SIMD swizzle() const;
178 template <comp X>
179 fvec4SIMD swizzle() const;
180 };
181 }//namespace detail
182
183 typedef glm::detail::fvec4SIMD simdVec4;
184
187
190 vec4 vec4_cast(
191 detail::fvec4SIMD const & x);
192
195 detail::fvec4SIMD abs(detail::fvec4SIMD const & x);
196
199 detail::fvec4SIMD sign(detail::fvec4SIMD const & x);
200
203 detail::fvec4SIMD floor(detail::fvec4SIMD const & x);
204
208 detail::fvec4SIMD trunc(detail::fvec4SIMD const & x);
209
217 detail::fvec4SIMD round(detail::fvec4SIMD const & x);
218
224 //detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x);
225
229 detail::fvec4SIMD ceil(detail::fvec4SIMD const & x);
230
234 detail::fvec4SIMD fract(detail::fvec4SIMD const & x);
235
240 detail::fvec4SIMD mod(
241 detail::fvec4SIMD const & x,
242 detail::fvec4SIMD const & y);
243
248 detail::fvec4SIMD mod(
249 detail::fvec4SIMD const & x,
250 float const & y);
251
257 //detail::fvec4SIMD modf(
258 // detail::fvec4SIMD const & x,
259 // detail::fvec4SIMD & i);
260
264 detail::fvec4SIMD min(
265 detail::fvec4SIMD const & x,
266 detail::fvec4SIMD const & y);
267
268 detail::fvec4SIMD min(
269 detail::fvec4SIMD const & x,
270 float const & y);
271
275 detail::fvec4SIMD max(
276 detail::fvec4SIMD const & x,
277 detail::fvec4SIMD const & y);
278
279 detail::fvec4SIMD max(
280 detail::fvec4SIMD const & x,
281 float const & y);
282
287 detail::fvec4SIMD clamp(
288 detail::fvec4SIMD const & x,
289 detail::fvec4SIMD const & minVal,
290 detail::fvec4SIMD const & maxVal);
291
292 detail::fvec4SIMD clamp(
293 detail::fvec4SIMD const & x,
294 float const & minVal,
295 float const & maxVal);
296
323 detail::fvec4SIMD mix(
324 detail::fvec4SIMD const & x,
325 detail::fvec4SIMD const & y,
326 detail::fvec4SIMD const & a);
327
331 detail::fvec4SIMD step(
332 detail::fvec4SIMD const & edge,
333 detail::fvec4SIMD const & x);
334
335 detail::fvec4SIMD step(
336 float const & edge,
337 detail::fvec4SIMD const & x);
338
350 detail::fvec4SIMD smoothstep(
351 detail::fvec4SIMD const & edge0,
352 detail::fvec4SIMD const & edge1,
353 detail::fvec4SIMD const & x);
354
355 detail::fvec4SIMD smoothstep(
356 float const & edge0,
357 float const & edge1,
358 detail::fvec4SIMD const & x);
359
367 //bvec4 isnan(detail::fvec4SIMD const & x);
368
376 //bvec4 isinf(detail::fvec4SIMD const & x);
377
383 //detail::ivec4SIMD floatBitsToInt(detail::fvec4SIMD const & value);
384
392 //detail::fvec4SIMD intBitsToFloat(detail::ivec4SIMD const & value);
393
397 detail::fvec4SIMD fma(
398 detail::fvec4SIMD const & a,
399 detail::fvec4SIMD const & b,
400 detail::fvec4SIMD const & c);
401
412 //detail::fvec4SIMD frexp(detail::fvec4SIMD const & x, detail::ivec4SIMD & exp);
413
421 //detail::fvec4SIMD ldexp(detail::fvec4SIMD const & x, detail::ivec4SIMD const & exp);
422
426 float length(
427 detail::fvec4SIMD const & x);
428
433 float fastLength(
434 detail::fvec4SIMD const & x);
435
440 float niceLength(
441 detail::fvec4SIMD const & x);
442
446 detail::fvec4SIMD length4(
447 detail::fvec4SIMD const & x);
448
453 detail::fvec4SIMD fastLength4(
454 detail::fvec4SIMD const & x);
455
460 detail::fvec4SIMD niceLength4(
461 detail::fvec4SIMD const & x);
462
466 float distance(
467 detail::fvec4SIMD const & p0,
468 detail::fvec4SIMD const & p1);
469
473 detail::fvec4SIMD distance4(
474 detail::fvec4SIMD const & p0,
475 detail::fvec4SIMD const & p1);
476
480 float simdDot(
481 detail::fvec4SIMD const & x,
482 detail::fvec4SIMD const & y);
483
487 detail::fvec4SIMD dot4(
488 detail::fvec4SIMD const & x,
489 detail::fvec4SIMD const & y);
490
494 detail::fvec4SIMD cross(
495 detail::fvec4SIMD const & x,
496 detail::fvec4SIMD const & y);
497
501 detail::fvec4SIMD normalize(
502 detail::fvec4SIMD const & x);
503
508 detail::fvec4SIMD fastNormalize(
509 detail::fvec4SIMD const & x);
510
514 detail::fvec4SIMD simdFaceforward(
515 detail::fvec4SIMD const & N,
516 detail::fvec4SIMD const & I,
517 detail::fvec4SIMD const & Nref);
518
523 detail::fvec4SIMD reflect(
524 detail::fvec4SIMD const & I,
525 detail::fvec4SIMD const & N);
526
532 detail::fvec4SIMD refract(
533 detail::fvec4SIMD const & I,
534 detail::fvec4SIMD const & N,
535 float const & eta);
536
540 detail::fvec4SIMD sqrt(
541 detail::fvec4SIMD const & x);
542
547 detail::fvec4SIMD niceSqrt(
548 detail::fvec4SIMD const & x);
549
554 detail::fvec4SIMD fastSqrt(
555 detail::fvec4SIMD const & x);
556
560 detail::fvec4SIMD inversesqrt(
561 detail::fvec4SIMD const & x);
562
567 detail::fvec4SIMD fastInversesqrt(
568 detail::fvec4SIMD const & x);
569
571 }//namespace glm
572
573 #include "simd_vec4.inl"
574
575 #if (GLM_COMPILER & GLM_COMPILER_VC)
576 # pragma warning(pop)
577 #endif
578
579 #endif//(GLM_ARCH != GLM_ARCH_PURE)
glm::distance
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::clamp
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::fma
GLM_FUNC_DECL genType fma(genType const &a, genType const &b, genType const &c)
Computes and returns a * b + c.
glm::floor
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::fract
GLM_FUNC_DECL genType fract(genType x)
Return x - floor(x).
glm::length
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::fastNormalize
GLM_FUNC_DECL genType fastNormalize(genType const &x)
Faster than the common normalize function but less accurate.
glm::vec2
highp_vec2 vec2
2 components vector of floating-point numbers.
Definition: type_vec.hpp:390
glm::ceil
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::smoothstep
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::trunc
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::refract
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::fastLength
GLM_FUNC_DECL genType fastLength(genType x)
Faster than the common length function but less accurate.
glm::round
GLM_FUNC_DECL vecType< T, P > round(vecType< T, P > const &x)
Returns a value equal to the nearest integer to x.
glm::normalize
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
Definition: _noise.hpp:40
glm::sign
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::reflect
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::fastSqrt
GLM_FUNC_DECL genType fastSqrt(genType x)
Faster than the common sqrt function but less accurate.
glm::vec4
highp_vec4 vec4
4 components vector of floating-point numbers.
Definition: type_vec.hpp:400
glm::max
GLM_FUNC_DECL genType max(genType x, genType y)
Returns y if x < y; otherwise, it returns x.
glm::vec3
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:395
glm::abs
GLM_FUNC_DECL genType abs(genType x)
Returns x if x >= 0; otherwise, it returns -x.
glm::min
GLM_FUNC_DECL genType min(genType x, genType y)
Returns y if y < x; otherwise, it returns x.
glm::inversesqrt
GLM_FUNC_DECL vecType< T, P > inversesqrt(vecType< T, P > const &v)
Returns the reciprocal of the positive square root of v.
glm::mix
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::step
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::mod
GLM_FUNC_DECL genType mod(genType x, genType y)
Modulus.
glm::sqrt
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &v)
Returns the positive square root of v.
glm::cross
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.