0.9.8: simd_vec4.hpp Source File

| 0.9.8

- Main Page
- Modules
- Files

- File List

simd_vec4.hpp
Go to the documentation of this file.
1
13 #pragma once
14
15 // Dependency:
16 #include "../glm.hpp"
17
18 #if(GLM_ARCH != GLM_ARCH_PURE)
19
20 #if(GLM_ARCH & GLM_ARCH_SSE2_BIT)
21 # include "../detail/intrinsic_common.hpp"
22 # include "../detail/intrinsic_geometric.hpp"
23 # include "../detail/intrinsic_integer.hpp"
24 #else
25 # error "GLM: GLM_GTX_simd_vec4 requires compiler support of SSE2 through intrinsics"
26 #endif
27
28 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
29 # pragma message("GLM: GLM_GTX_simd_vec4 extension included")
30 # pragma message("GLM: GLM_GTX_simd_vec4 extension is deprecated and will be removed in GLM 0.9.9. Use *vec4 types instead and use compiler SIMD arguments.")
31 #endif
32
33
34 // Warning silencer for nameless struct/union.
35 #if (GLM_COMPILER & GLM_COMPILER_VC)
36 # pragma warning(push)
37 # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
38 #endif
39
40 namespace glm
41 {
42 enum comp
43 {
44 X = 0,
45 R = 0,
46 S = 0,
47 Y = 1,
48 G = 1,
49 T = 1,
50 Z = 2,
51 B = 2,
52 P = 2,
53 W = 3,
54 A = 3,
55 Q = 3
56 };
57
58 }//namespace glm
59
60 namespace glm{
61 namespace detail
62 {
65 GLM_ALIGNED_STRUCT(16) fvec4SIMD
66 {
67 typedef float value_type;
68 typedef std::size_t size_type;
69
70 typedef fvec4SIMD type;
71 typedef tvec4<float, defaultp> pure_type;
72 typedef tvec4<bool, highp> bool_type;
73
74 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
75 union
76 {
77 __m128 Data;
78 struct {float x, y, z, w;};
79 };
80 #else
81 __m128 Data;
82 #endif
83
85 // Implicit basic constructors
86
87 fvec4SIMD() GLM_DEFAULT_CTOR;
88 fvec4SIMD(fvec4SIMD const & v) GLM_DEFAULT;
89 fvec4SIMD(__m128 const & Data);
90
92 // Explicit basic constructors
93
94 explicit fvec4SIMD(
95 ctor);
96 explicit fvec4SIMD(
97 float const & s);
98 explicit fvec4SIMD(
99 float const & x,
100 float const & y,
101 float const & z,
102 float const & w);
103 explicit fvec4SIMD(
104 vec4 const & v);
105
108
109 fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
110 fvec4SIMD(float const & s1, vec2 const & v, float const & s2);
111 fvec4SIMD(float const & s1, float const & s2, vec2 const & v);
112 fvec4SIMD(vec3 const & v, float const & s);
113 fvec4SIMD(float const & s, vec3 const & v);
114 fvec4SIMD(vec2 const & v1, vec2 const & v2);
115 //fvec4SIMD(ivec4SIMD const & v);
116
118 // Unary arithmetic operators
119
120 fvec4SIMD& operator= (fvec4SIMD const & v) GLM_DEFAULT;
121 fvec4SIMD& operator+=(fvec4SIMD const & v);
122 fvec4SIMD& operator-=(fvec4SIMD const & v);
123 fvec4SIMD& operator*=(fvec4SIMD const & v);
124 fvec4SIMD& operator/=(fvec4SIMD const & v);
125
126 fvec4SIMD& operator+=(float const & s);
127 fvec4SIMD& operator-=(float const & s);
128 fvec4SIMD& operator*=(float const & s);
129 fvec4SIMD& operator/=(float const & s);
130
131 fvec4SIMD& operator++();
132 fvec4SIMD& operator--();
133
135 // Swizzle operators
136
137 template <comp X_, comp Y_, comp Z_, comp W_>
138 fvec4SIMD& swizzle();
139 template <comp X_, comp Y_, comp Z_, comp W_>
140 fvec4SIMD swizzle() const;
141 template <comp X_, comp Y_, comp Z_>
142 fvec4SIMD swizzle() const;
143 template <comp X_, comp Y_>
144 fvec4SIMD swizzle() const;
145 template <comp X_>
146 fvec4SIMD swizzle() const;
147 };
148 }//namespace detail
149
150 typedef glm::detail::fvec4SIMD simdVec4;
151
154
157 vec4 vec4_cast(
158 detail::fvec4SIMD const & x);
159
162 detail::fvec4SIMD abs(detail::fvec4SIMD const & x);
163
166 detail::fvec4SIMD sign(detail::fvec4SIMD const & x);
167
170 detail::fvec4SIMD floor(detail::fvec4SIMD const & x);
171
175 detail::fvec4SIMD trunc(detail::fvec4SIMD const & x);
176
184 detail::fvec4SIMD round(detail::fvec4SIMD const & x);
185
191 //detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x);
192
196 detail::fvec4SIMD ceil(detail::fvec4SIMD const & x);
197
201 detail::fvec4SIMD fract(detail::fvec4SIMD const & x);
202
207 detail::fvec4SIMD mod(
208 detail::fvec4SIMD const & x,
209 detail::fvec4SIMD const & y);
210
215 detail::fvec4SIMD mod(
216 detail::fvec4SIMD const & x,
217 float const & y);
218
224 //detail::fvec4SIMD modf(
225 // detail::fvec4SIMD const & x,
226 // detail::fvec4SIMD & i);
227
231 detail::fvec4SIMD min(
232 detail::fvec4SIMD const & x,
233 detail::fvec4SIMD const & y);
234
235 detail::fvec4SIMD min(
236 detail::fvec4SIMD const & x,
237 float const & y);
238
242 detail::fvec4SIMD max(
243 detail::fvec4SIMD const & x,
244 detail::fvec4SIMD const & y);
245
246 detail::fvec4SIMD max(
247 detail::fvec4SIMD const & x,
248 float const & y);
249
254 detail::fvec4SIMD clamp(
255 detail::fvec4SIMD const & x,
256 detail::fvec4SIMD const & minVal,
257 detail::fvec4SIMD const & maxVal);
258
259 detail::fvec4SIMD clamp(
260 detail::fvec4SIMD const & x,
261 float const & minVal,
262 float const & maxVal);
263
290 detail::fvec4SIMD mix(
291 detail::fvec4SIMD const & x,
292 detail::fvec4SIMD const & y,
293 detail::fvec4SIMD const & a);
294
298 detail::fvec4SIMD step(
299 detail::fvec4SIMD const & edge,
300 detail::fvec4SIMD const & x);
301
302 detail::fvec4SIMD step(
303 float const & edge,
304 detail::fvec4SIMD const & x);
305
317 detail::fvec4SIMD smoothstep(
318 detail::fvec4SIMD const & edge0,
319 detail::fvec4SIMD const & edge1,
320 detail::fvec4SIMD const & x);
321
322 detail::fvec4SIMD smoothstep(
323 float const & edge0,
324 float const & edge1,
325 detail::fvec4SIMD const & x);
326
334 //bvec4 isnan(detail::fvec4SIMD const & x);
335
343 //bvec4 isinf(detail::fvec4SIMD const & x);
344
350 //detail::ivec4SIMD floatBitsToInt(detail::fvec4SIMD const & value);
351
359 //detail::fvec4SIMD intBitsToFloat(detail::ivec4SIMD const & value);
360
364 detail::fvec4SIMD fma(
365 detail::fvec4SIMD const & a,
366 detail::fvec4SIMD const & b,
367 detail::fvec4SIMD const & c);
368
379 //detail::fvec4SIMD frexp(detail::fvec4SIMD const & x, detail::ivec4SIMD & exp);
380
388 //detail::fvec4SIMD ldexp(detail::fvec4SIMD const & x, detail::ivec4SIMD const & exp);
389
393 float length(
394 detail::fvec4SIMD const & x);
395
400 float fastLength(
401 detail::fvec4SIMD const & x);
402
407 float niceLength(
408 detail::fvec4SIMD const & x);
409
413 detail::fvec4SIMD length4(
414 detail::fvec4SIMD const & x);
415
420 detail::fvec4SIMD fastLength4(
421 detail::fvec4SIMD const & x);
422
427 detail::fvec4SIMD niceLength4(
428 detail::fvec4SIMD const & x);
429
433 float distance(
434 detail::fvec4SIMD const & p0,
435 detail::fvec4SIMD const & p1);
436
440 detail::fvec4SIMD distance4(
441 detail::fvec4SIMD const & p0,
442 detail::fvec4SIMD const & p1);
443
447 float simdDot(
448 detail::fvec4SIMD const & x,
449 detail::fvec4SIMD const & y);
450
454 detail::fvec4SIMD dot4(
455 detail::fvec4SIMD const & x,
456 detail::fvec4SIMD const & y);
457
461 detail::fvec4SIMD cross(
462 detail::fvec4SIMD const & x,
463 detail::fvec4SIMD const & y);
464
468 detail::fvec4SIMD normalize(
469 detail::fvec4SIMD const & x);
470
475 detail::fvec4SIMD fastNormalize(
476 detail::fvec4SIMD const & x);
477
481 detail::fvec4SIMD simdFaceforward(
482 detail::fvec4SIMD const & N,
483 detail::fvec4SIMD const & I,
484 detail::fvec4SIMD const & Nref);
485
490 detail::fvec4SIMD reflect(
491 detail::fvec4SIMD const & I,
492 detail::fvec4SIMD const & N);
493
499 detail::fvec4SIMD refract(
500 detail::fvec4SIMD const & I,
501 detail::fvec4SIMD const & N,
502 float const & eta);
503
507 detail::fvec4SIMD sqrt(
508 detail::fvec4SIMD const & x);
509
514 detail::fvec4SIMD niceSqrt(
515 detail::fvec4SIMD const & x);
516
521 detail::fvec4SIMD fastSqrt(
522 detail::fvec4SIMD const & x);
523
527 detail::fvec4SIMD inversesqrt(
528 detail::fvec4SIMD const & x);
529
534 detail::fvec4SIMD fastInversesqrt(
535 detail::fvec4SIMD const & x);
536
538 }//namespace glm
539
540 #include "simd_vec4.inl"
541
542 #if (GLM_COMPILER & GLM_COMPILER_VC)
543 # pragma warning(pop)
544 #endif
545
546 #endif//(GLM_ARCH != GLM_ARCH_PURE)
glm::fract
GLM_FUNC_DECL genType fract(genType x)
Return x - floor(x).
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::fastNormalize
GLM_FUNC_DECL genType fastNormalize(genType const &x)
Faster than the common normalize function but less accurate.
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:466
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::max
GLM_FUNC_DECL genType max(genType x, genType y)
Returns y if x < y; otherwise, it returns x.
glm
Definition: _noise.hpp:11
glm::mod
GLM_FUNC_DECL genType mod(genType x, genType y)
Modulus.
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::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::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::abs
GLM_FUNC_DECL genType abs(genType x)
Returns x if x >= 0; otherwise, it returns -x.
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.
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::sqrt
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &v)
Returns the positive square root of v.
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::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::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::length
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
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::min
GLM_FUNC_DECL genType min(genType x, genType y)
Returns y if y < x; otherwise, it returns x.
glm::vec3
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:461
glm::fma
GLM_FUNC_DECL genType fma(genType const &a, genType const &b, genType const &c)
Computes and returns a * b + c.
glm::vec2
highp_vec2 vec2
2 components vector of floating-point numbers.
Definition: type_vec.hpp:456
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::inversesqrt
GLM_FUNC_DECL vecType< T, P > inversesqrt(vecType< T, P > const &v)
Returns the reciprocal of the positive square root of v.
glm::fastLength
GLM_FUNC_DECL genType fastLength(genType x)
Faster than the common length function but less accurate.
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::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.