11 #ifndef __VM_BasicFunc__
12 #define __VM_BasicFunc__
36 operator v4si()
const;
52 operator v4sf()
const;
57 v4sf::operator
v4si()
const
63 v4si::operator
v4sf()
const
68 #define V4SF(A) (v4sf)A
69 #define V4SI(A) (v4si)A
71 #define vm_BASIC_IFF(OP) \
73 r.i[0] = a.f[0] OP b.f[0]; \
74 r.i[1] = a.f[1] OP b.f[1]; \
75 r.i[2] = a.f[2] OP b.f[2]; \
76 r.i[3] = a.f[3] OP b.f[3]; \
79 #define vm_BASIC_CF(OP) \
81 r.i[0] = a.f[0] OP b.f[0] ? 0xFFFFFFFF : 0; \
82 r.i[1] = a.f[1] OP b.f[1] ? 0xFFFFFFFF : 0; \
83 r.i[2] = a.f[2] OP b.f[2] ? 0xFFFFFFFF : 0; \
84 r.i[3] = a.f[3] OP b.f[3] ? 0xFFFFFFFF : 0; \
87 #define vm_BASIC_CI(OP) \
89 r.i[0] = a.i[0] OP b.i[0] ? 0xFFFFFFFF : 0; \
90 r.i[1] = a.i[1] OP b.i[1] ? 0xFFFFFFFF : 0; \
91 r.i[2] = a.i[2] OP b.i[2] ? 0xFFFFFFFF : 0; \
92 r.i[3] = a.i[3] OP b.i[3] ? 0xFFFFFFFF : 0; \
95 #define vm_BASIC_III(OP) \
97 r.i[0] = a.i[0] OP b.i[0]; \
98 r.i[1] = a.i[1] OP b.i[1]; \
99 r.i[2] = a.i[2] OP b.i[2]; \
100 r.i[3] = a.i[3] OP b.i[3]; \
103 #define vm_BASIC_FFF(OP) \
105 r.f[0] = a.f[0] OP b.f[0]; \
106 r.f[1] = a.f[1] OP b.f[1]; \
107 r.f[2] = a.f[2] OP b.f[2]; \
108 r.f[3] = a.f[3] OP b.f[3]; \
111 #define vm_BASIC_FFFF(OP1, OP2) \
113 r.f[0] = a.f[0] OP1 b.f[0] OP2 c.f[0]; \
114 r.f[1] = a.f[1] OP1 b.f[1] OP2 c.f[1]; \
115 r.f[2] = a.f[2] OP1 b.f[2] OP2 c.f[2]; \
116 r.f[3] = a.f[3] OP1 b.f[3] OP2 c.f[3]; \
119 #define vm_BASIC_UFuncF(FUNC) \
121 r.f[0] = FUNC(a.f[0]); \
122 r.f[1] = FUNC(a.f[1]); \
123 r.f[2] = FUNC(a.f[2]); \
124 r.f[3] = FUNC(a.f[3]); \
127 #define vm_BASIC_UFuncFF(FUNC) \
129 r.f[0] = FUNC(a.f[0], b.f[0]); \
130 r.f[1] = FUNC(a.f[1], b.f[1]); \
131 r.f[2] = FUNC(a.f[2], b.f[2]); \
132 r.f[3] = FUNC(a.f[3], b.f[3]); \
165 r.
i[0] = ~a.
i[0] & b.
i[0];
166 r.
i[1] = ~a.
i[1] & b.
i[1];
167 r.
i[2] = ~a.
i[2] & b.
i[2];
168 r.
i[3] = ~a.
i[3] & b.
i[3];
186 static inline v4si vm_floor(
const v4sf &
a)
189 r.
i[0] = (
int)SYSfastFloor(a.
f[0]);
190 r.
i[1] = (
int)SYSfastFloor(a.
f[1]);
191 r.
i[2] = (
int)SYSfastFloor(a.
f[2]);
192 r.
i[3] = (
int)SYSfastFloor(a.
f[3]);
196 static inline v4si vm_intcast(
const v4sf &a)
199 r.
i[0] = (
int)a.
f[0];
200 r.
i[1] = (
int)a.
f[1];
201 r.
i[2] = (
int)a.
f[2];
202 r.
i[3] = (
int)a.
f[3];
206 static inline v4sf vm_floatcast(
const v4si &a)
210 r.
f[1] = (
float)a.
i[1];
212 r.
f[3] = (
float)a.
i[3];
237 return v4si(a, b, c, d);
243 return v4si(a, b, c, d);
247 vm_splats(
float a,
float b,
float c,
float d)
249 return v4sf(a, b, c, d);
253 vm_allbits(
const v4si &a)
255 return (a.
i[0] & a.
i[1] & a.
i[2] & a.
i[3]) == 0xFFFFFFFF;
259 vm_signbits(
const v4si &a)
261 return (a.
i[0] < 0 ? 1 : 0) |
262 (a.
i[1] < 0 ? 2 : 0) |
263 (a.
i[2] < 0 ? 4 : 0) |
264 (a.
i[3] < 0 ? 8 : 0);
268 vm_signbits(
const v4sf &a)
270 return vm_signbits( * ((
v4si *) &a) );
273 template <
int A,
int B,
int C,
int D>
275 vm_shuffle(
const v4sf &
v)
290 return v4si(v[0], v[1], v[2], v[3]);
294 vm_load(
const float v[4])
296 return v4sf(v[0], v[1], v[2], v[3]);
329 vm_insert(
const v4sf v,
float a,
int n)
339 vm_extract(
const v4si v,
int n)
345 vm_extract(
const v4sf v,
int n)
350 #define VMBASIC_DEFINE_UNARY(FUN) \
351 static inline v4sf vm_##FUN(const v4sf &a) \
362 #undef VMBASIC_DEFINE_UNARY
367 SYSsincos(x.
f[0], s->
f + 0, c->
f + 0);
368 SYSsincos(x.
f[1], s->
f + 1, c->
f + 1);
369 SYSsincos(x.
f[2], s->
f + 2, c->
f + 2);
370 SYSsincos(x.
f[3], s->
f + 3, c->
f + 3);
374 vm_shiftleft(
const v4si &a,
int c)
385 vm_shiftright(
const v4si &a,
int c)
395 #define VM_EXTRACT vm_extract
396 #define VM_INSERT vm_insert
397 #define VM_SPLATS vm_splats
398 #define VM_LOAD vm_load
399 #define VM_STORE vm_store
401 #define VM_CMPLT vm_clt
402 #define VM_CMPLE vm_cle
403 #define VM_CMPGT vm_cgt
404 #define VM_CMPGE vm_cge
405 #define VM_CMPEQ vm_ceq
406 #define VM_CMPNE vm_cne
408 #define VM_ICMPLT vm_clt
409 #define VM_ICMPGT vm_cgt
410 #define VM_ICMPEQ vm_ceq
412 #define VM_IADD vm_add
413 #define VM_ISUB vm_sub
414 #define VM_IMUL vm_mul
416 #define VM_ADD vm_add
417 #define VM_SUB vm_sub
418 #define VM_MUL vm_mul
419 #define VM_DIV vm_div
420 #define VM_FDIV vm_div
421 #define VM_NEG vm_negate
422 #define VM_SQRT vm_sqrt
423 #define VM_FSQRT vm_sqrt
424 #define VM_ISQRT vm_isqrt
425 #define VM_ABS vm_abs
427 #define VM_MADD vm_madd
428 #define VM_INVERT vm_reciprocal
430 #define VM_MIN vm_min
431 #define VM_MAX vm_max
433 #define VM_AND vm_and
434 #define VM_ANDNOT vm_andnot
436 #define VM_XOR vm_xor
438 #define VM_ALLBITS vm_allbits
440 #define VM_SHUFFLE vm_shuffle
443 #define VM_FLOOR vm_floor
446 #define VM_INT vm_intcast
448 #define VM_IFLOAT vm_floatcast
450 #define VM_SIN vm_sin
451 #define VM_COS vm_cos
452 #define VM_TAN vm_tan
453 #define VM_SINCOS vm_sincos
456 #define VM_SHIFTLEFT(A,C) vm_shiftleft(A,C)
457 #define VM_SHIFTRIGHT(A,C) vm_shiftright(A,C)
SYS_API double cos(double x)
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
GLboolean GLboolean GLboolean GLboolean a
IMATH_NAMESPACE::V2f float
v4sf(float a, float b, float c, float d)
#define vm_BASIC_UFuncF(FUNC)
GLboolean GLboolean GLboolean b
#define vm_BASIC_FFFF(OP1, OP2)
#define VMBASIC_DEFINE_UNARY(FUN)
SYS_API double tan(double x)
v4si(int32 a, int32 b, int32 c, int32 d)
#define vm_BASIC_UFuncFF(FUNC)
SYS_API double sin(double x)