diff options
| author | iCatButler <i.am.catbutler@gmail.com> | 2016-05-02 15:01:27 +0100 |
|---|---|---|
| committer | iCatButler <i.am.catbutler@gmail.com> | 2016-05-02 15:01:27 +0100 |
| commit | 216c2ff3aefc9e0295ed9b1486935d65f6c13f55 (patch) | |
| tree | 88791c94e67ac8a5b99b9b39238ca4513077adf6 /plugins | |
| parent | 153c8eb4997d21d3b2965cf38d4348f05c29860f (diff) | |
| download | pcsxr-216c2ff3aefc9e0295ed9b1486935d65f6c13f55.tar.gz | |
Fix bugs from previous
Fix stray triangles
- Switch to full floating point RTPS/RTPT
- Clamp w values to near plane
Fix texture corruption in 1.78, copy 2.4 Tweak
- Remove matrix replacement
- Add W component to vertices
- Wrap glVertex3fv calls
- Use counter to call glVertex4fv for PGXP vertices only
Diffstat (limited to 'plugins')
| -rwxr-xr-x | plugins/peopsxgl/draw.c | 6 | ||||
| -rwxr-xr-x | plugins/peopsxgl/externals.h | 1 | ||||
| -rwxr-xr-x | plugins/peopsxgl/gpu.c | 20 | ||||
| -rw-r--r-- | plugins/peopsxgl/pgxp_gpu.c | 35 | ||||
| -rw-r--r-- | plugins/peopsxgl/pgxp_gpu.h | 3 | ||||
| -rwxr-xr-x | plugins/peopsxgl/prim.c | 80 |
6 files changed, 88 insertions, 57 deletions
diff --git a/plugins/peopsxgl/draw.c b/plugins/peopsxgl/draw.c index 0e2e440a..c7a778a8 100755 --- a/plugins/peopsxgl/draw.c +++ b/plugins/peopsxgl/draw.c @@ -599,10 +599,10 @@ int GLinitialize() glMatrixMode(GL_PROJECTION); // init projection with psx resolution glLoadIdentity(); - //glOrtho(0,PSXDisplay.DisplayMode.x, - // PSXDisplay.DisplayMode.y, 0, -1, 1); + glOrtho(0,PSXDisplay.DisplayMode.x, + PSXDisplay.DisplayMode.y, 0, -1, 1); - PGXP_SetMatrix(0, PSXDisplay.DisplayMode.x, PSXDisplay.DisplayMode.y, 0, -1, 1); + //PGXP_SetMatrix(0, PSXDisplay.DisplayMode.x, PSXDisplay.DisplayMode.y, 0, -1, 1); if(iZBufferDepth) // zbuffer? { diff --git a/plugins/peopsxgl/externals.h b/plugins/peopsxgl/externals.h index e793549e..a3f0a20f 100755 --- a/plugins/peopsxgl/externals.h +++ b/plugins/peopsxgl/externals.h @@ -183,6 +183,7 @@ typedef struct OGLVertexTag GLfloat x; GLfloat y; GLfloat z; + GLfloat w; GLfloat sow; GLfloat tow; diff --git a/plugins/peopsxgl/gpu.c b/plugins/peopsxgl/gpu.c index e38ac48b..2237351d 100755 --- a/plugins/peopsxgl/gpu.c +++ b/plugins/peopsxgl/gpu.c @@ -1222,16 +1222,16 @@ static __inline void XPRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex glBegin(GL_QUAD_STRIP); glTexCoord2fv(&vertex1->sow); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); glTexCoord2fv(&vertex2->sow); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); glTexCoord2fv(&vertex4->sow); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex4->x); glTexCoord2fv(&vertex3->sow); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); glEnd(); } @@ -1314,10 +1314,10 @@ void SetScanLines(void) } glLoadIdentity(); - //glOrtho(0,PSXDisplay.DisplayMode.x, - // PSXDisplay.DisplayMode.y, 0, -1, 1); + glOrtho(0,PSXDisplay.DisplayMode.x, + PSXDisplay.DisplayMode.y, 0, -1, 1); - PGXP_SetMatrix(0, PSXDisplay.DisplayMode.x, PSXDisplay.DisplayMode.y, 0, -1, 1); + //PGXP_SetMatrix(0, PSXDisplay.DisplayMode.x, PSXDisplay.DisplayMode.y, 0, -1, 1); if(bKeepRatio) @@ -1892,10 +1892,10 @@ void updateDisplayIfChanged(void) else // some res change? { glLoadIdentity(); - //glOrtho(0,PSXDisplay.DisplayModeNew.x, // -> new psx resolution - // PSXDisplay.DisplayModeNew.y, 0, -1, 1); + glOrtho(0,PSXDisplay.DisplayModeNew.x, // -> new psx resolution + PSXDisplay.DisplayModeNew.y, 0, -1, 1); - PGXP_SetMatrix(0, PSXDisplay.DisplayModeNew.x, PSXDisplay.DisplayModeNew.y, 0, -1, 1); + // PGXP_SetMatrix(0, PSXDisplay.DisplayModeNew.x, PSXDisplay.DisplayModeNew.y, 0, -1, 1); if(bKeepRatio) SetAspectRatio(); diff --git a/plugins/peopsxgl/pgxp_gpu.c b/plugins/peopsxgl/pgxp_gpu.c index eedf7b8d..98b7a94d 100644 --- a/plugins/peopsxgl/pgxp_gpu.c +++ b/plugins/peopsxgl/pgxp_gpu.c @@ -47,6 +47,9 @@ const unsigned int primCountTable[] = { 3, 3, 4, 4, 3, 3, 4, 4, 0 }; PGXP_vertex* PGXP_Mem = NULL; // pointer to parallel memory
unsigned int currentAddr = 0; // address of current DMA
+unsigned int numVertices = 0; // iCB: Used for glVertex3fv fix
+unsigned int vertexIdx = 0;
+
// Set current DMA address and pointer to parallel memory
void CALLBACK GPUpgxpMemory(unsigned int addr, unsigned char* pVRAM)
{
@@ -99,6 +102,26 @@ void PGXP_SetMatrix(float left, float right, float bottom, float top, float zNea //glOrtho(left, right, bottom, top, zNear, zFar);
}
+// Wrap glVertex3fv/glVertex4fv
+void PGXP_glVertexfv(GLfloat* pV)
+{
+ // If there are PGXP vertices expected
+ if (vertexIdx < numVertices)
+ {
+ // pre-multiply each element by w (to negate perspective divide)
+ for (unsigned int i = 0; i < 3; i++)
+ pV[i] *= pV[3];
+
+ // pass complete vertex to OpenGL
+ glVertex4fv(pV);
+ vertexIdx++;
+ }
+ else
+ {
+ glVertex3fv(pV);
+ }
+}
+
// Get parallel vertex values
int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs)
{
@@ -114,6 +137,10 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs) if (PGXP_Mem == NULL)
return 0;
+ // Reset vertex count
+ numVertices = count;
+ vertexIdx = 0;
+
// Offset to start of primitive
primStart = &PGXP_Mem[currentAddr + 1];
@@ -134,10 +161,10 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs) if (primStart[stride * i].valid)
{
- // Premultiply x,y coorindates by w because they've already been divided by w
- pVertex[i].x = (primStart[stride * i].x + xOffs) * w;
- pVertex[i].y = (primStart[stride * i].y + yOffs) * w;
- pVertex[i].z = w;
+ pVertex[i].x = (primStart[stride * i].x + xOffs);
+ pVertex[i].y = (primStart[stride * i].y + yOffs);
+ pVertex[i].z = 0.95f;
+ pVertex[i].w = w;
}
}
diff --git a/plugins/peopsxgl/pgxp_gpu.h b/plugins/peopsxgl/pgxp_gpu.h index 35fb5698..97c5b615 100644 --- a/plugins/peopsxgl/pgxp_gpu.h +++ b/plugins/peopsxgl/pgxp_gpu.h @@ -28,8 +28,11 @@ #ifndef _PGXP_GPU_H_
#define _PGXP_GPU_H_
+#include "stdafx.h"
+
void PGXP_SetMatrix(float left, float right, float bottom, float top, float zNear, float zFar);
void PGXP_SetAddress(unsigned int addr);
int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs);
+void PGXP_glVertexfv(GLfloat* pVertex);
#endif // _PGXP_GPU_H_
diff --git a/plugins/peopsxgl/prim.c b/plugins/peopsxgl/prim.c index adf6380e..ffa3fcf3 100755 --- a/plugins/peopsxgl/prim.c +++ b/plugins/peopsxgl/prim.c @@ -151,16 +151,16 @@ static __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2 { glBegin(GL_TRIANGLE_STRIP); glTexCoord2fv(&vertex1->sow); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); glTexCoord2fv(&vertex2->sow); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); glTexCoord2fv(&vertex4->sow); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex4->x); glTexCoord2fv(&vertex3->sow); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); glEnd(); } @@ -171,13 +171,13 @@ static __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2, { glBegin(GL_TRIANGLES); glTexCoord2fv(&vertex1->sow); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); glTexCoord2fv(&vertex2->sow); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); glTexCoord2fv(&vertex3->sow); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); glEnd(); } @@ -190,15 +190,15 @@ static __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* v SETPCOL(vertex1); glTexCoord2fv(&vertex1->sow); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); SETPCOL(vertex2); glTexCoord2fv(&vertex2->sow); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); SETPCOL(vertex3); glTexCoord2fv(&vertex3->sow); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); glEnd(); } @@ -210,19 +210,19 @@ static __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVerte glBegin(GL_TRIANGLE_STRIP); SETPCOL(vertex1); glTexCoord2fv(&vertex1->sow); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); SETPCOL(vertex2); glTexCoord2fv(&vertex2->sow); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); SETPCOL(vertex4); glTexCoord2fv(&vertex4->sow); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex4->x); SETPCOL(vertex3); glTexCoord2fv(&vertex3->sow); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); glEnd(); } @@ -231,9 +231,9 @@ static __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVerte static __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3) { glBegin(GL_TRIANGLES); - glVertex3fv(&vertex1->x); - glVertex3fv(&vertex2->x); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex1->x); + PGXP_glVertexfv(&vertex2->x); + PGXP_glVertexfv(&vertex3->x); glEnd(); } @@ -243,10 +243,10 @@ static __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4) { glBegin(GL_TRIANGLE_STRIP); - glVertex3fv(&vertex1->x); - glVertex3fv(&vertex3->x); - glVertex3fv(&vertex2->x); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex1->x); + PGXP_glVertexfv(&vertex3->x); + PGXP_glVertexfv(&vertex2->x); + PGXP_glVertexfv(&vertex4->x); glEnd(); } @@ -257,13 +257,13 @@ static __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vert { glBegin(GL_TRIANGLES); SETPCOL(vertex1); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); SETPCOL(vertex2); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); SETPCOL(vertex3); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); glEnd(); } @@ -274,16 +274,16 @@ static __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* ver { glBegin(GL_TRIANGLE_STRIP); SETPCOL(vertex1); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); SETPCOL(vertex3); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); SETPCOL(vertex2); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); SETPCOL(vertex4); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex4->x); glEnd(); } @@ -295,10 +295,10 @@ static __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGL SETPCOL(vertex1); - glVertex3fv(&vertex1->x); - glVertex3fv(&vertex2->x); - glVertex3fv(&vertex3->x); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex1->x); + PGXP_glVertexfv(&vertex2->x); + PGXP_glVertexfv(&vertex3->x); + PGXP_glVertexfv(&vertex4->x); glEnd(); } @@ -309,16 +309,16 @@ static __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2, glBegin(GL_QUADS); SETPCOL(vertex1); - glVertex3fv(&vertex1->x); + PGXP_glVertexfv(&vertex1->x); SETPCOL(vertex2); - glVertex3fv(&vertex2->x); + PGXP_glVertexfv(&vertex2->x); SETPCOL(vertex3); - glVertex3fv(&vertex3->x); + PGXP_glVertexfv(&vertex3->x); SETPCOL(vertex4); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex4->x); glEnd(); } @@ -328,10 +328,10 @@ static __inline void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4) { glBegin(GL_QUADS); - glVertex3fv(&vertex1->x); - glVertex3fv(&vertex2->x); - glVertex3fv(&vertex3->x); - glVertex3fv(&vertex4->x); + PGXP_glVertexfv(&vertex1->x); + PGXP_glVertexfv(&vertex2->x); + PGXP_glVertexfv(&vertex3->x); + PGXP_glVertexfv(&vertex4->x); glEnd(); } |
