diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index 68e03debd2..5daef9ef29 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -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]; } diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 4fcec22ec8..2c3388a552 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -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)