From 1e4870e6b9001e034b0699ad29acad1b2fbbcfc8 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sat, 29 Jun 2013 22:46:27 +0700 Subject: [PATCH] Change way of color buffer address range calculation: on buffers swap use actual color image height to re-calculate end address. --- FrameBuffer.cpp | 2 ++ gDP.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index d83b03f1..77759c9d 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -159,6 +159,8 @@ void FrameBuffer_SaveBuffer( u32 address, u16 format, u16 size, u16 width, u16 h frameBuffer.drawBuffer = GL_DRAW_FRAMEBUFFER; FrameBuffer *current = frameBuffer.top; + if (current != NULL && gDP.colorImage.height > 1) + current->endAddress = current->startAddress + ((current->width * gDP.colorImage.height << current->size >> 1) - 1); // Search through saved frame buffers while (current != NULL) { diff --git a/gDP.cpp b/gDP.cpp index 3581ffe4..5260f566 100644 --- a/gDP.cpp +++ b/gDP.cpp @@ -349,28 +349,32 @@ void gDPSetColorImage( u32 format, u32 size, u32 width, u32 address ) if (gDP.colorImage.address != address || gDP.colorImage.width != width || gDP.colorImage.size != size) { + u32 height = 1; if (width == VI.width) { if (width == gSP.viewport.width) - gDP.colorImage.height = max(VI.height, gSP.viewport.height); + height = max(VI.height, gSP.viewport.height); else - gDP.colorImage.height = max(VI.height, gDP.scissor.lry); + height = max(VI.height, gDP.scissor.lry); } else if (width == gDP.scissor.lrx && width == gSP.viewport.width) - gDP.colorImage.height = max(gDP.scissor.lry, gSP.viewport.height); + height = max(gDP.scissor.lry, gSP.viewport.height); else if (width == gDP.scissor.lrx) - gDP.colorImage.height = gDP.scissor.lry; + height = gDP.scissor.lry; else - gDP.colorImage.height = gSP.viewport.height; + height = gSP.viewport.height; if (OGL.frameBufferTextures)// && address != gDP.depthImageAddress) { //if (gDP.colorImage.changed) - FrameBuffer_SaveBuffer( address, (u16)format, (u16)size, (u16)width, gDP.colorImage.height ); + FrameBuffer_SaveBuffer( address, (u16)format, (u16)size, (u16)width, height ); + gDP.colorImage.height = 1; //if (address != gDP.depthImageAddress) //FrameBuffer_RestoreBuffer( address, (u16)size, (u16)width ); //OGL_ClearDepthBuffer(); - } + } else + gDP.colorImage.height = height; + // if (width == VI.width) // gDP.colorImage.height = VI.height;