Commit Graph

3 Commits

Author SHA1 Message Date
Bill Currie 3125009a7c [util] Add vector and quaternion types to cexpr
Although there's no distinction between the two at the C level, I think
it's probably best to separate them in a scripting language.
2020-12-30 18:20:11 +09:00
Bill Currie 1ddd57b09e [util] Add qconj, vtrunc, vceil and vfloor functions
I had forgotten these rather critical functions. Both double and float
versions are included.
2020-12-30 18:20:11 +09:00
Bill Currie 09a10f80e1 [util] Add basic SIMD implemented vector functions
They take advantage of gcc's vector_size attribute and so only cross,
dot, qmul, qvmul and qrot (create rotation quaternion from two vectors)
are needed at this stage as basic (per-component) math is supported
natively by gcc.

The provided functions work on horizontal (array-of-structs) data, ie a
vec4d_t or vec4f_t represents a single vector, or traditional vector
layout. Vertical layout (struct-of-arrays) does not need any special
functions as the regular math can be used to operate on four vectors at
a time.

Functions are provided for loading a vec4 from a vec3 (4th element set
to 0) and storing a vec4 into a vec3 (discarding the 4th element).

With this, QF will require AVX2 support (needed for vec4d_t). Without
support for doubles, SSE is possible, but may not be worthwhile for
horizontal data.

Fused-multiply-add is NOT used because it alters the results between
unoptimized and optimized code, resulting in -mfma really meaning
-mfast-math-anyway. I really do not want to have to debug issues that
occur only in optimized code.
2020-12-30 18:20:11 +09:00