summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoriCatButler <i.am.catbutler@gmail.com>2016-07-30 17:43:12 +0100
committeriCatButler <i.am.catbutler@gmail.com>2016-07-30 17:43:12 +0100
commit69f33a4782857bf2027db6c81f670409bed76b43 (patch)
treeca5ac7afe837748e8c1db89c2519eabf367df4ea /plugins
parentd5b40fbbe0eee90573ec1848ac135962fba9438e (diff)
downloadpcsxr-69f33a4782857bf2027db6c81f670409bed76b43.tar.gz
Various CPU updates
- Sign extend values read using LH - Add conversion functions to represent Signed/Unsigned 16-bit ranges - Add overflow and truncation functions for 16-bit ranges - Sign extend imm value in ADD(U) - Add component overflow and truncation to ADD/SUB functions - Construct new value in logic operators where result using inputs is undefined - Return a valid W component from logic operators (if either input has one) - Compare against high value (y), then low value (x) in less than operators - Use doubles and implement overflow for Multiply operations to try to increase accuracy - Use unsigned values in both MUL and DIV operations to make output as accurate as possible - Implement several variants of shift operators. Trying both arithmetically correct and more analytical approaches with varying success. Debug updates - Added ability to force all values to be equal to low precision values before operating on them - Added feature to test output of operations against a tolerance and print only those which fail GPU updates - Colour vertices with valid XY coordinates but no W as cyan to make them easier to spot - Remove cyan colouring for stale vertices (wasn't useful) - Added ability to skip debug rendering when needed (like seeing the output of offscreen rendering applied to a sprite). - Added new mode which shows primitive type
Diffstat (limited to 'plugins')
-rw-r--r--plugins/peopsxgl/pgxp_gpu.c93
-rw-r--r--plugins/peopsxgl/pgxp_gpu.h6
-rwxr-xr-xplugins/peopsxgl/prim.c22
3 files changed, 94 insertions, 27 deletions
diff --git a/plugins/peopsxgl/pgxp_gpu.c b/plugins/peopsxgl/pgxp_gpu.c
index 279f2dc9..8db849ba 100644
--- a/plugins/peopsxgl/pgxp_gpu.c
+++ b/plugins/peopsxgl/pgxp_gpu.c
@@ -305,20 +305,23 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs)
pVertex[i].PGXP_flag = 1;
if ((primStart[stride * i].flags & VALID_2) != VALID_2)
+ {
pVertex[i].PGXP_flag = 6;
+ // __Log("GPPV No W: v:%x (%d, %d) pgxp(%f, %f)|\n", (currentAddr + 1 + (i * stride)) * 4, pPrimData[stride * i * 2], pPrimData[(stride * i * 2) + 1], primStart[stride * i].x, primStart[stride * i].y);
+ }
// Log incorrect vertices
//if (PGXP_tDebug &&
- // (fabs((float)pPrimData[stride * i * 2] - pVertex[i].x) > debug_tolerance) ||
- // (fabs((float)pPrimData[(stride * i * 2) + 1] - pVertex[i].y) > debug_tolerance))
- // __Log("GPPV: v:%x (%d, %d) pgxp(%f, %f)|\n", (currentAddr + 1 + (i * stride)) * 4, pPrimData[stride * i * 2], pPrimData[(stride * i * 2) + 1], pVertex[i].x, pVertex[i].y);
+ // (fabs((float)pPrimData[stride * i * 2] - primStart[stride * i].x) > debug_tolerance) ||
+ // (fabs((float)pPrimData[(stride * i * 2) + 1] - primStart[stride * i].y) > debug_tolerance))
+ // __Log("GPPV: v:%x (%d, %d) pgxp(%f, %f)|\n", (currentAddr + 1 + (i * stride)) * 4, pPrimData[stride * i * 2], pPrimData[(stride * i * 2) + 1], primStart[stride * i].x, primStart[stride * i].y);
}
else
{
// Default to low precision vertex data
- if (primStart && ((primStart[stride * i].flags & VALID_01) == VALID_01) && primStart[stride * i].value != *(unsigned int*)(&pPrimData[stride * i * 2]))
- pVertex[i].PGXP_flag = 6;
- else
+ //if (primStart && ((primStart[stride * i].flags & VALID_01) == VALID_01) && primStart[stride * i].value != *(unsigned int*)(&pPrimData[stride * i * 2]))
+ // pVertex[i].PGXP_flag = 6;
+ //else
pVertex[i].PGXP_flag = 2;
// Look in cache for valid vertex
@@ -354,6 +357,10 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs)
for (unsigned i = 0; i < count; ++i)
pVertex[i].w = 1;
+ if(PGXP_vDebug == 3)
+ for (unsigned i = 0; i < count; ++i)
+ pVertex[i].PGXP_flag = primIdx;
+
return 1;
}
@@ -361,7 +368,7 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs)
//// Visual Debugging Functions
/////////////////////////////////
unsigned int PGXP_vDebug = 0;
-const unsigned int PGXP_maxDebug = 3;
+const unsigned int PGXP_maxDebug = 4;
const char red[4] = { 255, 0, 0, 255 };
const char blue[4] = { 0, 0, 255, 255 };
@@ -370,6 +377,9 @@ const char green[4] = { 0, 255, 0, 255 };
const char yellow[4] = { 255, 255, 0, 255 };
const char magenta[4] = { 255, 0, 255, 255 };
const char cyan[4] = { 0, 255, 255, 255 };
+
+const char orange[4] = { 255, 128 ,0 ,255 };
+
const char black[4] = { 0, 0, 0, 255 };
@@ -426,21 +436,57 @@ void PGXP_colour(OGLVertex* vertex)
fDepth = vertex->w / (float)(0xFFFF);
glColor4f(fDepth, fDepth, fDepth, 1.f);
break;
+ case 3:
+ // Primitive type
+ switch (vertex->PGXP_flag)
+ {
+ case 0:
+ pColour = yellow;
+ break;
+ case 1:
+ pColour = blue;
+ break;
+ case 2:
+ pColour = red;
+ break;
+ case 3:
+ pColour = green;
+ break;
+ case 4:
+ pColour = magenta;
+ break;
+ case 6:
+ pColour = cyan;
+ break;
+ case 7:
+ pColour = orange;
+ default:
+ pColour = black;
+ break;
+ }
+ glColor4ubv(pColour);
+ break;
}
}
-void PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
+int PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
{
GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
GLfloat fColour[4];
GLint iShadeModel;
+ //if ((vertex1->PGXP_flag == 0) ||
+ // (vertex2->PGXP_flag == 0) ||
+ // (vertex3->PGXP_flag == 0) ||
+ // (vertex4->PGXP_flag == 0))
+ // return 0;
+
// Quit if PGXP_flag == ignore
if ((vertex1->PGXP_flag == 5) ||
(vertex2->PGXP_flag == 5) ||
(vertex3->PGXP_flag == 5) ||
(vertex4->PGXP_flag == 5))
- return;
+ return 1;
glGetIntegerv(GL_SHADE_MODEL, &iShadeModel);
glGetFloatv(GL_CURRENT_COLOR, fColour);
@@ -486,19 +532,28 @@ void PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* ve
glEnable(GL_TEXTURE_2D);
glShadeModel(iShadeModel);
+
+ return 1;
}
-void PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
+int PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
{
GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
GLfloat fColour[4];
GLint iShadeModel;
+
+ //if ((vertex1->PGXP_flag == 0) ||
+ // (vertex2->PGXP_flag == 0) ||
+ // (vertex3->PGXP_flag == 0))
+ // return 0;
+
+
// Quit if PGXP_flag == ignore
if ((vertex1->PGXP_flag == 5) ||
(vertex2->PGXP_flag == 5) ||
(vertex3->PGXP_flag == 5))
- return;
+ return 1;
glGetIntegerv(GL_SHADE_MODEL, &iShadeModel);
glGetFloatv(GL_CURRENT_COLOR, fColour);
@@ -540,20 +595,30 @@ void PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex
glEnable(GL_TEXTURE_2D);
glShadeModel(iShadeModel);
+
+ return 1;
}
-void PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
+int PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
{
GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
GLfloat fColour[4];
GLint iShadeModel;
+
+ //if ((vertex1->PGXP_flag == 0) ||
+ // (vertex2->PGXP_flag == 0) ||
+ // (vertex3->PGXP_flag == 0) ||
+ // (vertex4->PGXP_flag == 0))
+ // return 0;
+
+
// Quit if PGXP_flag == ignore
if ((vertex1->PGXP_flag == 5) ||
(vertex2->PGXP_flag == 5) ||
(vertex3->PGXP_flag == 5) ||
(vertex4->PGXP_flag == 5))
- return;
+ return 1;
glGetIntegerv(GL_SHADE_MODEL, &iShadeModel);
glGetFloatv(GL_CURRENT_COLOR, fColour);
@@ -599,4 +664,6 @@ void PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* verte
glEnable(GL_TEXTURE_2D);
glShadeModel(iShadeModel);
+
+ return 1;
} \ No newline at end of file
diff --git a/plugins/peopsxgl/pgxp_gpu.h b/plugins/peopsxgl/pgxp_gpu.h
index df07ff46..aacc6912 100644
--- a/plugins/peopsxgl/pgxp_gpu.h
+++ b/plugins/peopsxgl/pgxp_gpu.h
@@ -42,8 +42,8 @@ void PGXP_glVertexfv(GLfloat* pVertex);
extern unsigned int PGXP_vDebug;
extern unsigned int PGXP_debugFlags[4];
-void PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4);
-void PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3);
-void PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4);
+int PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4);
+int PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3);
+int PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4);
#endif // _PGXP_GPU_H_
diff --git a/plugins/peopsxgl/prim.c b/plugins/peopsxgl/prim.c
index 8ea7d71b..7dd017e0 100755
--- a/plugins/peopsxgl/prim.c
+++ b/plugins/peopsxgl/prim.c
@@ -152,7 +152,7 @@ static __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3);
+ if(PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3))
return;
}
@@ -179,7 +179,7 @@ static __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ if(PGXP_DrawDebugTri(vertex1, vertex2, vertex3))
return;
}
@@ -202,7 +202,7 @@ static __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* v
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ if(PGXP_DrawDebugTri(vertex1, vertex2, vertex3))
return;
}
@@ -229,7 +229,7 @@ static __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVerte
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3);
+ if(PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3))
return;
}
@@ -258,7 +258,7 @@ static __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVert
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ if(PGXP_DrawDebugTri(vertex1, vertex2, vertex3))
return;
}
@@ -276,7 +276,7 @@ static __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4);
+ if(PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4))
return;
}
@@ -295,7 +295,7 @@ static __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vert
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ if(PGXP_DrawDebugTri(vertex1, vertex2, vertex3))
return;
}
@@ -318,7 +318,7 @@ static __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* ver
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4);
+ if(PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4))
return;
}
@@ -343,7 +343,7 @@ static __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGL
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ if(PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4))
return;
}
@@ -364,7 +364,7 @@ static __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ if(PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4))
return;
}
@@ -391,7 +391,7 @@ static __inline void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2,
{
if (PGXP_vDebug)
{
- PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ if(PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4))
return;
}