[Video] Remove VPDEBUG code

This commit is contained in:
zilmar 2017-05-22 17:59:04 +10:00
parent c34739d528
commit 02b46a5f74
4 changed files with 0 additions and 305 deletions

View File

@ -34,10 +34,6 @@
#define OPENGL_CHECK_ERRORS { const GLenum errcode = glGetError(); if (errcode != GL_NO_ERROR) LOG("OpenGL Error code %i in '%s' line %i\n", errcode, __FILE__, __LINE__-1); }
#ifdef VPDEBUG
#include <IL/il.h>
#endif
extern void(*renderCallback)(int);
wrapper_config config = { 0, 0, 0 };
@ -1449,30 +1445,6 @@ grBufferSwap(FxU32 swap_interval)
#endif
for (i = 0; i < nb_fb; i++)
fbs[i].buff_clear = 1;
// VP debugging
#ifdef VPDEBUG
dump_stop();
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case 'd':
printf("Dumping !\n");
dump_start();
break;
case 'w': {
static int wireframe;
wireframe = !wireframe;
glPolygonMode(GL_FRONT_AND_BACK, wireframe ? GL_LINE : GL_FILL);
break;
}
}
break;
}
}
#endif
}
// frame buffer
@ -1710,17 +1682,6 @@ grLfbWriteRegion(GrBuffer_t dst_buffer,
WriteTrace(TraceGlitch, TraceWarning, "grLfbWriteRegion : unknown format : %d", src_format);
}
#ifdef VPDEBUG
if (dumping) {
ilTexImage(tex_width, tex_height, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, buf);
char name[128];
static int id;
sprintf(name, "dump/writecolor%d.png", id++);
ilSaveImage(name);
//printf("dumped gdLfbWriteRegion %s\n", name);
}
#endif
glBindTexture(GL_TEXTURE_2D, default_texture);
glTexImage2D(GL_TEXTURE_2D, 0, 4, tex_width, tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
free(buf);
@ -1753,21 +1714,6 @@ grLfbWriteRegion(GrBuffer_t dst_buffer,
}
}
#ifdef VPDEBUG
if (dumping) {
unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (g_viewport_offset)));
for (i = 0; i < src_width*src_height; i++)
buf2[i] = buf[i] * 255.0f;
ilTexImage(src_width, src_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buf2);
char name[128];
static int id;
sprintf(name, "dump/writedepth%d.png", id++);
ilSaveImage(name);
//printf("dumped gdLfbWriteRegion %s\n", name);
free(buf2);
}
#endif
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
@ -1853,110 +1799,6 @@ guGammaCorrectionRGB(FxFloat gammaR, FxFloat gammaG, FxFloat gammaB)
CorrectGamma(aGammaRamp);*/
}
// VP debug
#ifdef VPDEBUG
int dumping = 0;
static int tl_i;
static int tl[10240];
void dump_start()
{
static int init;
if (!init) {
init = 1;
ilInit();
ilEnable(IL_FILE_OVERWRITE);
}
dumping = 1;
tl_i = 0;
}
void dump_stop()
{
if (!dumping) return;
int i, j;
for (i = 0; i < nb_fb; i++) {
dump_tex(fbs[i].texid);
}
dump_tex(default_texture);
dump_tex(depth_texture);
dumping = 0;
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer);
ilTexImage(width, height, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, frameBuffer);
ilSaveImage("dump/framecolor.png");
glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer);
// FILE * fp = fopen("glide_depth1.bin", "rb");
// fread(depthBuffer, 2, width*height, fp);
// fclose(fp);
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
//uint16_t d = ( (uint16_t *)depthBuffer )[i+(height-1-j)*width]/2 + 0x8000;
uint16_t d = ((uint16_t *)depthBuffer)[i + j*width];
uint32_t c = ((uint32_t *)frameBuffer)[i + j*width];
((unsigned char *)frameBuffer)[(i + j*width) * 3] = d & 0xff;
((unsigned char *)frameBuffer)[(i + j*width) * 3 + 1] = d >> 8;
((unsigned char *)frameBuffer)[(i + j*width) * 3 + 2] = c & 0xff;
}
}
ilTexImage(width, height, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, frameBuffer);
ilSaveImage("dump/framedepth.png");
for (i = 0; i < tl_i; i++) {
glBindTexture(GL_TEXTURE_2D, tl[i]);
GLint w, h, fmt;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
fprintf(stderr, "Texture %d %dx%d fmt %x\n", tl[i], (int)w, (int)h, (int)fmt);
uint32_t * pixels = (uint32_t *)malloc(w*h * 4);
// 0x1902 is another constant meaning GL_DEPTH_COMPONENT
// (but isn't defined in gl's headers !!)
if (fmt != GL_DEPTH_COMPONENT && fmt != 0x1902) {
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
ilTexImage(w, h, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, pixels);
}
else {
glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, pixels);
int i;
for (i = 0; i < w*h; i++)
((unsigned char *)frameBuffer)[i] = ((unsigned short *)pixels)[i] / 256;
ilTexImage(w, h, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, frameBuffer);
}
char name[128];
// sprintf(name, "mkdir -p dump ; rm -f dump/tex%04d.png", i);
// system(name);
sprintf(name, "dump/tex%04d.png", i);
fprintf(stderr, "Writing '%s'\n", name);
ilSaveImage(name);
// SDL_FreeSurface(surf);
free(pixels);
}
glBindTexture(GL_TEXTURE_2D, default_texture);
}
void dump_tex(int id)
{
if (!dumping) return;
int n;
// yes, it's inefficient
for (n = 0; n < tl_i; n++)
if (tl[n] == id)
return;
tl[tl_i++] = id;
int i = tl_i - 1;
}
#endif
void CHECK_FRAMEBUFFER_STATUS(void)
{
GLenum status;

View File

@ -673,9 +673,6 @@ grTexSource(GrChipID_t tmu,
}
glBindTexture(GL_TEXTURE_2D, startAddress + 1);
#ifdef VPDEBUG
dump_tex(startAddress + 1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s0);
@ -697,9 +694,6 @@ grTexSource(GrChipID_t tmu,
}
glBindTexture(GL_TEXTURE_2D, startAddress + 1);
#ifdef VPDEBUG
dump_tex(startAddress + 1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s1);

View File

@ -33,10 +33,6 @@
#include <Project64-video/trace.h>
#include <Common/Util.h>
#ifdef VPDEBUG
#include <IL/il.h>
#endif
/*
* `GetSystemSetting` and `FindSystemSettingId` from Project64 debugger
* used only in g_Notify->DisplayError when OpenGL extension loading fails on WGL
@ -1958,17 +1954,6 @@ grLfbWriteRegion(GrBuffer_t dst_buffer,
WriteTrace(TraceGlitch, TraceWarning, "grLfbWriteRegion : unknown format : %d", src_format);
}
#ifdef VPDEBUG
if (dumping) {
ilTexImage(tex_width, tex_height, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, buf);
char name[128];
static int id;
sprintf(name, "dump/writecolor%d.png", id++);
ilSaveImage(name);
//printf("dumped gdLfbWriteRegion %s\n", name);
}
#endif
glBindTexture(GL_TEXTURE_2D, default_texture);
glTexImage2D(GL_TEXTURE_2D, 0, 4, tex_width, tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
free(buf);
@ -2001,21 +1986,6 @@ grLfbWriteRegion(GrBuffer_t dst_buffer,
}
}
#ifdef VPDEBUG
if (dumping) {
unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (g_viewport_offset)));
for (i = 0; i < src_width*src_height; i++)
buf2[i] = buf[i] * 255.0f;
ilTexImage(src_width, src_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buf2);
char name[128];
static int id;
sprintf(name, "dump/writedepth%d.png", id++);
ilSaveImage(name);
//printf("dumped gdLfbWriteRegion %s\n", name);
free(buf2);
}
#endif
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
@ -2184,111 +2154,6 @@ int grDisplayGLError(const char* message)
}
#endif
// VP debug
#ifdef VPDEBUG
int dumping = 0;
static int tl_i;
static int tl[10240];
void dump_start()
{
static int init;
if (!init) {
init = 1;
ilInit();
ilEnable(IL_FILE_OVERWRITE);
}
dumping = 1;
tl_i = 0;
}
void dump_stop()
{
if (!dumping) return;
int i, j;
for (i = 0; i < nb_fb; i++) {
dump_tex(fbs[i].texid);
}
dump_tex(default_texture);
dump_tex(depth_texture);
dumping = 0;
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer);
ilTexImage(width, height, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, frameBuffer);
ilSaveImage("dump/framecolor.png");
glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer);
// FILE * fp = fopen("glide_depth1.bin", "rb");
// fread(depthBuffer, 2, width*height, fp);
// fclose(fp);
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
//uint16_t d = ( (uint16_t *)depthBuffer )[i+(height-1-j)*width]/2 + 0x8000;
uint16_t d = ((uint16_t *)depthBuffer)[i + j*width];
uint32_t c = ((uint32_t *)frameBuffer)[i + j*width];
((unsigned char *)frameBuffer)[(i + j*width) * 3] = d & 0xff;
((unsigned char *)frameBuffer)[(i + j*width) * 3 + 1] = d >> 8;
((unsigned char *)frameBuffer)[(i + j*width) * 3 + 2] = c & 0xff;
}
}
ilTexImage(width, height, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, frameBuffer);
ilSaveImage("dump/framedepth.png");
for (i = 0; i < tl_i; i++) {
glBindTexture(GL_TEXTURE_2D, tl[i]);
GLint w, h, fmt;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
fprintf(stderr, "Texture %d %dx%d fmt %x\n", tl[i], (int)w, (int)h, (int)fmt);
uint32_t * pixels = (uint32_t *)malloc(w*h * 4);
// 0x1902 is another constant meaning GL_DEPTH_COMPONENT
// (but isn't defined in gl's headers !!)
if (fmt != GL_DEPTH_COMPONENT && fmt != 0x1902) {
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
ilTexImage(w, h, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, pixels);
}
else {
glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, pixels);
int i;
for (i = 0; i < w*h; i++)
((unsigned char *)frameBuffer)[i] = ((unsigned short *)pixels)[i] / 256;
ilTexImage(w, h, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, frameBuffer);
}
char name[128];
// sprintf(name, "mkdir -p dump ; rm -f dump/tex%04d.png", i);
// system(name);
sprintf(name, "dump/tex%04d.png", i);
fprintf(stderr, "Writing '%s'\n", name);
ilSaveImage(name);
// SDL_FreeSurface(surf);
free(pixels);
}
glBindTexture(GL_TEXTURE_2D, default_texture);
grDisplayGLError("dump_stop");
}
void dump_tex(int id)
{
if (!dumping) return;
int n;
// yes, it's inefficient
for (n = 0; n < tl_i; n++)
if (tl[n] == id)
return;
tl[tl_i++] = id;
int i = tl_i - 1;
}
#endif
void CHECK_FRAMEBUFFER_STATUS()
{
GLenum status;

View File

@ -670,9 +670,6 @@ grTexSource(GrChipID_t tmu,
}
glBindTexture(GL_TEXTURE_2D, startAddress + 1);
#ifdef VPDEBUG
dump_tex(startAddress + 1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s0);
@ -694,9 +691,6 @@ grTexSource(GrChipID_t tmu,
}
glBindTexture(GL_TEXTURE_2D, startAddress + 1);
#ifdef VPDEBUG
dump_tex(startAddress + 1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s1);