Support reversed buffer formats in the ge debugger.

So that it doesn't show garbage under the softgpu.
This commit is contained in:
Unknown W. Brackets 2013-11-11 00:42:33 -08:00
parent ce11fd7e4b
commit ac8edb4282
5 changed files with 40 additions and 9 deletions

View File

@ -38,22 +38,39 @@ enum GPUDebugBufferFormat {
GPU_DBG_FORMAT_8888 = 3,
GPU_DBG_FORMAT_INVALID = 0xFF,
// These are reversed versions.
GPU_DBG_FORMAT_REVERSE_FLAG = 4,
GPU_DBG_FORMAT_565_REV = 4,
GPU_DBG_FORMAT_5551_REV = 5,
GPU_DBG_FORMAT_4444_REV = 6,
// These don't, they're for depth/stencil buffers.
GPU_DBG_FORMAT_FLOAT = 0x10,
GPU_DBG_FORMAT_16BIT = 0x11,
GPU_DBG_FORMAT_8BIT = 0x12,
};
inline GPUDebugBufferFormat &operator |=(GPUDebugBufferFormat &lhs, const GPUDebugBufferFormat &rhs) {
lhs = GPUDebugBufferFormat((int)lhs | (int)rhs);
return lhs;
}
struct GPUDebugBuffer {
GPUDebugBuffer() : alloc_(false), data_(NULL) {
}
GPUDebugBuffer(void *data, u32 stride, u32 height, GEBufferFormat fmt)
GPUDebugBuffer(void *data, u32 stride, u32 height, GEBufferFormat fmt, bool reversed = false)
: alloc_(false), data_((u8 *)data), stride_(stride), height_(height), fmt_(GPUDebugBufferFormat(fmt)), flipped_(false) {
if (reversed && fmt_ < GPU_DBG_FORMAT_8888) {
fmt_ |= GPU_DBG_FORMAT_REVERSE_FLAG;
}
}
GPUDebugBuffer(void *data, u32 stride, u32 height, GETextureFormat fmt)
GPUDebugBuffer(void *data, u32 stride, u32 height, GETextureFormat fmt, bool reversed = false)
: alloc_(false), data_((u8 *)data), stride_(stride), height_(height), fmt_(GPUDebugBufferFormat(fmt)), flipped_(false) {
if (reversed && fmt_ < GPU_DBG_FORMAT_8888) {
fmt_ |= GPU_DBG_FORMAT_REVERSE_FLAG;
}
}
GPUDebugBuffer(void *data, u32 stride, u32 height, GPUDebugBufferFormat fmt)
@ -91,8 +108,12 @@ struct GPUDebugBuffer {
return *this;
}
void Allocate(u32 stride, u32 height, GEBufferFormat fmt, bool flipped = false) {
Allocate(stride, height, GPUDebugBufferFormat(fmt), flipped);
void Allocate(u32 stride, u32 height, GEBufferFormat fmt, bool flipped = false, bool reversed = false) {
GPUDebugBufferFormat actualFmt = GPUDebugBufferFormat(fmt);
if (reversed && actualFmt < GPU_DBG_FORMAT_8888) {
actualFmt |= GPU_DBG_FORMAT_REVERSE_FLAG;
}
Allocate(stride, height, actualFmt, flipped);
}
void Allocate(u32 stride, u32 height, GPUDebugBufferFormat fmt, bool flipped = false) {

View File

@ -1533,7 +1533,7 @@ bool FramebufferManager::GetCurrentFramebuffer(GPUDebugBuffer &buffer) {
return true;
}
buffer.Allocate(vfb->renderWidth, vfb->renderHeight, GE_FORMAT_8888, true);
buffer.Allocate(vfb->renderWidth, vfb->renderHeight, GE_FORMAT_8888, true, true);
if (vfb->fbo)
fbo_bind_for_read(vfb->fbo);
#ifndef USING_GLES2

View File

@ -224,6 +224,13 @@ void SimpleGLWindow::Draw(u8 *data, int w, int h, bool flipped, Format fmt) {
} else if (fmt == FORMAT_565) {
glfmt = GL_UNSIGNED_SHORT_5_6_5;
components = GL_RGB;
} else if (fmt == FORMAT_4444_REV) {
glfmt = GL_UNSIGNED_SHORT_4_4_4_4_REV;
} else if (fmt == FORMAT_5551_REV) {
glfmt = GL_UNSIGNED_SHORT_1_5_5_5_REV;
} else if (fmt == FORMAT_565_REV) {
glfmt = GL_UNSIGNED_SHORT_5_6_5_REV;
components = GL_RGB;
} else if (fmt == FORMAT_16BIT) {
glfmt = GL_UNSIGNED_SHORT;
components = GL_RED;

View File

@ -25,10 +25,13 @@ struct SimpleGLWindow {
static const PTCHAR windowClass;
enum Format {
FORMAT_565 = 0,
FORMAT_5551 = 1,
FORMAT_4444 = 2,
FORMAT_565_REV = 0,
FORMAT_5551_REV = 1,
FORMAT_4444_REV = 2,
FORMAT_8888 = 3,
FORMAT_565 = 4,
FORMAT_5551 = 5,
FORMAT_4444 = 6,
FORMAT_FLOAT = 0x10,
FORMAT_16BIT = 0x11,

View File

@ -31,7 +31,7 @@ void CGEDebugger::UpdatePrimPreview(u32 op) {
return;
}
if (!gpuDebug) {
ERROR_LOG(COMMON, "Invalid debugging environment, shutting down?", op);
ERROR_LOG(COMMON, "Invalid debugging environment, shutting down?");
return;
}
if (count == 0) {