From cda902f02ab891a4f74a8162902d722d5b8b1bb4 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 14 Sep 2013 21:03:24 +0800 Subject: [PATCH] Attemp to fix Kingdom Heart , Valkyrie Profile & Tales Of Phantasia --- GPU/GLES/Framebuffer.cpp | 45 ++++++++++++++++++++++++++++----------- GPU/GLES/TextureCache.cpp | 2 +- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index ddc6619cb3..e5c5000141 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -426,9 +426,12 @@ void DrawingSize(int &drawing_width, int &drawing_height) { } } else { // Correct region size has to be used when fb_width equals to region_width for exmaple GTA/Midnight Club/MSG Peace Maker . - if (fb_stride == region_width && region_width != scissor_width) { + if (fb_stride == region_width && region_width == viewport_width) { drawing_width = region_width; drawing_height = region_height; + } else if (fb_stride == viewport_width) { + drawing_width = viewport_width; + drawing_height = viewport_height; } else { drawing_width = default_width; drawing_height = default_height; @@ -488,22 +491,40 @@ void FramebufferManager::SetRenderFrameBuffer() { int buffer_width = drawing_width; int buffer_height = drawing_height; - // Find a matching framebuffer + // Find a matching framebuffer, same size or bigger VirtualFramebuffer *vfb = 0; for (size_t i = 0; i < vfbs_.size(); ++i) { VirtualFramebuffer *v = vfbs_[i]; - if (MaskedEqual(v->fb_address, fb_address) && v->format == fmt) { - // Let's not be so picky for now. Let's say this is the one. - vfb = v; - // Update fb stride in case it changed - vfb->fb_stride = fb_stride; - vfb->format = fmt; - if (v->bufferWidth >= drawing_width && v->bufferHeight >= drawing_height) { + if (MaskedEqual(v->fb_address, fb_address)) { + // Okay, let's check the sizes. If the new one is bigger than the old one, recreate. + // If the opposite, just use it and hope that the game sets scissors accordingly. + if (v->bufferWidth >= drawing_width && v->bufferHeight >= drawing_height) { + // Let's not be so picky for now. Let's say this is the one. + vfb = v; + // Update fb stride in case it changed + vfb->fb_stride = fb_stride; + v->format = fmt; + // Just hack the width/height and we should be fine. also hack renderwidth/renderheight? v->width = drawing_width; v->height = drawing_height; - } - break; - } + break; + } else { + INFO_LOG(HLE, "Enlarging framebuffer from (%i, %i) to (%i, %i)", (int)v->width, (int)v->height, drawing_width, drawing_height); + // drawing_width or drawing_height is bigger. Let's recreate with the max. + // To do this right we should copy the data over too, but meh. + if ((int)v->width >= drawing_width && (int)v->height >= drawing_height) { + buffer_width = (int)v->width; + buffer_height = (int)v->height; + } else { + buffer_width = drawing_width; + buffer_height = drawing_height; + } + + DestroyFramebuf(v); + vfbs_.erase(vfbs_.begin() + i--); + break; + } + } } float renderWidthFactor = (float)PSP_CoreParameter().renderWidth / 480.0f; diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 9dfaccab72..363ebd8395 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -989,7 +989,7 @@ void TextureCache::SetTextureFramebuffer(TexCacheEntry *entry) if (useBufferedRendering) { // For now, let's not bind FBOs that we know are off (invalidHint will be -1.) // But let's still not use random memory. - if (entry->framebuffer->fbo && entry->invalidHint != -1) { + if (entry->framebuffer->fbo) { fbo_bind_color_as_texture(entry->framebuffer->fbo, 0); // Keep the framebuffer alive. // TODO: Dangerous if it sets a new one?