matrix.cpp: Major cleanup and refactor. All previous functionality and behavior should be retained.

- This refactor was done to support future additions of SIMD functions using ISAs other than SSE / SSE4.1.
- Add support for fixed-point math functions using accumulators that saturate, following the GEM_TransformVertex() function. This feature requires new testing, and has been disabled for now in order to retain the previous behavior.
- Remove the obsolete and unused functions _MatrixMultVec4x4_NoSIMD() and vector_fix2float(). If non-SIMD testing is required, it should be easy enough to comment out the SIMD code paths in the appropriate function in favor of the plain C code path.
This commit is contained in:
rogerman 2022-04-12 17:33:20 -07:00
parent 2e6b938378
commit b608a62cd0
3 changed files with 941 additions and 792 deletions

View File

@ -1199,8 +1199,6 @@ static BOOL gfx3d_glLoadMatrix4x4(s32 v)
GFX_DELAY(19);
//vector_fix2float<4>(mtxCurrent[mode], 4096.f);
if (mode == MATRIXMODE_POSITION_VECTOR)
MatrixCopy(mtxCurrent[MATRIXMODE_POSITION], mtxCurrent[MATRIXMODE_POSITION_VECTOR]);
@ -1217,8 +1215,6 @@ static BOOL gfx3d_glLoadMatrix4x3(s32 v)
if(ML4x3ind<16) return FALSE;
ML4x3ind = 0;
//vector_fix2float<4>(mtxCurrent[mode], 4096.f);
//fill in the unusued matrix values
mtxCurrent[mode][3] = mtxCurrent[mode][7] = mtxCurrent[mode][11] = 0;
mtxCurrent[mode][15] = (1<<12);
@ -1241,8 +1237,6 @@ static BOOL gfx3d_glMultMatrix4x4(s32 v)
GFX_DELAY(35);
//vector_fix2float<4>(mtxTemporal, 4096.f);
MatrixMultiply(mtxCurrent[mode], mtxTemporal);
if (mode == MATRIXMODE_POSITION_VECTOR)
@ -1273,8 +1267,6 @@ static BOOL gfx3d_glMultMatrix4x3(s32 v)
GFX_DELAY(31);
//vector_fix2float<4>(mtxTemporal, 4096.f);
//fill in the unusued matrix values
mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0;
mtxTemporal[15] = 1 << 12;
@ -1310,8 +1302,6 @@ static BOOL gfx3d_glMultMatrix3x3(s32 v)
GFX_DELAY(28);
//vector_fix2float<3>(mtxTemporal, 4096.f);
//fill in the unusued matrix values
mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0;
mtxTemporal[15] = 1<<12;
@ -1796,8 +1786,6 @@ static BOOL gfx3d_glBoxTest(u32 v)
//DS_ALIGN(16) VERT_POS4f vert = { verts[i].x, verts[i].y, verts[i].z, verts[i].w };
//_MatrixMultVec4x4_NoSIMD(mtxCurrent[MATRIXMODE_POSITION], verts[i].coord);
//_MatrixMultVec4x4_NoSIMD(mtxCurrent[MATRIXMODE_PROJECTION], verts[i].coord);
MatrixMultVec4x4(mtxCurrent[MATRIXMODE_POSITION], verts[i].coord);
MatrixMultVec4x4(mtxCurrent[MATRIXMODE_PROJECTION], verts[i].coord);
}

File diff suppressed because it is too large Load Diff

View File

@ -95,17 +95,12 @@ void Vector3Normalize(float *dst);
void Vector4Copy(float *dst, const float *src);
void _MatrixMultVec4x4_NoSIMD(const s32 (&__restrict mtx)[16], float (&__restrict vec)[4]);
void MatrixMultVec4x4(const s32 (&__restrict mtx)[16], float (&__restrict vec)[4]);
void MatrixMultVec3x3(const s32 (&__restrict mtx)[16], float (&__restrict vec)[4]);
void MatrixTranslate(float (&__restrict mtx)[16], const float (&__restrict vec)[4]);
void MatrixScale(float (&__restrict mtx)[16], const float (&__restrict vec)[4]);
void MatrixMultiply(float (&__restrict mtxA)[16], const s32 (&__restrict mtxB)[16]);
template<size_t NUM_ROWS> FORCEINLINE void vector_fix2float(float (&mtx)[16], const float divisor);
void MatrixMultVec4x4(const s32 (&__restrict mtx)[16], s32 (&__restrict vec)[4]);
void MatrixMultVec3x3(const s32 (&__restrict mtx)[16], s32 (&__restrict vec)[4]);
void MatrixTranslate(s32 (&__restrict mtx)[16], const s32 (&__restrict vec)[4]);