Grab the stencil buffer in softgpu debugging.

This commit is contained in:
Unknown W. Brackets 2013-10-07 00:50:15 -07:00
parent a0d84d45cc
commit 31171cc044
2 changed files with 32 additions and 4 deletions

View File

@ -112,7 +112,9 @@ struct GPUDebugBuffer {
u32 pixelSize = 2;
if (fmt == GPU_DBG_FORMAT_8888 || fmt == GPU_DBG_FORMAT_FLOAT) {
pixelSize = 4;
};
} else if (fmt == GPU_DBG_FORMAT_8BIT) {
pixelSize = 1;
}
data_ = new u8[pixelSize * stride * height];
}

View File

@ -759,15 +759,41 @@ bool SoftGPU::GetCurrentDepthbuffer(GPUDebugBuffer &buffer)
{
// We don't know the height, so just use 512, which should be the max (hopefully?)
// TODO: Could check clipping and such, though...?
// TODO: Is the value 16-bit? It seems to be.
buffer = GPUDebugBuffer(depthbuf.data, gstate.DepthBufStride(), 512, GPU_DBG_FORMAT_16BIT);
return true;
}
bool SoftGPU::GetCurrentStencilbuffer(GPUDebugBuffer &buffer)
{
// TODO: Just need the alpha value from the framebuffer...
return false;
buffer.Allocate(gstate.DepthBufStride(), 512, GPU_DBG_FORMAT_8BIT);
for (int y = 0; y < 512; ++y) {
u8 *row = buffer.GetData() + gstate.DepthBufStride() * y;
switch (gstate.FrameBufFormat()) {
case GE_FORMAT_565:
memset(row, 0, gstate.DepthBufStride());
break;
case GE_FORMAT_5551:
for (int x = 0; x < gstate.DepthBufStride(); ++x) {
row[x] = (fb.Get16(x, y, gstate.FrameBufStride()) & 0x8000) != 0 ? 0xFF : 0;
}
break;
case GE_FORMAT_4444:
for (int x = 0; x < gstate.DepthBufStride(); ++x) {
row[x] = Convert4To8(fb.Get16(x, y, gstate.FrameBufStride()) >> 12);
}
break;
case GE_FORMAT_8888:
for (int x = 0; x < gstate.DepthBufStride(); ++x) {
row[x] = fb.Get32(x, y, gstate.FrameBufStride()) >> 24;
}
break;
case GE_FORMAT_INVALID:
ERROR_LOG(HLE, "Impossible framebuffer format.");
break;
}
}
return true;
}
bool SoftGPU::GetCurrentTexture(GPUDebugBuffer &buffer)