summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriCatButler <i.am.catbutler@gmail.com>2016-05-10 21:34:27 +0100
committeriCatButler <i.am.catbutler@gmail.com>2016-05-10 21:34:27 +0100
commitb5a738748175a460f856a1ed8a2e29fa26ebfb14 (patch)
tree8cc060819d9433940859de000bbb986cc45d7458
parent1a30cfb9510d4e46960010735d26a344f75cb328 (diff)
Add PGXP visual debug mode
Toggles using F11 Red = low precision Blue = high precision Yellow = Sprite
-rw-r--r--.gitignore5
-rwxr-xr-xlibpcsxcore/plugins.c3
-rwxr-xr-xlibpcsxcore/plugins.h2
-rwxr-xr-xplugins/peopsxgl/externals.h2
-rwxr-xr-xplugins/peopsxgl/gpu.c1
-rw-r--r--plugins/peopsxgl/pgxp_gpu.c184
-rw-r--r--plugins/peopsxgl/pgxp_gpu.h11
-rwxr-xr-xplugins/peopsxgl/prim.c68
-rwxr-xr-xwin32/gui/plugin.c4
-rwxr-xr-xwin32/plugins/peopsxgl/gpuPeopsOpenGL.def2
10 files changed, 272 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..94511dd7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+################################################################################
+# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
+################################################################################
+
+/SyncToy_b769e033-01a5-40b2-9c12-6b3a0fbe40a4.dat
diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c
index 352e8e5b..b42c5d1d 100755
--- a/libpcsxcore/plugins.c
+++ b/libpcsxcore/plugins.c
@@ -45,6 +45,7 @@ GPUdmaChain GPU_dmaChain;
GPUkeypressed GPU_keypressed;
GPUdisplayText GPU_displayText;
GPUmakeSnapshot GPU_makeSnapshot;
+GPUtoggleDebug GPU_toggleDebug;
GPUfreeze GPU_freeze;
GPUgetScreenPic GPU_getScreenPic;
GPUshowScreenPic GPU_showScreenPic;
@@ -207,6 +208,7 @@ long CALLBACK GPU__configure(void) { return 0; }
long CALLBACK GPU__test(void) { return 0; }
void CALLBACK GPU__about(void) {}
void CALLBACK GPU__makeSnapshot(void) {}
+void CALLBACK GPU__toggleDebug(void) {}
void CALLBACK GPU__keypressed(int key) {}
long CALLBACK GPU__getScreenPic(unsigned char *pMem) { return -1; }
long CALLBACK GPU__showScreenPic(unsigned char *pMem) { return -1; }
@@ -254,6 +256,7 @@ static int LoadGPUplugin(const char *GPUdll) {
LoadGpuSym0(keypressed, "GPUkeypressed");
LoadGpuSym0(displayText, "GPUdisplayText");
LoadGpuSym0(makeSnapshot, "GPUmakeSnapshot");
+ LoadGpuSym0(toggleDebug, "GPUtoggleDebug");
LoadGpuSym1(freeze, "GPUfreeze");
LoadGpuSym0(getScreenPic, "GPUgetScreenPic");
LoadGpuSym0(showScreenPic, "GPUshowScreenPic");
diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h
index c77c0ae0..07da50e3 100755
--- a/libpcsxcore/plugins.h
+++ b/libpcsxcore/plugins.h
@@ -79,6 +79,7 @@ typedef long (CALLBACK* GPUconfigure)(void);
typedef long (CALLBACK* GPUtest)(void);
typedef void (CALLBACK* GPUabout)(void);
typedef void (CALLBACK* GPUmakeSnapshot)(void);
+typedef void (CALLBACK* GPUtoggleDebug)(void);
typedef void (CALLBACK* GPUkeypressed)(int);
typedef void (CALLBACK* GPUdisplayText)(char *);
typedef struct {
@@ -118,6 +119,7 @@ extern GPUdmaChain GPU_dmaChain;
extern GPUkeypressed GPU_keypressed;
extern GPUdisplayText GPU_displayText;
extern GPUmakeSnapshot GPU_makeSnapshot;
+extern GPUtoggleDebug GPU_toggleDebug;
extern GPUfreeze GPU_freeze;
extern GPUgetScreenPic GPU_getScreenPic;
extern GPUshowScreenPic GPU_showScreenPic;
diff --git a/plugins/peopsxgl/externals.h b/plugins/peopsxgl/externals.h
index a3f0a20f..89c19743 100755
--- a/plugins/peopsxgl/externals.h
+++ b/plugins/peopsxgl/externals.h
@@ -193,6 +193,8 @@ typedef struct OGLVertexTag
unsigned char col[4];
unsigned int lcol;
} c;
+
+ unsigned int PGXP_flag;
} OGLVertex;
typedef union EXShortTag
diff --git a/plugins/peopsxgl/gpu.c b/plugins/peopsxgl/gpu.c
index fd784c51..5becb698 100755
--- a/plugins/peopsxgl/gpu.c
+++ b/plugins/peopsxgl/gpu.c
@@ -2986,6 +2986,7 @@ ENDVRAM:
vertex[i].x = vertex[i].y = 0.f;
vertex[i].z = 0.95f;
vertex[i].w = 1.f;
+ vertex[i].PGXP_flag = 0;
}
primFunc[gpuCommand]((unsigned char *)gpuDataM);
diff --git a/plugins/peopsxgl/pgxp_gpu.c b/plugins/peopsxgl/pgxp_gpu.c
index e8191e48..ece50795 100644
--- a/plugins/peopsxgl/pgxp_gpu.c
+++ b/plugins/peopsxgl/pgxp_gpu.c
@@ -106,25 +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 (1)//(vertexIdx < numVertices)
+ {
float temp[4];
memcpy(temp, pV, sizeof(float) * 4);
- // pre-multiply each element by w (to negate perspective divide)
+ //pre-multiply each element by w (to negate perspective divide)
for (unsigned int i = 0; i < 3; i++)
temp[i] *= temp[3];
- // pass complete vertex to OpenGL
+ //pass complete vertex to OpenGL
glVertex4fv(temp);
vertexIdx++;
- // pV[3] = 1.f;
- //}
- //else
- //{
- // glVertex3fv(pV);
- //}
+ //pV[3] = 1.f;
+ }
+ else
+ {
+ glVertex3fv(pV);
+ }
}
// Get parallel vertex values
@@ -170,9 +170,173 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs)
pVertex[i].y = (primStart[stride * i].y + yOffs);
pVertex[i].z = 0.95f;
pVertex[i].w = w;
+ pVertex[i].PGXP_flag = 1;
}
+ else
+ pVertex[i].PGXP_flag = 2;
}
return 1;
}
+/////////////////////////////////
+//// Visual Debugging Functions
+/////////////////////////////////
+unsigned int PGXP_vDebug = 0;
+
+const char blue[4] = { 0, 0, 255, 255 };
+const char red[4] = { 255, 0, 0, 255 };
+const char black[4] = { 0, 0, 0, 255 };
+const char yellow[4] = { 255, 255, 0, 255 };
+
+void CALLBACK GPUtoggleDebug(void)
+{
+ if (PGXP_vDebug)
+ PGXP_vDebug = 0;
+ else
+ PGXP_vDebug = 1;
+}
+
+const char* PGXP_colour(unsigned int flag)
+{
+ switch (flag)
+ {
+ case 0:
+ return yellow;
+ case 1:
+ return blue;
+ case 2:
+ return red;
+ default:
+ return black;
+ }
+}
+
+void PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
+{
+ GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
+ GLfloat fColour[4];
+ glGetFloatv(GL_CURRENT_COLOR, fColour);
+ glDisable(GL_TEXTURE_2D);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(PGXP_colour(vertex1->PGXP_flag));
+ PGXP_glVertexfv(&vertex1->x);
+
+ glColor4ubv(PGXP_colour(vertex2->PGXP_flag));
+ PGXP_glVertexfv(&vertex2->x);
+
+ glColor4ubv(PGXP_colour(vertex3->PGXP_flag));
+ PGXP_glVertexfv(&vertex3->x);
+
+ glColor4ubv(PGXP_colour(vertex4->PGXP_flag));
+ PGXP_glVertexfv(&vertex4->x);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(black);
+ PGXP_glVertexfv(&vertex1->x);
+ PGXP_glVertexfv(&vertex2->x);
+ PGXP_glVertexfv(&vertex3->x);
+ PGXP_glVertexfv(&vertex4->x);
+
+ glColor4fv(fColour);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glPolygonMode(GL_BACK, GL_FILL);
+
+ if(bTexture == GL_TRUE)
+ glEnable(GL_TEXTURE_2D);
+}
+
+void PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
+{
+ GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
+ GLfloat fColour[4];
+ glGetFloatv(GL_CURRENT_COLOR, fColour);
+ glDisable(GL_TEXTURE_2D);
+
+ glBegin(GL_TRIANGLES);
+
+ glColor4ubv(PGXP_colour(vertex1->PGXP_flag));
+ PGXP_glVertexfv(&vertex1->x);
+
+ glColor4ubv(PGXP_colour(vertex2->PGXP_flag));
+ PGXP_glVertexfv(&vertex2->x);
+
+ glColor4ubv(PGXP_colour(vertex3->PGXP_flag));
+ PGXP_glVertexfv(&vertex3->x);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(black);
+ PGXP_glVertexfv(&vertex1->x);
+ PGXP_glVertexfv(&vertex2->x);
+ PGXP_glVertexfv(&vertex3->x);
+
+ glColor4fv(fColour);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glPolygonMode(GL_BACK, GL_FILL);
+
+ if (bTexture == GL_TRUE)
+ glEnable(GL_TEXTURE_2D);
+}
+
+void PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
+{
+ GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
+ GLfloat fColour[4];
+ glGetFloatv(GL_CURRENT_COLOR, fColour);
+ glDisable(GL_TEXTURE_2D);
+
+ glBegin(GL_QUADS);
+ glColor4ubv(PGXP_colour(vertex1->PGXP_flag));
+ PGXP_glVertexfv(&vertex1->x);
+
+ glColor4ubv(PGXP_colour(vertex2->PGXP_flag));
+ PGXP_glVertexfv(&vertex2->x);
+
+ glColor4ubv(PGXP_colour(vertex3->PGXP_flag));
+ PGXP_glVertexfv(&vertex3->x);
+
+ glColor4ubv(PGXP_colour(vertex4->PGXP_flag));
+ PGXP_glVertexfv(&vertex4->x);
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(black);
+ PGXP_glVertexfv(&vertex1->x);
+ PGXP_glVertexfv(&vertex2->x);
+ PGXP_glVertexfv(&vertex3->x);
+ PGXP_glVertexfv(&vertex4->x);
+
+ glColor4fv(fColour);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glPolygonMode(GL_BACK, GL_FILL);
+
+ if (bTexture == GL_TRUE)
+ glEnable(GL_TEXTURE_2D);
+} \ No newline at end of file
diff --git a/plugins/peopsxgl/pgxp_gpu.h b/plugins/peopsxgl/pgxp_gpu.h
index 97c5b615..df07ff46 100644
--- a/plugins/peopsxgl/pgxp_gpu.h
+++ b/plugins/peopsxgl/pgxp_gpu.h
@@ -30,9 +30,20 @@
#include "stdafx.h"
+//struct OGLVertex;
+
+struct OGLVertexTag;
+typedef struct OGLVertexTag OGLVertex;
+
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);
+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);
+
#endif // _PGXP_GPU_H_
diff --git a/plugins/peopsxgl/prim.c b/plugins/peopsxgl/prim.c
index ffa3fcf3..eb4b7f01 100755
--- a/plugins/peopsxgl/prim.c
+++ b/plugins/peopsxgl/prim.c
@@ -25,6 +25,7 @@
#include "draw.h"
#include "soft.h"
#include "texture.h"
+#include "PGXP_gpu.h"
////////////////////////////////////////////////////////////////////////
// defines
@@ -149,6 +150,13 @@ unsigned short BGR24to16 (uint32_t BGR)
static __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3);
+ return;
+ }
+
+
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2fv(&vertex1->sow);
PGXP_glVertexfv(&vertex1->x);
@@ -169,6 +177,12 @@ static __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2
static __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
glTexCoord2fv(&vertex1->sow);
PGXP_glVertexfv(&vertex1->x);
@@ -186,6 +200,12 @@ static __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
static __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
SETPCOL(vertex1);
@@ -207,6 +227,12 @@ static __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* v
static __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLE_STRIP);
SETPCOL(vertex1);
glTexCoord2fv(&vertex1->sow);
@@ -230,6 +256,12 @@ static __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVerte
static __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
PGXP_glVertexfv(&vertex1->x);
PGXP_glVertexfv(&vertex2->x);
@@ -242,6 +274,12 @@ static __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVert
static __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4);
+ return;
+ }
+
glBegin(GL_TRIANGLE_STRIP);
PGXP_glVertexfv(&vertex1->x);
PGXP_glVertexfv(&vertex3->x);
@@ -255,6 +293,12 @@ static __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
static __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
SETPCOL(vertex1);
PGXP_glVertexfv(&vertex1->x);
@@ -272,6 +316,12 @@ static __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vert
static __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4);
+ return;
+ }
+
glBegin(GL_TRIANGLE_STRIP);
SETPCOL(vertex1);
PGXP_glVertexfv(&vertex1->x);
@@ -291,6 +341,12 @@ static __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* ver
static __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ return;
+ }
+
glBegin(GL_QUADS);
SETPCOL(vertex1);
@@ -306,6 +362,12 @@ static __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGL
static __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ return;
+ }
+
glBegin(GL_QUADS);
SETPCOL(vertex1);
@@ -327,6 +389,12 @@ static __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,
static __inline void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ return;
+ }
+
glBegin(GL_QUADS);
PGXP_glVertexfv(&vertex1->x);
PGXP_glVertexfv(&vertex2->x);
diff --git a/win32/gui/plugin.c b/win32/gui/plugin.c
index 6c79a0dc..35b4e445 100755
--- a/win32/gui/plugin.c
+++ b/win32/gui/plugin.c
@@ -188,6 +188,10 @@ void PADhandleKey(int key) {
LidInterrupt();
break;
+ case VK_F11:
+ GPU_toggleDebug();
+ break;
+
case VK_F12:
SysPrintf("*PCSXR*: CpuReset\n");
psxReset();
diff --git a/win32/plugins/peopsxgl/gpuPeopsOpenGL.def b/win32/plugins/peopsxgl/gpuPeopsOpenGL.def
index 83d853a7..88d121ff 100755
--- a/win32/plugins/peopsxgl/gpuPeopsOpenGL.def
+++ b/win32/plugins/peopsxgl/gpuPeopsOpenGL.def
@@ -35,3 +35,5 @@ EXPORTS
GPUvisualVibration @28
GPUaddVertex @29
GPUpgxpMemory @30
+
+ GPUtoggleDebug @31