diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index 6214a7c511..e758ae8aed 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -35,7 +35,7 @@ struct GPUDebugBuffer { } GPUDebugBuffer(void *data, u32 stride, u32 height, GEBufferFormat fmt) - : alloc_(false), data_((u8 *)data), stride_(stride), height_(height), fmt_(fmt) { + : alloc_(false), data_((u8 *)data), stride_(stride), height_(height), fmt_(fmt), flipped_(false) { } GPUDebugBuffer(GPUDebugBuffer &&other) { @@ -43,6 +43,7 @@ struct GPUDebugBuffer { data_ = other.data_; height_ = other.height_; stride_ = other.stride_; + flipped_ = other.flipped_; fmt_ = other.fmt_; other.alloc_ = false; other.data_ = NULL; @@ -59,6 +60,7 @@ struct GPUDebugBuffer { data_ = other.data_; height_ = other.height_; stride_ = other.stride_; + flipped_ = other.flipped_; fmt_ = other.fmt_; other.alloc_ = false; other.data_ = NULL; @@ -67,9 +69,10 @@ struct GPUDebugBuffer { return *this; } - void Allocate(u32 stride, u32 height, GEBufferFormat fmt) { + void Allocate(u32 stride, u32 height, GEBufferFormat fmt, bool flipped = false) { if (alloc_ && stride_ == stride && height_ == height && fmt_ == fmt) { // Already allocated the right size. + flipped_ = flipped; return; } @@ -78,6 +81,7 @@ struct GPUDebugBuffer { height_ = height; stride_ = stride; fmt_ = fmt; + flipped_ = flipped; u32 pixelSize = 2; if (fmt == GE_FORMAT_8888) { @@ -106,14 +110,20 @@ struct GPUDebugBuffer { return stride_; } + bool GetFlipped() const { + return flipped_; + } + GEBufferFormat GetFormat() const { return fmt_; } +private: bool alloc_; u8 *data_; u32 height_; u32 stride_; + bool flipped_; GEBufferFormat fmt_; }; diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index cdda9dca2f..ac889bded3 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -1340,7 +1340,7 @@ bool FramebufferManager::GetCurrentFramebuffer(GPUDebugBuffer &buffer) return true; } - buffer.Allocate(vfb->renderWidth, vfb->renderHeight, GE_FORMAT_8888); + buffer.Allocate(vfb->renderWidth, vfb->renderHeight, GE_FORMAT_8888, true); fbo_bind_for_read(vfb->fbo); glPixelStorei(GL_PACK_ALIGNMENT, 4); diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 1d3796759e..842afb21fb 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -147,7 +147,7 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { if (bufferResult) { auto fmt = SimpleGLWindow::Format(buffer.GetFormat()); - frameWindow->Draw(buffer.GetData(), buffer.GetStride(), buffer.GetHeight(), fmt, SimpleGLWindow::RESIZE_SHRINK_CENTER); + frameWindow->Draw(buffer.GetData(), buffer.GetStride(), buffer.GetHeight(), buffer.GetFlipped(), fmt, SimpleGLWindow::RESIZE_SHRINK_CENTER); } else { ERROR_LOG(COMMON, "Unable to get buffer."); } diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index b012aa9b85..c74dc473f9 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -205,7 +205,7 @@ void SimpleGLWindow::DrawChecker() { glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices); } -void SimpleGLWindow::Draw(u8 *data, int w, int h, Format fmt, ResizeType resize) { +void SimpleGLWindow::Draw(u8 *data, int w, int h, bool flipped, Format fmt, ResizeType resize) { DrawChecker(); glDisable(GL_BLEND); @@ -258,14 +258,15 @@ void SimpleGLWindow::Draw(u8 *data, int w, int h, Format fmt, ResizeType resize) } } const float pos[12] = {x,y,0, x+fw,y,0, x+fw,y+fh,0, x,y+fh,0}; - const float texCoords[8] = {0,1, 1,1, 1,0, 0,0}; - const GLubyte indices[4] = {0,1,3,2}; + static const float texCoords[8] = {0,0, 1,0, 1,1, 0,1}; + static const float texCoordsFlipped[8] = {0,1, 1,1, 1,0, 0,0}; + static const GLubyte indices[4] = {0,1,3,2}; Matrix4x4 ortho; ortho.setOrtho(0, (float)w_, (float)h_, 0, -1, 1); glUniformMatrix4fv(drawProgram_->u_viewproj, 1, GL_FALSE, ortho.getReadPtr()); glVertexAttribPointer(drawProgram_->a_position, 3, GL_FLOAT, GL_FALSE, 12, pos); - glVertexAttribPointer(drawProgram_->a_texcoord0, 2, GL_FLOAT, GL_FALSE, 8, texCoords); + glVertexAttribPointer(drawProgram_->a_texcoord0, 2, GL_FLOAT, GL_FALSE, 8, flipped ? texCoordsFlipped : texCoords); glActiveTexture(GL_TEXTURE0); glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices); diff --git a/Windows/GEDebugger/SimpleGLWindow.h b/Windows/GEDebugger/SimpleGLWindow.h index 376364271e..264e6de971 100644 --- a/Windows/GEDebugger/SimpleGLWindow.h +++ b/Windows/GEDebugger/SimpleGLWindow.h @@ -41,7 +41,7 @@ struct SimpleGLWindow { ~SimpleGLWindow(); void Clear(); - void Draw(u8 *data, int w, int h, Format = FORMAT_8888, ResizeType resize = RESIZE_NONE); + void Draw(u8 *data, int w, int h, bool flipped = false, Format = FORMAT_8888, ResizeType resize = RESIZE_NONE); void Swap() { SwapBuffers(hDC_);