Read softgpu stencil using existing funcs.

Slower but at least it's the same.
This commit is contained in:
Unknown W. Brackets 2013-10-07 01:02:58 -07:00
parent b9453f82ca
commit 5c2d418d95
3 changed files with 24 additions and 29 deletions

View File

@ -959,4 +959,18 @@ void DrawTriangle(const VertexData& v0, const VertexData& v1, const VertexData&
}
}
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer)
{
buffer.Allocate(gstate.DepthBufStride(), 512, GPU_DBG_FORMAT_8BIT);
u8 *row = buffer.GetData();
for (int y = 0; y < 512; ++y) {
for (int x = 0; x < gstate.DepthBufStride(); ++x) {
row[x] = GetPixelStencil(x, y);
}
row += gstate.DepthBufStride();
}
return true;
}
} // namespace

View File

@ -19,9 +19,13 @@
#include "TransformUnit.h" // for DrawingCoords
struct GPUDebugBuffer;
namespace Rasterizer {
// Draws a triangle if its vertices are specified in counter-clockwise order
void DrawTriangle(const VertexData& v0, const VertexData& v1, const VertexData& v2);
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer);
}

View File

@ -28,6 +28,7 @@
#include "GPU/Software/SoftGpu.h"
#include "GPU/Software/TransformUnit.h"
#include "GPU/Software/Colors.h"
#include "GPU/Software/Rasterizer.h"
static GLuint temp_texture = 0;
@ -765,40 +766,15 @@ bool SoftGPU::GetCurrentDepthbuffer(GPUDebugBuffer &buffer)
bool SoftGPU::GetCurrentStencilbuffer(GPUDebugBuffer &buffer)
{
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;
return Rasterizer::GetCurrentStencilbuffer(buffer);
}
bool SoftGPU::GetCurrentTexture(GPUDebugBuffer &buffer)
{
static const int level = 0;
WARN_LOG(G3D, "Software texture preview currently very broken.");
u32 bufw = GetTextureBufw(level, gstate.getTextureAddress(level), gstate.getTextureFormat());
switch (gstate.getTextureFormat())
{
@ -806,6 +782,7 @@ bool SoftGPU::GetCurrentTexture(GPUDebugBuffer &buffer)
case GE_TFMT_5551:
case GE_TFMT_4444:
case GE_TFMT_8888:
// TODO: Swizzling, of course.
buffer = GPUDebugBuffer(Memory::GetPointer(gstate.getTextureAddress(level)), bufw, gstate.getTextureHeight(level), gstate.getTextureFormat());
return true;