gcc porting - successful compilation
This commit is contained in:
@@ -58,16 +58,16 @@ Vector3 Matrix::operator*(const Vector3 &v) const
|
||||
float a[4] = {v.x, v.y, v.z, 1.0F};
|
||||
float res[4];
|
||||
asm volatile(
|
||||
"lqc2 vf4, 0x00(%1) \n\t"
|
||||
"lqc2 vf5, 0x10(%1) \n\t"
|
||||
"lqc2 vf6, 0x20(%1) \n\t"
|
||||
"lqc2 vf7, 0x30(%1) \n\t"
|
||||
"lqc2 vf8, 0x00(%2) \n\t"
|
||||
"vmulax.xyzw ACC, vf4, vf8 \n\t"
|
||||
"vmadday.xyzw ACC, vf5, vf8 \n\t"
|
||||
"vmaddaz.xyzw ACC, vf6, vf8 \n\t"
|
||||
"vmaddw.xyzw vf9, vf7, vf8 \n\t"
|
||||
"sqc2 vf9, 0x00(%0) \n\t"
|
||||
"lqc2 $vf4, 0x00(%1) \n\t"
|
||||
"lqc2 $vf5, 0x10(%1) \n\t"
|
||||
"lqc2 $vf6, 0x20(%1) \n\t"
|
||||
"lqc2 $vf7, 0x30(%1) \n\t"
|
||||
"lqc2 $vf8, 0x00(%2) \n\t"
|
||||
"vmulax.xyzw $ACC, $vf4, $vf8 \n\t"
|
||||
"vmadday.xyzw $ACC, $vf5, $vf8 \n\t"
|
||||
"vmaddaz.xyzw $ACC, $vf6, $vf8 \n\t"
|
||||
"vmaddw.xyzw $vf9, $vf7, $vf8 \n\t"
|
||||
"sqc2 $vf9, 0x00(%0) \n\t"
|
||||
:
|
||||
: "r"(res), "r"(this->data), "r"(a));
|
||||
return Vector3(res[0], res[1], res[2]);
|
||||
@@ -80,15 +80,15 @@ Vector3 Matrix::operator*(const Vector3 &v) const
|
||||
void Matrix::identity()
|
||||
{
|
||||
asm volatile(
|
||||
"vsub.xyzw vf4, vf0, vf0 \n\t"
|
||||
"vadd.w vf4, vf4, vf0 \n\t"
|
||||
"vmr32.xyzw vf5, vf4 \n\t"
|
||||
"vmr32.xyzw vf6, vf5 \n\t"
|
||||
"vmr32.xyzw vf7, vf6 \n\t"
|
||||
"sqc2 vf4, 0x30(%0) \n\t"
|
||||
"sqc2 vf5, 0x20(%0) \n\t"
|
||||
"sqc2 vf6, 0x10(%0) \n\t"
|
||||
"sqc2 vf7, 0x0(%0) \n\t"
|
||||
"vsub.xyzw $vf4, $vf0, $vf0 \n\t"
|
||||
"vadd.w $vf4, $vf4, $vf0 \n\t"
|
||||
"vmr32.xyzw $vf5, $vf4 \n\t"
|
||||
"vmr32.xyzw $vf6, $vf5 \n\t"
|
||||
"vmr32.xyzw $vf7, $vf6 \n\t"
|
||||
"sqc2 $vf4, 0x30(%0) \n\t"
|
||||
"sqc2 $vf5, 0x20(%0) \n\t"
|
||||
"sqc2 $vf6, 0x10(%0) \n\t"
|
||||
"sqc2 $vf7, 0x0(%0) \n\t"
|
||||
:
|
||||
: "r"(this->data));
|
||||
}
|
||||
@@ -131,17 +131,17 @@ void Matrix::lookAt(const Vector3 &t_position, const Vector3 &t_target)
|
||||
VECTOR eye = {t_position.x, t_position.y, t_position.z, 1.0F};
|
||||
VECTOR obj = {t_target.x, t_target.y, t_target.z, 1.0F};
|
||||
asm volatile(
|
||||
"lqc2 vf4, 0x00(%2) # eye \n\t"
|
||||
"lqc2 vf5, 0x00(%3) # obj \n\t"
|
||||
"vsub.xyz vf7, vf4, vf5 # view_vec = vf7 \n\t"
|
||||
"vmove.xyzw vf6, vf0 \n\t"
|
||||
"vaddw.y vf6, vf0, vf0 # vf6 = { 0.0f, 1.0f, 0.0f, 1.0f } \n\t"
|
||||
"vopmula.xyz ACC, vf6, vf7 \n\t"
|
||||
"vopmsub.xyz vf9, vf7, vf6 # vec = vf9 \n\t"
|
||||
"vopmula.xyz ACC, vf7, vf9 \n\t"
|
||||
"vopmsub.xyz vf8, vf9, vf7 # up_vec = vf8 \n\t"
|
||||
"sqc2 vf7, 0x00(%0) # view_vec \n\t"
|
||||
"sqc2 vf6, 0x00(%1) # up_vec \n\t"
|
||||
"lqc2 $vf4, 0x00(%2) # eye \n\t"
|
||||
"lqc2 $vf5, 0x00(%3) # obj \n\t"
|
||||
"vsub.xyz $vf7, $vf4, $vf5 # view_vec = $vf7 \n\t"
|
||||
"vmove.xyzw $vf6, $vf0 \n\t"
|
||||
"vaddw.y $vf6, $vf0, $vf0 # $vf6 = { 0.0f, 1.0f, 0.0f, 1.0f } \n\t"
|
||||
"vopmula.xyz $ACC, $vf6, $vf7 \n\t"
|
||||
"vopmsub.xyz $vf9, $vf7, $vf6 # vec = $vf9 \n\t"
|
||||
"vopmula.xyz $ACC, $vf7, $vf9 \n\t"
|
||||
"vopmsub.xyz $vf8, $vf9, $vf7 # up_vec = $vf8 \n\t"
|
||||
"sqc2 $vf7, 0x00(%0) # view_vec \n\t"
|
||||
"sqc2 $vf6, 0x00(%1) # up_vec \n\t"
|
||||
:
|
||||
: "r"(view_vec), "r"(up_vec), "r"(eye), "r"(obj));
|
||||
Matrix temp;
|
||||
@@ -270,45 +270,45 @@ void Matrix::setScale(const Vector3 &t_val)
|
||||
|
||||
void Matrix::setCamera(const float t_pos[4], const float t_vz[4], const float t_vy[4])
|
||||
{
|
||||
// Matrix vf4, vf5, vf6, vf7
|
||||
// t_pos vf8
|
||||
// t_vz vf9
|
||||
// t_vy vf10
|
||||
// vtmp vf11
|
||||
// Matrix $vf4, $vf5, $vf6, $vf7
|
||||
// t_pos $vf8
|
||||
// t_vz $vf9
|
||||
// t_vy $vf10
|
||||
// vtmp $vf11
|
||||
asm volatile(
|
||||
"lqc2 vf9, 0x00(%2) \n\t"
|
||||
"lqc2 vf10, 0x00(%3) \n\t"
|
||||
"lqc2 $vf9, 0x00(%2) \n\t"
|
||||
"lqc2 $vf10, 0x00(%3) \n\t"
|
||||
// mtmp.unit()
|
||||
"vsub.w vf5, vf0, vf0 # mtmp[1][PW] = 0.0F \n\t"
|
||||
"vsub.w $vf5, $vf0, $vf0 # mtmp[1][PW] = 0.0F \n\t"
|
||||
// vtmp.outerProduct(vy, vz);
|
||||
"vopmula.xyz ACC, vf10, vf9 \n\t"
|
||||
"vopmsub.xyz vf11, vf9, vf10 \n\t"
|
||||
"vopmula.xyz $ACC, $vf10, $vf9 \n\t"
|
||||
"vopmsub.xyz $vf11, $vf9, $vf10 \n\t"
|
||||
// mtmp[0] = vtmp.normalize();
|
||||
"vmul.xyz vf12, vf11, vf11 \n\t"
|
||||
"vaddy.x vf12, vf12, vf12 \n\t"
|
||||
"vaddz.x vf12, vf12, vf12 \n\t"
|
||||
"vrsqrt Q, vf0w, vf12x \n\t"
|
||||
"vsub.xyzw vf4, vf0, vf0 \n\t"
|
||||
"vmul.xyz $vf12, $vf11, $vf11 \n\t"
|
||||
"vaddy.x $vf12, $vf12, $vf12 \n\t"
|
||||
"vaddz.x $vf12, $vf12, $vf12 \n\t"
|
||||
"vrsqrt $Q, $vf0w, $vf12x \n\t"
|
||||
"vsub.xyzw $vf4, $vf0, $vf0 \n\t"
|
||||
"vwaitq \n\t"
|
||||
"vmulq.xyz vf4, vf11, Q \n\t"
|
||||
"vmulq.xyz $vf4, $vf11, $Q \n\t"
|
||||
// mtmp[2] = vz.normalize();
|
||||
"vmul.xyz vf12, vf9, vf9 \n\t"
|
||||
"vaddy.x vf12, vf12, vf12 \n\t"
|
||||
"vaddz.x vf12, vf12, vf12 \n\t"
|
||||
"vrsqrt Q, vf0w, vf12x \n\t"
|
||||
"vsub.xyzw vf6, vf0, vf0 \n\t"
|
||||
"vmul.xyz $vf12, $vf9, $vf9 \n\t"
|
||||
"vaddy.x $vf12, $vf12, $vf12 \n\t"
|
||||
"vaddz.x $vf12, $vf12, $vf12 \n\t"
|
||||
"vrsqrt $Q, $vf0w, $vf12x \n\t"
|
||||
"vsub.xyzw $vf6, $vf0, $vf0 \n\t"
|
||||
"vwaitq \n\t"
|
||||
"vmulq.xyz vf6, vf9, Q \n\t"
|
||||
"vmulq.xyz $vf6, $vf9, $Q \n\t"
|
||||
// mtmp[1].outerProduct(mtmp[2], mtmp[0]);
|
||||
"vopmula.xyz ACC, vf6, vf4 \n\t"
|
||||
"vopmsub.xyz vf5, vf4, vf6 \n\t"
|
||||
"vopmula.xyz $ACC, $vf6, $vf4 \n\t"
|
||||
"vopmsub.xyz $vf5, $vf4, $vf6 \n\t"
|
||||
// mtmp.transpose(pos);
|
||||
"lqc2 vf7, 0x00(%1) \n\t"
|
||||
"lqc2 $vf7, 0x00(%1) \n\t"
|
||||
// m = mtmp.inverse();
|
||||
"qmfc2.ni $11, vf0 \n\t"
|
||||
"qmfc2.ni $8, vf4 \n\t"
|
||||
"qmfc2.ni $9, vf5 \n\t"
|
||||
"qmfc2.ni $10, vf6 \n\t"
|
||||
"qmfc2.ni $11, $vf0 \n\t"
|
||||
"qmfc2.ni $8, $vf4 \n\t"
|
||||
"qmfc2.ni $9, $vf5 \n\t"
|
||||
"qmfc2.ni $10, $vf6 \n\t"
|
||||
|
||||
"pextlw $12, $9, $8 \n\t"
|
||||
"pextuw $13, $9, $8 \n\t"
|
||||
@@ -318,18 +318,18 @@ void Matrix::setCamera(const float t_pos[4], const float t_vz[4], const float t_
|
||||
"pcpyud $9, $12, $14 \n\t"
|
||||
"pcpyld $10, $15, $13 \n\t"
|
||||
|
||||
"qmtc2.ni $8, vf16 \n\t"
|
||||
"qmtc2.ni $9, vf17 \n\t"
|
||||
"qmtc2.ni $10, vf18 \n\t"
|
||||
"vmulax.xyz ACC, vf16, vf7 \n\t"
|
||||
"vmadday.xyz ACC, vf17, vf7 \n\t"
|
||||
"vmaddz.xyz vf5, vf18, vf7 \n\t"
|
||||
"vsub.xyzw vf5, vf0, vf5 \n\t"
|
||||
"qmtc2.ni $8, $vf16 \n\t"
|
||||
"qmtc2.ni $9, $vf17 \n\t"
|
||||
"qmtc2.ni $10, $vf18 \n\t"
|
||||
"vmulax.xyz $ACC, $vf16, $vf7 \n\t"
|
||||
"vmadday.xyz $ACC, $vf17, $vf7 \n\t"
|
||||
"vmaddz.xyz $vf5, $vf18, $vf7 \n\t"
|
||||
"vsub.xyzw $vf5, $vf0, $vf5 \n\t"
|
||||
|
||||
"sq $8, 0x00(%0) \n\t"
|
||||
"sq $9, 0x10(%0) \n\t"
|
||||
"sq $10, 0x20(%0) \n\t"
|
||||
"sqc2 vf5, 0x30(%0) \n\t"
|
||||
"sqc2 $vf5, 0x30(%0) \n\t"
|
||||
:
|
||||
: "r"(this->data), "r"(t_pos), "r"(t_vz), "r"(t_vy));
|
||||
}
|
||||
@@ -337,34 +337,34 @@ void Matrix::setCamera(const float t_pos[4], const float t_vz[4], const float t_
|
||||
void Matrix::cross(float res[16], const float a[16], const float b[16]) const
|
||||
{
|
||||
asm volatile(
|
||||
"lqc2 vf1, 0x00(%1) \n\t"
|
||||
"lqc2 vf2, 0x10(%1) \n\t"
|
||||
"lqc2 vf3, 0x20(%1) \n\t"
|
||||
"lqc2 vf4, 0x30(%1) \n\t"
|
||||
"lqc2 vf5, 0x00(%2) \n\t"
|
||||
"lqc2 vf6, 0x10(%2) \n\t"
|
||||
"lqc2 vf7, 0x20(%2) \n\t"
|
||||
"lqc2 vf8, 0x30(%2) \n\t"
|
||||
"vmulax.xyzw ACC, vf5, vf1 \n\t"
|
||||
"vmadday.xyzw ACC, vf6, vf1 \n\t"
|
||||
"vmaddaz.xyzw ACC, vf7, vf1 \n\t"
|
||||
"vmaddw.xyzw vf1, vf8, vf1 \n\t"
|
||||
"vmulax.xyzw ACC, vf5, vf2 \n\t"
|
||||
"vmadday.xyzw ACC, vf6, vf2 \n\t"
|
||||
"vmaddaz.xyzw ACC, vf7, vf2 \n\t"
|
||||
"vmaddw.xyzw vf2, vf8, vf2 \n\t"
|
||||
"vmulax.xyzw ACC, vf5, vf3 \n\t"
|
||||
"vmadday.xyzw ACC, vf6, vf3 \n\t"
|
||||
"vmaddaz.xyzw ACC, vf7, vf3 \n\t"
|
||||
"vmaddw.xyzw vf3, vf8, vf3 \n\t"
|
||||
"vmulax.xyzw ACC, vf5, vf4 \n\t"
|
||||
"vmadday.xyzw ACC, vf6, vf4 \n\t"
|
||||
"vmaddaz.xyzw ACC, vf7, vf4 \n\t"
|
||||
"vmaddw.xyzw vf4, vf8, vf4 \n\t"
|
||||
"sqc2 vf1, 0x00(%0) \n\t"
|
||||
"sqc2 vf2, 0x10(%0) \n\t"
|
||||
"sqc2 vf3, 0x20(%0) \n\t"
|
||||
"sqc2 vf4, 0x30(%0) \n\t"
|
||||
"lqc2 $vf1, 0x00(%1) \n\t"
|
||||
"lqc2 $vf2, 0x10(%1) \n\t"
|
||||
"lqc2 $vf3, 0x20(%1) \n\t"
|
||||
"lqc2 $vf4, 0x30(%1) \n\t"
|
||||
"lqc2 $vf5, 0x00(%2) \n\t"
|
||||
"lqc2 $vf6, 0x10(%2) \n\t"
|
||||
"lqc2 $vf7, 0x20(%2) \n\t"
|
||||
"lqc2 $vf8, 0x30(%2) \n\t"
|
||||
"vmulax.xyzw $ACC, $vf5, $vf1 \n\t"
|
||||
"vmadday.xyzw $ACC, $vf6, $vf1 \n\t"
|
||||
"vmaddaz.xyzw $ACC, $vf7, $vf1 \n\t"
|
||||
"vmaddw.xyzw $vf1, $vf8, $vf1 \n\t"
|
||||
"vmulax.xyzw $ACC, $vf5, $vf2 \n\t"
|
||||
"vmadday.xyzw $ACC, $vf6, $vf2 \n\t"
|
||||
"vmaddaz.xyzw $ACC, $vf7, $vf2 \n\t"
|
||||
"vmaddw.xyzw $vf2, $vf8, $vf2 \n\t"
|
||||
"vmulax.xyzw $ACC, $vf5, $vf3 \n\t"
|
||||
"vmadday.xyzw $ACC, $vf6, $vf3 \n\t"
|
||||
"vmaddaz.xyzw $ACC, $vf7, $vf3 \n\t"
|
||||
"vmaddw.xyzw $vf3, $vf8, $vf3 \n\t"
|
||||
"vmulax.xyzw $ACC, $vf5, $vf4 \n\t"
|
||||
"vmadday.xyzw $ACC, $vf6, $vf4 \n\t"
|
||||
"vmaddaz.xyzw $ACC, $vf7, $vf4 \n\t"
|
||||
"vmaddw.xyzw $vf4, $vf8, $vf4 \n\t"
|
||||
"sqc2 $vf1, 0x00(%0) \n\t"
|
||||
"sqc2 $vf2, 0x10(%0) \n\t"
|
||||
"sqc2 $vf3, 0x20(%0) \n\t"
|
||||
"sqc2 $vf4, 0x30(%0) \n\t"
|
||||
:
|
||||
: "r"(res), "r"(b), "r"(a)
|
||||
: "memory");
|
||||
|
||||
@@ -30,10 +30,10 @@ Vector3 Vector3::operator+(const Vector3 &v) const
|
||||
{
|
||||
Vector3 result;
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%1) \n\t"
|
||||
"lqc2 vf5, 0x0(%2) \n\t"
|
||||
"vadd.xyz vf6, vf4, vf5 \n\t"
|
||||
"sqc2 vf6, 0x0(%0) \n\t"
|
||||
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||
"vadd.xyz $vf6, $vf4, $vf5 \n\t"
|
||||
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||
:
|
||||
: "r"(result.xyz), "r"(this->xyz), "r"(v.xyz));
|
||||
return result;
|
||||
@@ -43,10 +43,10 @@ Vector3 Vector3::operator-(const Vector3 &v) const
|
||||
{
|
||||
Vector3 result;
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%1) \n\t"
|
||||
"lqc2 vf5, 0x0(%2) \n\t"
|
||||
"vsub.xyz vf6, vf4, vf5 \n\t"
|
||||
"sqc2 vf6, 0x0(%0) \n\t"
|
||||
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||
"vsub.xyz $vf6, $vf4, $vf5 \n\t"
|
||||
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||
:
|
||||
: "r"(result.xyz), "r"(this->xyz), "r"(v.xyz));
|
||||
return result;
|
||||
@@ -55,13 +55,13 @@ Vector3 Vector3::operator-(const Vector3 &v) const
|
||||
Vector3 Vector3::operator*(const Vector3 &v) const
|
||||
{
|
||||
Vector3 res;
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%1) \n\t" // vf4 = this
|
||||
"lqc2 vf5, 0x0(%2) \n\t" // vf5 = v
|
||||
"vopmula.xyz ACC, vf4, vf5 \n\t"
|
||||
"vopmsub.xyz vf8, vf5, vf4 \n\t"
|
||||
"vsub.w vf8, vf00, vf00 \n\t"
|
||||
"sqc2 vf8, 0x0(%0) \n\t" // vf8 = res
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 $vf4, 0x0(%1) \n\t" // $vf4 = this
|
||||
"lqc2 $vf5, 0x0(%2) \n\t" // $vf5 = v
|
||||
"vopmula.xyz $ACC, $vf4, $vf5 \n\t"
|
||||
"vopmsub.xyz $vf8, $vf5, $vf4 \n\t"
|
||||
"vsub.w $vf8, $vf0, $vf0 \n\t"
|
||||
"sqc2 $vf8, 0x0(%0) \n\t" // $vf8 = res
|
||||
:
|
||||
: "r"(res.xyz), "r"(this->xyz), "r"(v.xyz));
|
||||
// result.x = y * v.z - z * v.y;
|
||||
@@ -74,11 +74,11 @@ Vector3 Vector3::operator*(const float &t) const
|
||||
{
|
||||
Vector3 result;
|
||||
asm volatile(
|
||||
"lqc2 vf4, 0x0(%1) \n\t"
|
||||
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||
"mfc1 $8, %2 \n\t"
|
||||
"qmtc2 $8, vf5 \n\t"
|
||||
"vmulx.xyz vf6, vf4, vf5 \n\t"
|
||||
"sqc2 vf6, 0x0(%0) \n\t"
|
||||
"qmtc2 $8, $vf5 \n\t"
|
||||
"vmulx.xyz $vf6, $vf4, $vf5 \n\t"
|
||||
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||
:
|
||||
: "r"(result.xyz), "r"(this->xyz), "f"(t));
|
||||
return result;
|
||||
@@ -96,10 +96,10 @@ Vector3 Vector3::operator/(const float &t) const
|
||||
void Vector3::operator+=(const Vector3 &t)
|
||||
{
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%0) \n\t"
|
||||
"lqc2 vf5, 0x0(%1) \n\t"
|
||||
"vadd.xyz vf4, vf4, vf5 \n\t"
|
||||
"sqc2 vf4, 0x0(%0) \n\t"
|
||||
"lqc2 $vf4, 0x0(%0) \n\t"
|
||||
"lqc2 $vf5, 0x0(%1) \n\t"
|
||||
"vadd.xyz $vf4, $vf4, $vf5 \n\t"
|
||||
"sqc2 $vf4, 0x0(%0) \n\t"
|
||||
:
|
||||
: "r"(this->xyz), "r"(t.xyz));
|
||||
}
|
||||
@@ -107,11 +107,11 @@ void Vector3::operator+=(const Vector3 &t)
|
||||
void Vector3::operator*=(const float &t)
|
||||
{
|
||||
asm volatile(
|
||||
"lqc2 vf4, 0x0(%0) \n\t"
|
||||
"lqc2 $vf4, 0x0(%0) \n\t"
|
||||
"mfc1 $8, %1 \n\t"
|
||||
"qmtc2 $8, vf5 \n\t"
|
||||
"vmulx.xyz vf4, vf4, vf5 \n\t"
|
||||
"sqc2 vf4, 0x0(%0) \n\t"
|
||||
"qmtc2 $8, $vf5 \n\t"
|
||||
"vmulx.xyz $vf4, $vf4, $vf5 \n\t"
|
||||
"sqc2 $vf4, 0x0(%0) \n\t"
|
||||
:
|
||||
: "r"(this->xyz), "f"(t));
|
||||
}
|
||||
@@ -140,12 +140,12 @@ float Vector3::innerProduct(const Vector3 &v) const
|
||||
{
|
||||
float result;
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%1) \n\t"
|
||||
"lqc2 vf5, 0x0(%2) \n\t"
|
||||
"vmul.xyz vf6, vf4, vf5 \n\t"
|
||||
"vaddy.x vf6, vf6, vf6 \n\t"
|
||||
"vaddz.x vf6, vf6, vf6 \n\t"
|
||||
"qmfc2 $2, vf6 \n\t"
|
||||
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||
"vmul.xyz $vf6, $vf4, $vf5 \n\t"
|
||||
"vaddy.x $vf6, $vf6, $vf6 \n\t"
|
||||
"vaddz.x $vf6, $vf6, $vf6 \n\t"
|
||||
"qmfc2 $2, $vf6 \n\t"
|
||||
"mtc1 $2, %0 \n\t"
|
||||
: "=f"(result)
|
||||
: "r"(this->xyz), "r"(v.xyz));
|
||||
@@ -157,14 +157,14 @@ float Vector3::length() const
|
||||
{
|
||||
float result;
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%1) \n\t"
|
||||
"vmul.xyz vf5, vf4, vf4 \n\t"
|
||||
"vaddy.x vf5, vf5, vf5 \n\t"
|
||||
"vaddz.x vf5, vf5, vf5 \n\t"
|
||||
"vsqrt Q , vf5x \n\t"
|
||||
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||
"vmul.xyz $vf5, $vf4, $vf4 \n\t"
|
||||
"vaddy.x $vf5, $vf5, $vf5 \n\t"
|
||||
"vaddz.x $vf5, $vf5, $vf5 \n\t"
|
||||
"vsqrt $Q , $vf5x \n\t"
|
||||
"vwaitq \n\t"
|
||||
"vaddq.x vf8, vf0, Q \n\t"
|
||||
"qmfc2 $2, vf8 \n\t"
|
||||
"vaddq.x $vf8, $vf0, $Q \n\t"
|
||||
"qmfc2 $2, $vf8 \n\t"
|
||||
"mtc1 $2, %0 \n\t"
|
||||
: "=f"(result)
|
||||
: "r"(this->xyz));
|
||||
@@ -175,17 +175,17 @@ float Vector3::length() const
|
||||
void Vector3::normalize()
|
||||
{
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%0) \n\t"
|
||||
"vmul.xyz vf5, vf4, vf4 \n\t"
|
||||
"vaddy.x vf5, vf5, vf5 \n\t"
|
||||
"vaddz.x vf5, vf5, vf5 \n\t"
|
||||
"vrsqrt Q, vf0w, vf5x \n\t"
|
||||
"lqc2 $vf4, 0x0(%0) \n\t"
|
||||
"vmul.xyz $vf5, $vf4, $vf4 \n\t"
|
||||
"vaddy.x $vf5, $vf5, $vf5 \n\t"
|
||||
"vaddz.x $vf5, $vf5, $vf5 \n\t"
|
||||
"vrsqrt $Q, $vf0w, $vf5x \n\t"
|
||||
"vwaitq \n\t"
|
||||
"vsub.xyz vf6, vf0, vf0 \n\t"
|
||||
"vaddw.xyz vf6, vf6, vf4 \n\t"
|
||||
"vsub.xyz $vf6, $vf0, $vf0 \n\t"
|
||||
"vaddw.xyz $vf6, $vf6, $vf4 \n\t"
|
||||
"vwaitq \n\t"
|
||||
"vmulq.xyz vf6, vf4, Q \n\t"
|
||||
"sqc2 vf6, 0x0(%0) \n\t"
|
||||
"vmulq.xyz $vf6, $vf4, $Q \n\t"
|
||||
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||
:
|
||||
: "r"(this->xyz));
|
||||
}
|
||||
@@ -194,16 +194,16 @@ float Vector3::distanceTo(const Vector3 &v) const
|
||||
{
|
||||
register float result;
|
||||
asm volatile( // VU0 Macro program
|
||||
"lqc2 vf4, 0x0(%1) \n\t"
|
||||
"lqc2 vf5, 0x0(%2) \n\t"
|
||||
"vsub.xyz vf6, vf4, vf5 \n\t"
|
||||
"vmul.xyz vf7, vf6, vf6 \n\t"
|
||||
"vaddy.x vf7, vf7, vf7 \n\t"
|
||||
"vaddz.x vf7, vf7, vf7 \n\t"
|
||||
"vsqrt Q , vf7x \n\t"
|
||||
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||
"vsub.xyz $vf6, $vf4, $vf5 \n\t"
|
||||
"vmul.xyz $vf7, $vf6, $vf6 \n\t"
|
||||
"vaddy.x $vf7, $vf7, $vf7 \n\t"
|
||||
"vaddz.x $vf7, $vf7, $vf7 \n\t"
|
||||
"vsqrt $Q , $vf7x \n\t"
|
||||
"vwaitq \n\t"
|
||||
"vaddq.x vf8, vf0, Q \n\t"
|
||||
"qmfc2 $2, vf8 \n\t"
|
||||
"vaddq.x $vf8, $vf0, $Q \n\t"
|
||||
"qmfc2 $2, $vf8 \n\t"
|
||||
"mtc1 $2, %0 \n\t"
|
||||
: "=f"(result)
|
||||
: "r"(this->xyz), "r"(v.xyz));
|
||||
@@ -217,20 +217,20 @@ u8 Vector3::shouldBeBackfaceCulled(const Vector3 *t_cameraPos, const Vector3 *t_
|
||||
{
|
||||
register float dot;
|
||||
asm volatile(
|
||||
"lqc2 vf4, 0x0(%1) \n\t" // vf4 = cameraPos
|
||||
"lqc2 vf5, 0x0(%2) \n\t" // vf5 = v0
|
||||
"lqc2 vf6, 0x0(%3) \n\t" // vf6 = v1
|
||||
"lqc2 vf7, 0x0(%4) \n\t" // vf7 = v2
|
||||
"vsub.xyz vf8, vf7, vf5 \n\t" // vf8 = vf7(v2) - vf5(v0)
|
||||
"vsub.xyz vf9, vf6, vf5 \n\t" // vf9 = vf6(v1) - vf5(v0)
|
||||
"vopmula.xyz ACC, vf8, vf9 \n\t" // vf6 = cross(vf8, vf9)
|
||||
"vopmsub.xyz vf6, vf9, vf8 \n\t"
|
||||
"vsub.w vf6, vf6, vf6 \n\t"
|
||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = vf5(v0) - vf4(cameraPos)
|
||||
"vmul.xyz vf5, vf7, vf6 \n\t" // vf5 = dot(vf7, vf6)
|
||||
"vaddy.x vf5, vf5, vf5 \n\t"
|
||||
"vaddz.x vf5, vf5, vf5 \n\t"
|
||||
"qmfc2 $2, vf5 \n\t" // store result on `dot` variable
|
||||
"lqc2 $vf4, 0x0(%1) \n\t" // $vf4 = cameraPos
|
||||
"lqc2 $vf5, 0x0(%2) \n\t" // $vf5 = v0
|
||||
"lqc2 $vf6, 0x0(%3) \n\t" // $vf6 = v1
|
||||
"lqc2 $vf7, 0x0(%4) \n\t" // $vf7 = v2
|
||||
"vsub.xyz $vf8, $vf7, $vf5 \n\t" // $vf8 = $vf7(v2) - $vf5(v0)
|
||||
"vsub.xyz $vf9, $vf6, $vf5 \n\t" // $vf9 = $vf6(v1) - $vf5(v0)
|
||||
"vopmula.xyz $ACC, $vf8, $vf9 \n\t" // $vf6 = cross($vf8, $vf9)
|
||||
"vopmsub.xyz $vf6, $vf9, $vf8 \n\t"
|
||||
"vsub.w $vf6, $vf6, $vf6 \n\t"
|
||||
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = $vf5(v0) - $vf4(cameraPos)
|
||||
"vmul.xyz $vf5, $vf7, $vf6 \n\t" // $vf5 = dot($vf7, $vf6)
|
||||
"vaddy.x $vf5, $vf5, $vf5 \n\t"
|
||||
"vaddz.x $vf5, $vf5, $vf5 \n\t"
|
||||
"qmfc2 $2, $vf5 \n\t" // store result on `dot` variable
|
||||
"mtc1 $2, %0 \n\t"
|
||||
: "=f"(dot)
|
||||
: "r"(t_cameraPos->xyz), "r"(t_v0->xyz), "r"(t_v1->xyz), "r"(t_v2->xyz));
|
||||
@@ -240,14 +240,14 @@ u8 Vector3::shouldBeBackfaceCulled(const Vector3 *t_cameraPos, const Vector3 *t_
|
||||
void Vector3::setByLerp(const Vector3 &t_v1, const Vector3 &t_v2, const float &t_interp, const float &t_scale)
|
||||
{
|
||||
asm volatile(
|
||||
"lqc2 vf4, 0x0(%1) \n\t" // vf4 = v1
|
||||
"lqc2 vf5, 0x0(%2) \n\t" // vf5 = v2
|
||||
"mfc1 $8, %3 \n\t" // vf6 = t
|
||||
"qmtc2 $8, vf6 \n\t" // lerp:
|
||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
||||
"sqc2 vf9, 0x0(%0) \n\t" // v0 = vf9
|
||||
"lqc2 $vf4, 0x0(%1) \n\t" // $vf4 = v1
|
||||
"lqc2 $vf5, 0x0(%2) \n\t" // $vf5 = v2
|
||||
"mfc1 $8, %3 \n\t" // $vf6 = t
|
||||
"qmtc2 $8, $vf6 \n\t" // lerp:
|
||||
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||
"sqc2 $vf9, 0x0(%0) \n\t" // v0 = $vf9
|
||||
:
|
||||
: "r"(&this->xyz), "r"(&t_v1.xyz), "r"(&t_v2.xyz), "f"(t_interp));
|
||||
operator*=(t_scale);
|
||||
|
||||
+58
-58
@@ -195,7 +195,7 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
||||
asm volatile(
|
||||
// VU0 macro program:
|
||||
// Load vector with 1.0F values to VF21
|
||||
"lqc2 vf21, 0x0(%0) \n\t" // load "one vec"
|
||||
"lqc2 $vf21, 0x0(%0) \n\t" // load "one vec"
|
||||
:
|
||||
: "r"(ONE_VEC));
|
||||
|
||||
@@ -221,34 +221,34 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
||||
// Calculate lerp() and store data into calc3Vectors
|
||||
|
||||
// Vertex 0
|
||||
"lqc2 vf4, 0x0(%3) \n\t" // vf4 = v1
|
||||
"lqc2 vf5, 0x0(%6) \n\t" // vf5 = v2
|
||||
"mfc1 $10, %9 \n\t" // vf6 = t
|
||||
"qmtc2 $10, vf6 \n\t" // lerp:
|
||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
||||
"sqc2 vf9, 0x0(%0) \n\t" // v0 = vf9
|
||||
"lqc2 $vf4, 0x0(%3) \n\t" // $vf4 = v1
|
||||
"lqc2 $vf5, 0x0(%6) \n\t" // $vf5 = v2
|
||||
"mfc1 $10, %9 \n\t" // $vf6 = t
|
||||
"qmtc2 $10, $vf6 \n\t" // lerp:
|
||||
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||
"sqc2 $vf9, 0x0(%0) \n\t" // v0 = $vf9
|
||||
|
||||
// Vertex 1
|
||||
"lqc2 vf4, 0x0(%4) \n\t" // vf4 = v1
|
||||
"lqc2 vf5, 0x0(%7) \n\t" // vf5 = v2
|
||||
"mfc1 $10, %9 \n\t" // vf6 = t
|
||||
"qmtc2 $10, vf6 \n\t" // lerp:
|
||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
||||
"sqc2 vf9, 0x0(%1) \n\t" // v0 = vf9
|
||||
"lqc2 $vf4, 0x0(%4) \n\t" // $vf4 = v1
|
||||
"lqc2 $vf5, 0x0(%7) \n\t" // $vf5 = v2
|
||||
"mfc1 $10, %9 \n\t" // $vf6 = t
|
||||
"qmtc2 $10, $vf6 \n\t" // lerp:
|
||||
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||
"sqc2 $vf9, 0x0(%1) \n\t" // v0 = $vf9
|
||||
|
||||
// Vertex 2
|
||||
"lqc2 vf4, 0x0(%5) \n\t" // vf4 = v1
|
||||
"lqc2 vf5, 0x0(%8) \n\t" // vf5 = v2
|
||||
"mfc1 $10, %9 \n\t" // vf6 = t
|
||||
"qmtc2 $10, vf6 \n\t" // lerp:
|
||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
||||
"sqc2 vf9, 0x0(%2) \n\t" // v0 = vf9
|
||||
"lqc2 $vf4, 0x0(%5) \n\t" // $vf4 = v1
|
||||
"lqc2 $vf5, 0x0(%8) \n\t" // $vf5 = v2
|
||||
"mfc1 $10, %9 \n\t" // $vf6 = t
|
||||
"qmtc2 $10, $vf6 \n\t" // lerp:
|
||||
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||
"sqc2 $vf9, 0x0(%2) \n\t" // v0 = $vf9
|
||||
|
||||
:
|
||||
: "r"(calc3Vectors[0].xyz),
|
||||
@@ -267,12 +267,12 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
||||
asm volatile(
|
||||
// VU0 macro program
|
||||
// Copy 0,1,2 vertices
|
||||
"lqc2 vf1, 0x0(%3) \n\t" // load vert
|
||||
"lqc2 vf2, 0x0(%4) \n\t" // load normal
|
||||
"lqc2 vf3, 0x0(%5) \n\t" // load st
|
||||
"sqc2 vf1, 0x0(%0) \n\t" // store vert
|
||||
"sqc2 vf2, 0x0(%1) \n\t" // store normal
|
||||
"sqc2 vf3, 0x0(%2) \n\t" // store st
|
||||
"lqc2 $vf1, 0x0(%3) \n\t" // load vert
|
||||
"lqc2 $vf2, 0x0(%4) \n\t" // load normal
|
||||
"lqc2 $vf3, 0x0(%5) \n\t" // load st
|
||||
"sqc2 $vf1, 0x0(%0) \n\t" // store vert
|
||||
"sqc2 $vf2, 0x0(%1) \n\t" // store normal
|
||||
"sqc2 $vf3, 0x0(%2) \n\t" // store st
|
||||
:
|
||||
: "r"(calc3Vectors[0].xyz),
|
||||
"r"(calc3Vectors[1].xyz),
|
||||
@@ -291,37 +291,37 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
||||
// Copy data and set vert/normal "w" and st "z"+"w" to 1.0F
|
||||
|
||||
// Vertex 0
|
||||
"lqc2 vf1, 0x0(%3) \n\t" // load vert
|
||||
"lqc2 vf2, 0x0(%4) \n\t" // load normal
|
||||
"lqc2 vf3, 0x0(%5) \n\t" // load st
|
||||
"vadd.w vf1, vf20, vf21 \n\t" // set vert.w to 1.0F
|
||||
"vadd.w vf2, vf20, vf21 \n\t" // set normal.W to 1.0F
|
||||
"vadd.zw vf3, vf20, vf21 \n\t" // set st.zw to 1.0F
|
||||
"sqc2 vf1, 0x0(%0) \n\t" // store vert
|
||||
"sqc2 vf2, 0x0(%1) \n\t" // store normal
|
||||
"sqc2 vf3, 0x0(%2) \n\t" // store st
|
||||
"lqc2 $vf1, 0x0(%3) \n\t" // load vert
|
||||
"lqc2 $vf2, 0x0(%4) \n\t" // load normal
|
||||
"lqc2 $vf3, 0x0(%5) \n\t" // load st
|
||||
"vadd.w $vf1, $vf20, $vf21 \n\t" // set vert.w to 1.0F
|
||||
"vadd.w $vf2, $vf20, $vf21 \n\t" // set normal.W to 1.0F
|
||||
"vadd.zw $vf3, $vf20, $vf21 \n\t" // set st.zw to 1.0F
|
||||
"sqc2 $vf1, 0x0(%0) \n\t" // store vert
|
||||
"sqc2 $vf2, 0x0(%1) \n\t" // store normal
|
||||
"sqc2 $vf3, 0x0(%2) \n\t" // store st
|
||||
|
||||
// Vertex 1
|
||||
"lqc2 vf1, 0x0(%9) \n\t" // load vert
|
||||
"lqc2 vf2, 0x0(%10) \n\t" // load normal
|
||||
"lqc2 vf3, 0x0(%11) \n\t" // load st
|
||||
"vadd.w vf1, vf20, vf21 \n\t" // set vert.w to 1.0F
|
||||
"vadd.w vf2, vf20, vf21 \n\t" // set normal.W to 1.0F
|
||||
"vadd.zw vf3, vf20, vf21 \n\t" // set st.zw to 1.0F
|
||||
"sqc2 vf1, 0x0(%6) \n\t" // store vert
|
||||
"sqc2 vf2, 0x0(%7) \n\t" // store normal
|
||||
"sqc2 vf3, 0x0(%8) \n\t" // store st
|
||||
"lqc2 $vf1, 0x0(%9) \n\t" // load vert
|
||||
"lqc2 $vf2, 0x0(%10) \n\t" // load normal
|
||||
"lqc2 $vf3, 0x0(%11) \n\t" // load st
|
||||
"vadd.w $vf1, $vf20, $vf21 \n\t" // set vert.w to 1.0F
|
||||
"vadd.w $vf2, $vf20, $vf21 \n\t" // set normal.W to 1.0F
|
||||
"vadd.zw $vf3, $vf20, $vf21 \n\t" // set st.zw to 1.0F
|
||||
"sqc2 $vf1, 0x0(%6) \n\t" // store vert
|
||||
"sqc2 $vf2, 0x0(%7) \n\t" // store normal
|
||||
"sqc2 $vf3, 0x0(%8) \n\t" // store st
|
||||
|
||||
// Vertex 2
|
||||
"lqc2 vf1, 0x0(%15) \n\t" // load vert
|
||||
"lqc2 vf2, 0x0(%16) \n\t" // load normal
|
||||
"lqc2 vf3, 0x0(%17) \n\t" // load st
|
||||
"vadd.w vf1, vf20, vf21 \n\t" // set vert.w to 1.0F
|
||||
"vadd.w vf2, vf20, vf21 \n\t" // set normal.W to 1.0F
|
||||
"vadd.zw vf3, vf20, vf21 \n\t" // set st.zw to 1.0F
|
||||
"sqc2 vf1, 0x0(%12) \n\t" // store vert
|
||||
"sqc2 vf2, 0x0(%13) \n\t" // store normal
|
||||
"sqc2 vf3, 0x0(%14) \n\t" // store st
|
||||
"lqc2 $vf1, 0x0(%15) \n\t" // load vert
|
||||
"lqc2 $vf2, 0x0(%16) \n\t" // load normal
|
||||
"lqc2 $vf3, 0x0(%17) \n\t" // load st
|
||||
"vadd.w $vf1, $vf20, $vf21 \n\t" // set vert.w to 1.0F
|
||||
"vadd.w $vf2, $vf20, $vf21 \n\t" // set normal.W to 1.0F
|
||||
"vadd.zw $vf3, $vf20, $vf21 \n\t" // set st.zw to 1.0F
|
||||
"sqc2 $vf1, 0x0(%12) \n\t" // store vert
|
||||
"sqc2 $vf2, 0x0(%13) \n\t" // store normal
|
||||
"sqc2 $vf3, 0x0(%14) \n\t" // store st
|
||||
|
||||
:
|
||||
: "r"(o_vertices[addedFaces]),
|
||||
|
||||
Reference in New Issue
Block a user