From c6ffed648497fd1ab59cea56cc3441a77acfdf02 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 10 Jan 2016 09:25:19 -0800 Subject: [PATCH] gedbg: Add mechanics to grab CLUT buffer. --- GPU/Common/GPUDebugInterface.h | 4 ++++ GPU/Common/TextureCacheCommon.cpp | 9 +++++++++ GPU/Common/TextureCacheCommon.h | 2 ++ GPU/Debugger/Stepping.cpp | 10 ++++++++++ GPU/Debugger/Stepping.h | 1 + GPU/Directx9/GPU_DX9.cpp | 4 ++++ GPU/Directx9/GPU_DX9.h | 1 + GPU/GLES/GLES_GPU.cpp | 4 ++++ GPU/GLES/GLES_GPU.h | 1 + GPU/Software/SoftGpu.cpp | 10 ++++++++++ GPU/Software/SoftGpu.h | 1 + 11 files changed, 47 insertions(+) diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index db960fc88b..f2676484b2 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -223,6 +223,10 @@ public: return false; } + virtual bool GetCurrentClut(GPUDebugBuffer &buffer) { + return false; + } + // TODO: // cached framebuffers / textures / vertices? // get content of specific framebuffer / texture? diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 48bf17d7e4..b5d355b403 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -352,3 +352,12 @@ void *TextureCacheCommon::RearrangeBuf(void *inBuf, u32 inRowBytes, u32 outRowBy return outBuf; } + +bool TextureCacheCommon::GetCurrentClutBuffer(GPUDebugBuffer &buffer) { + const u32 bpp = gstate.getClutPaletteFormat() == GE_CMODE_32BIT_ABGR8888 ? 4 : 2; + const u32 pixels = 1024 / bpp; + + buffer.Allocate(pixels, 1, (GEBufferFormat)gstate.getClutPaletteFormat()); + memcpy(buffer.GetData(), clutBufRaw_, 1024); + return true; +} diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 6df502572b..542de147fc 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -18,6 +18,7 @@ #pragma once #include "Common/CommonTypes.h" +#include "GPU/Common/GPUDebugInterface.h" enum TextureFiltering { TEX_FILTER_AUTO = 1, @@ -40,6 +41,7 @@ public: virtual ~TextureCacheCommon(); void LoadClut(u32 clutAddr, u32 loadBytes); + bool GetCurrentClutBuffer(GPUDebugBuffer &buffer); virtual bool SetOffsetTexture(u32 offset); diff --git a/GPU/Debugger/Stepping.cpp b/GPU/Debugger/Stepping.cpp index 622e0eae60..312bb6b553 100644 --- a/GPU/Debugger/Stepping.cpp +++ b/GPU/Debugger/Stepping.cpp @@ -30,6 +30,7 @@ enum PauseAction { PAUSE_GETDEPTHBUF, PAUSE_GETSTENCILBUF, PAUSE_GETTEX, + PAUSE_GETCLUT, PAUSE_SETCMDVALUE, }; @@ -52,6 +53,7 @@ static GPUDebugBuffer bufferFrame; static GPUDebugBuffer bufferDepth; static GPUDebugBuffer bufferStencil; static GPUDebugBuffer bufferTex; +static GPUDebugBuffer bufferClut; static int bufferLevel; static u32 pauseSetCmdValue; @@ -97,6 +99,10 @@ static void RunPauseAction() { bufferResult = gpuDebug->GetCurrentTexture(bufferTex, bufferLevel); break; + case PAUSE_GETCLUT: + bufferResult = gpuDebug->GetCurrentClut(bufferClut); + break; + case PAUSE_SETCMDVALUE: gpuDebug->SetCmdValue(pauseSetCmdValue); break; @@ -171,6 +177,10 @@ bool GPU_GetCurrentTexture(const GPUDebugBuffer *&buffer, int level) { return GetBuffer(buffer, PAUSE_GETTEX, bufferTex); } +bool GPU_GetCurrentClut(const GPUDebugBuffer *&buffer) { + return GetBuffer(buffer, PAUSE_GETCLUT, bufferClut); +} + bool GPU_SetCmdValue(u32 op) { if (!isStepping) { return false; diff --git a/GPU/Debugger/Stepping.h b/GPU/Debugger/Stepping.h index 228b1ab8f4..9db652257e 100644 --- a/GPU/Debugger/Stepping.h +++ b/GPU/Debugger/Stepping.h @@ -32,6 +32,7 @@ namespace GPUStepping { bool GPU_GetCurrentDepthbuffer(const GPUDebugBuffer *&buffer); bool GPU_GetCurrentStencilbuffer(const GPUDebugBuffer *&buffer); bool GPU_GetCurrentTexture(const GPUDebugBuffer *&buffer, int level); + bool GPU_GetCurrentClut(const GPUDebugBuffer *&buffer); bool GPU_SetCmdValue(u32 op); void ResumeFromStepping(); diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 475ecc5354..c2502c07e3 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -2185,6 +2185,10 @@ bool DIRECTX9_GPU::GetCurrentTexture(GPUDebugBuffer &buffer, int level) { return success; } +bool DIRECTX9_GPU::GetCurrentClut(GPUDebugBuffer &buffer) { + return textureCache_.GetCurrentClutBuffer(buffer); +} + bool DIRECTX9_GPU::GetDisplayFramebuffer(GPUDebugBuffer &buffer) { return FramebufferManagerDX9::GetDisplayFramebuffer(buffer); } diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index 8e76ac4870..a36add8c2c 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -78,6 +78,7 @@ public: bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer); bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer); bool GetCurrentTexture(GPUDebugBuffer &buffer, int level); + bool GetCurrentClut(GPUDebugBuffer &buffer) override; static bool GetDisplayFramebuffer(GPUDebugBuffer &buffer); bool GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices); diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 0e1a3198a4..ba3c3e32a8 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -2401,6 +2401,10 @@ bool GLES_GPU::GetCurrentTexture(GPUDebugBuffer &buffer, int level) { #endif } +bool GLES_GPU::GetCurrentClut(GPUDebugBuffer &buffer) { + return textureCache_.GetCurrentClutBuffer(buffer); +} + bool GLES_GPU::GetDisplayFramebuffer(GPUDebugBuffer &buffer) { return FramebufferManager::GetDisplayFramebuffer(buffer); } diff --git a/GPU/GLES/GLES_GPU.h b/GPU/GLES/GLES_GPU.h index 5c858a9523..5ad5719902 100644 --- a/GPU/GLES/GLES_GPU.h +++ b/GPU/GLES/GLES_GPU.h @@ -83,6 +83,7 @@ public: bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override; bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override; bool GetCurrentTexture(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentClut(GPUDebugBuffer &buffer) override; static bool GetDisplayFramebuffer(GPUDebugBuffer &buffer); bool GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) override; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 84fe67aaf6..ad96fce331 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -968,6 +968,16 @@ bool SoftGPU::GetCurrentTexture(GPUDebugBuffer &buffer, int level) return Rasterizer::GetCurrentTexture(buffer, level); } +bool SoftGPU::GetCurrentClut(GPUDebugBuffer &buffer) +{ + const u32 bpp = gstate.getClutPaletteFormat() == GE_CMODE_32BIT_ABGR8888 ? 4 : 2; + const u32 pixels = 1024 / bpp; + + buffer.Allocate(pixels, 1, (GEBufferFormat)gstate.getClutPaletteFormat()); + memcpy(buffer.GetData(), clut, 1024); + return true; +} + bool SoftGPU::GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) { return TransformUnit::GetCurrentSimpleVertices(count, vertices, indices); diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index afd375abc6..8cdd67ed69 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -84,6 +84,7 @@ public: bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override; bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override; bool GetCurrentTexture(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentClut(GPUDebugBuffer &buffer) override; bool GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) override; protected: