Using NEON optimized code where possible.
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
#include "rwengine.h"
|
||||
|
||||
#include <vitaGL.h>
|
||||
extern "C"{
|
||||
#include <math_neon.h>
|
||||
};
|
||||
|
||||
namespace rw {
|
||||
|
||||
@@ -190,6 +193,9 @@ V3d::transformVectors(V3d *out, const V3d *in, int32 n, const Matrix *m)
|
||||
void
|
||||
RawMatrix::mult(RawMatrix *dst, RawMatrix *src1, RawMatrix *src2)
|
||||
{
|
||||
#ifdef PSP2
|
||||
matmul4_neon((float*)&dst->right.x, (float*)&src1->right.x, (float*)&src2->right.x);
|
||||
#else
|
||||
dst->right.x = src1->right.x*src2->right.x + src1->right.y*src2->up.x + src1->right.z*src2->at.x + src1->rightw*src2->pos.x;
|
||||
dst->right.y = src1->right.x*src2->right.y + src1->right.y*src2->up.y + src1->right.z*src2->at.y + src1->rightw*src2->pos.y;
|
||||
dst->right.z = src1->right.x*src2->right.z + src1->right.y*src2->up.z + src1->right.z*src2->at.z + src1->rightw*src2->pos.z;
|
||||
@@ -206,6 +212,7 @@ RawMatrix::mult(RawMatrix *dst, RawMatrix *src1, RawMatrix *src2)
|
||||
dst->pos.y = src1->pos.x*src2->right.y + src1->pos.y*src2->up.y + src1->pos.z*src2->at.y + src1->posw*src2->pos.y;
|
||||
dst->pos.z = src1->pos.x*src2->right.z + src1->pos.y*src2->up.z + src1->pos.z*src2->at.z + src1->posw*src2->pos.z;
|
||||
dst->posw = src1->pos.x*src2->rightw + src1->pos.y*src2->upw + src1->pos.z*src2->atw + src1->posw*src2->posw;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+10
-5
@@ -5,7 +5,9 @@
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
extern "C"{
|
||||
#include <math_neon.h>
|
||||
};
|
||||
// TODO: clean up the opengl defines
|
||||
// and figure out what we even want here...
|
||||
#ifdef RW_GL3
|
||||
@@ -240,7 +242,7 @@ inline V3d add(const V3d &a, const V3d &b) { return makeV3d(a.x+b.x, a.y+b.y, a.
|
||||
inline V3d sub(const V3d &a, const V3d &b) { return makeV3d(a.x-b.x, a.y-b.y, a.z-b.z); }
|
||||
inline V3d scale(const V3d &a, float32 r) { return makeV3d(a.x*r, a.y*r, a.z*r); }
|
||||
inline float32 length(const V3d &v) { return sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); }
|
||||
inline V3d normalize(const V3d &v) { return scale(v, 1.0f/length(v)); }
|
||||
inline V3d normalize(const V3d &v) { V3d r; normalize3_neon((float*)&v.x, &r.x); return r; }
|
||||
inline V3d setlength(const V3d &v, float32 l) { return scale(v, l/length(v)); }
|
||||
V3d cross(const V3d &a, const V3d &b);
|
||||
inline float32 dot(const V3d &a, const V3d &b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
|
||||
@@ -273,7 +275,10 @@ struct Quat
|
||||
float32 x, y, z, w;
|
||||
|
||||
static Quat rotation(float32 angle, const V3d &axis){
|
||||
return makeQuat(cosf(angle/2.0f), scale(normalize(axis), sinf(angle/2.0f))); }
|
||||
float cs[2];
|
||||
sincosf_c(angle/2.0f, cs);
|
||||
return makeQuat(cs[1], scale(normalize(axis), cs[0]));
|
||||
}
|
||||
void set(float32 w, float32 x, float32 y, float32 z){
|
||||
this->w = w; this->x = x; this->y = y; this->z = z; }
|
||||
V3d vec(void){ return makeV3d(x, y, z); }
|
||||
@@ -286,10 +291,10 @@ inline Quat makeQuat(float32 w, const V3d &vec) { Quat q = { vec.x, vec.y, vec.z
|
||||
inline Quat add(const Quat &q, const Quat &p) { return makeQuat(q.w+p.w, q.x+p.x, q.y+p.y, q.z+p.z); }
|
||||
inline Quat sub(const Quat &q, const Quat &p) { return makeQuat(q.w-p.w, q.x-p.x, q.y-p.y, q.z-p.z); }
|
||||
inline Quat negate(const Quat &q) { return makeQuat(-q.w, -q.x, -q.y, -q.z); }
|
||||
inline float32 dot(const Quat &q, const Quat &p) { return q.w*p.w + q.x*p.x + q.y*p.y + q.z*p.z; }
|
||||
inline float32 dot(const Quat &q, const Quat &p) { return dot4_neon((float*)&q.x, (float*)&p.x); }
|
||||
inline Quat scale(const Quat &q, float32 r) { return makeQuat(q.w*r, q.x*r, q.y*r, q.z*r); }
|
||||
inline float32 length(const Quat &q) { return sqrtf(q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z); }
|
||||
inline Quat normalize(const Quat &q) { return scale(q, 1.0f/length(q)); }
|
||||
inline Quat normalize(const Quat &q) { float r[4]; normalize4_neon((float*)&q.x, r); return makeQuat(r[0], r[1], r[2], r[3]); }
|
||||
inline Quat conj(const Quat &q) { return makeQuat(q.w, -q.x, -q.y, -q.z); }
|
||||
Quat mult(const Quat &q, const Quat &p);
|
||||
inline V3d rotate(const V3d &v, const Quat &q) { return mult(mult(q, makeQuat(0.0f, v)), conj(q)).vec(); }
|
||||
|
||||
Reference in New Issue
Block a user