diff options
| author | iCatButler <i.am.catbutler@gmail.com> | 2016-05-06 17:12:31 +0100 |
|---|---|---|
| committer | iCatButler <i.am.catbutler@gmail.com> | 2016-05-06 17:12:31 +0100 |
| commit | ca61b53f6c99e49de4620395bc8dbe5b71c9e2db (patch) | |
| tree | ff573393e15c8eb343d499c637c4bc846419024e | |
| parent | 4b706847d4ffbaa72b2d2a39130f71b0d2a401b6 (diff) | |
| download | pcsxr-ca61b53f6c99e49de4620395bc8dbe5b71c9e2db.tar.gz | |
More fixes for persective correct build
- Switch back to fixed point GTE
- Only clamp w to h/2 after divide
- Fix vertex function for multi-pass (was overwriting vertexon first pass)
| -rwxr-xr-x | libpcsxcore/gte.c | 25 | ||||
| -rw-r--r-- | libpcsxcore/pgxp_gte.c | 31 | ||||
| -rw-r--r-- | plugins/peopsxgl/pgxp_gpu.c | 23 |
3 files changed, 56 insertions, 23 deletions
diff --git a/libpcsxcore/gte.c b/libpcsxcore/gte.c index abe3c205..2938d170 100755 --- a/libpcsxcore/gte.c +++ b/libpcsxcore/gte.c @@ -497,11 +497,11 @@ int docop2(int op) { SX2 = Lm_G1(F((s64) OFX + ((s64) IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)) >> 16); SY2 = Lm_G2(F((s64) OFY + ((s64) IR2 * h_over_sz3)) >> 16); - //PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), - // Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), - // SZ3, SXY2); + PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), + Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), + max(SZ3, H/2), SXY2); - PGXP_RTPS(0, SXY2); + //PGXP_RTPS(0, SXY2); MAC0 = F((s64) DQB + ((s64) DQA * h_over_sz3)); IR0 = Lm_H(m_mac0, 1); @@ -888,12 +888,19 @@ int docop2(int op) { SXY1 = SXY2; SX2 = Lm_G1(F((s64) OFX + ((s64) IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)) >> 16); SY2 = Lm_G2(F((s64) OFY + ((s64) IR2 * h_over_sz3)) >> 16); - - //PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), - // Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), - // SZ3, SXY2); - PGXP_RTPS(v, SXY2); + //float tempMx = MAC1; + //float tempx = IR1; + //float temphow = (float)h_over_sz3 / (float)(1 << 16); + + //float tempMz = MAC3; + //float tempZ = SZ3; + // + PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), + Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), + max(SZ3, H/2), SXY2); + + //PGXP_RTPS(v, SXY2); } MAC0 = F((s64) DQB + ((s64) DQA * h_over_sz3)); diff --git a/libpcsxcore/pgxp_gte.c b/libpcsxcore/pgxp_gte.c index 3ee5db22..3844e6be 100644 --- a/libpcsxcore/pgxp_gte.c +++ b/libpcsxcore/pgxp_gte.c @@ -306,19 +306,42 @@ void PGXP_RTPS(u32 _n, u32 _v) float MAC2 = TRY + (R21 * VX(_n)) + (R22 * VY(_n)) + (R23 * VZ(_n));
float MAC3 = TRZ + (R31 * VX(_n)) + (R32 * VY(_n)) + (R33 * VZ(_n));
+ float IR1 = max(min(MAC1, 0x7fff), -0x8000);
+ float IR2 = max(min(MAC2, 0x7fff), -0x8000);
+ float IR3 = max(min(MAC3, 0x7fff), -0x8000);
+
float H = psxRegs.CP2C.p[26].sw.l; // Near plane
float F = 0xFFFF; // Far plane?
- float SZ3 = max(MAC3, H); // Clamp SZ3 to near plane because we have no clipping (no proper Z)
+ float SZ3 = max(min(MAC3, 0xffff), 0x0000); // Clamp SZ3 to near plane because we have no clipping (no proper Z)
// float h_over_sz3 = H / SZ3;
// Offsets with 16-bit shift
float OFX = (float)psxRegs.CP2C.p[24].sd / (float)(1 << 16);
float OFY = (float)psxRegs.CP2C.p[25].sd / (float)(1 << 16);
+ float h_over_w = min(H / SZ3, (float)0x1ffff / (float)0xffff);
+ h_over_w = (SZ3 == 0) ? ((float)0x1ffff / (float)0xffff) : h_over_w;
+
// PSX Screen space X,Y,W components
- float sx = OFX + (MAC1 * (H / SZ3)) * (Config.Widescreen ? 0.75 : 1);
- float sy = OFY + (MAC2 * (H / SZ3));
- float sw = SZ3;
+ float sx = OFX + (IR1 * h_over_w) * (Config.Widescreen ? 0.75 : 1);
+ float sy = OFY + (IR2 * h_over_w);
+ float sw = SZ3;// max(SZ3, 0.1);
+
+ sx = max(min(sx, 1024.f), -1024.f);
+ sy = max(min(sy, 1024.f), -1024.f);
+
+ //float sx2 = SX2;
+ //float sy2 = SY2;
+ //float sz2 = SXY2.z;
+
+ //float ftolerance = 5.f;
+
+ //if ((fabs(sx - sx2) > ftolerance) ||
+ // (fabs(sy - sy2) > ftolerance) ||
+ // (fabs(sw - sz2) > ftolerance))
+ //{
+ // float r = 5;
+ //}
PGXP_pushSXYZ2f(sx , sy , sw, _v);
diff --git a/plugins/peopsxgl/pgxp_gpu.c b/plugins/peopsxgl/pgxp_gpu.c index 67b381d8..e8191e48 100644 --- a/plugins/peopsxgl/pgxp_gpu.c +++ b/plugins/peopsxgl/pgxp_gpu.c @@ -106,22 +106,25 @@ void PGXP_SetMatrix(float left, float right, float bottom, float top, float zNea void PGXP_glVertexfv(GLfloat* pV)
{
// If there are PGXP vertices expected
- if (vertexIdx < numVertices)
- {
+ //if (vertexIdx < numVertices)
+ //{
+ float temp[4];
+ memcpy(temp, pV, sizeof(float) * 4);
+
// pre-multiply each element by w (to negate perspective divide)
for (unsigned int i = 0; i < 3; i++)
- pV[i] *= pV[3];
+ temp[i] *= temp[3];
// pass complete vertex to OpenGL
- glVertex4fv(pV);
+ glVertex4fv(temp);
vertexIdx++;
- pV[3] = 1.f;
- }
- else
- {
- glVertex3fv(pV);
- }
+ // pV[3] = 1.f;
+ //}
+ //else
+ //{
+ // glVertex3fv(pV);
+ //}
}
// Get parallel vertex values
|
