From 81e71dd8d7609b552f19bf8e58c499ea72f1767f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 27 Sep 2013 21:53:42 -0700 Subject: [PATCH] Add a way to get to the current texture as well. --- GPU/Common/GPUDebugInterface.h | 7 ++++++- GPU/GLES/GLES_GPU.cpp | 25 +++++++++++++++++++++++-- GPU/GLES/GLES_GPU.h | 1 + GPU/GLES/TextureCache.cpp | 6 +++++- GPU/GLES/TextureCache.h | 2 +- GPU/GeDisasm.cpp | 2 +- GPU/Software/SoftGpu.h | 4 ++++ 7 files changed, 41 insertions(+), 6 deletions(-) diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index e758ae8aed..1b7fd4cff0 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -153,8 +153,13 @@ public: return false; } + // Similar to GetCurrentFramebuffer(). + virtual bool GetCurrentTexture(GPUDebugBuffer &buffer) { + return false; + } + // TODO: // cached framebuffers / textures / vertices? - // get content of framebuffer / texture + // get content of specific framebuffer / texture? // vertex / texture decoding? }; \ No newline at end of file diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index d600201232..a6547523db 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -1515,7 +1515,28 @@ void GLES_GPU::DoState(PointerWrap &p) { framebufferManager_.DestroyAllFBOs(); } -bool GLES_GPU::GetCurrentFramebuffer(GPUDebugBuffer &buffer) -{ +bool GLES_GPU::GetCurrentFramebuffer(GPUDebugBuffer &buffer) { return framebufferManager_.GetCurrentFramebuffer(buffer); } + +bool GLES_GPU::GetCurrentTexture(GPUDebugBuffer &buffer) { + if (!gstate.isTextureMapEnabled()) { + return false; + } + +#ifndef USING_GLES2 + textureCache_.SetTexture(true); + int w = gstate.getTextureWidth(0); + int h = gstate.getTextureHeight(0); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); + + buffer.Allocate(w, h, GE_FORMAT_8888, false); + glPixelStorei(GL_PACK_ALIGNMENT, 4); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer.GetData()); + + return true; +#else + return false; +#endif +} \ No newline at end of file diff --git a/GPU/GLES/GLES_GPU.h b/GPU/GLES/GLES_GPU.h index 7df50b4eef..a3280b3013 100644 --- a/GPU/GLES/GLES_GPU.h +++ b/GPU/GLES/GLES_GPU.h @@ -67,6 +67,7 @@ public: std::vector GetFramebufferList(); bool GetCurrentFramebuffer(GPUDebugBuffer &buffer); + bool GetCurrentTexture(GPUDebugBuffer &buffer); protected: virtual void FastRunLoop(DisplayList &list); diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index af9b6a070f..b54fd23799 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -780,7 +780,7 @@ void TextureCache::SetTextureFramebuffer(TexCacheEntry *entry) } } -void TextureCache::SetTexture() { +void TextureCache::SetTexture(bool force) { #ifdef DEBUG_TEXTURES if (SetDebugTexture()) { // A different texture was bound, let's rebind next time. @@ -789,6 +789,10 @@ void TextureCache::SetTexture() { } #endif + if (force) { + lastBoundTexture = -1; + } + u32 texaddr = gstate.getTextureAddress(0); if (!Memory::IsValidAddress(texaddr)) { // Bind a null texture and return. diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index 7c1880b2df..034c8eb035 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -44,7 +44,7 @@ public: TextureCache(); ~TextureCache(); - void SetTexture(); + void SetTexture(bool force = false); void Clear(bool delete_them); void StartFrame(); diff --git a/GPU/GeDisasm.cpp b/GPU/GeDisasm.cpp index 8a21959cc5..79ff0e1b6e 100644 --- a/GPU/GeDisasm.cpp +++ b/GPU/GeDisasm.cpp @@ -365,7 +365,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer) { case GE_CMD_FRAMEBUFWIDTH: { - sprintf(buffer, "FramebufWidth: %i", data); + sprintf(buffer, "FramebufWidth: %x, address high %02x", data & 0xFFFF, data >> 16); } break; diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index f511f48757..cf1110eb26 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -74,6 +74,10 @@ public: } virtual bool GetCurrentFramebuffer(GPUDebugBuffer &buffer); + bool GetCurrentTexture(GPUDebugBuffer &buffer) { + // TODO + return false; + } protected: virtual void FastRunLoop(DisplayList &list);