Add PGXP visual debug mode

Toggles using F11
Red = low precision
Blue = high precision
Yellow = Sprite
This commit is contained in:
iCatButler 2016-05-10 21:34:27 +01:00
parent 1a30cfb951
commit b5a7387481
10 changed files with 272 additions and 10 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################
/SyncToy_b769e033-01a5-40b2-9c12-6b3a0fbe40a4.dat

View File

@ -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");

View File

@ -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;

View File

@ -193,6 +193,8 @@ typedef struct OGLVertexTag
unsigned char col[4];
unsigned int lcol;
} c;
unsigned int PGXP_flag;
} OGLVertex;
typedef union EXShortTag

View File

@ -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);

View File

@ -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);
}

View File

@ -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_

View File

@ -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);

View File

@ -188,6 +188,10 @@ void PADhandleKey(int key) {
LidInterrupt();
break;
case VK_F11:
GPU_toggleDebug();
break;
case VK_F12:
SysPrintf("*PCSXR*: CpuReset\n");
psxReset();

View File

@ -35,3 +35,5 @@ EXPORTS
GPUvisualVibration @28
GPUaddVertex @29
GPUpgxpMemory @30
GPUtoggleDebug @31