From dbb2dfdcff1d28d1b069c7d39cf2fad0371f2491 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Jun 2013 04:37:40 -0700 Subject: [PATCH] Invalidate FBOs when it's obvious they should be. This fixes videos not being visible in for example Star Ocean. Most likely any games doing a copy directly from the mpeg decode. --- Core/HLE/sceDmac.cpp | 8 +++++++- GPU/GLES/DisplayListInterpreter.cpp | 3 +++ GPU/GLES/Framebuffer.cpp | 32 +++++++++++++++++++++++++++++ GPU/GLES/Framebuffer.h | 1 + 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceDmac.cpp b/Core/HLE/sceDmac.cpp index 0bdcdafc2d..77710e8387 100644 --- a/Core/HLE/sceDmac.cpp +++ b/Core/HLE/sceDmac.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Globals.h" +#include "Core/Reporting.h" #include "Core/HLE/HLE.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" @@ -32,7 +33,12 @@ u32 sceDmacMemcpy(u32 dst, u32 src, u32 size) Memory::Memcpy(dst, Memory::GetPointer(src), size); - gpu->InvalidateCache(dst, size, GPU_INVALIDATE_HINT); + src &= ~0x40000000; + // TODO: If we do this it'll probably black out the framebuffer? + if (src < PSP_GetVidMemBase() || src > PSP_GetVidMemEnd()) + gpu->InvalidateCache(dst, size, GPU_INVALIDATE_HINT); + else + WARN_LOG_REPORT(HLE, "sceDmacMemcpy(): FBO blit?"); return 0; } diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index ac6d280aec..89926fc2b2 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -1024,6 +1024,9 @@ void GLES_GPU::InvalidateCache(u32 addr, int size, GPUInvalidationType type) { textureCache_.Invalidate(addr, size, type); else textureCache_.InvalidateAll(type); + + if (type != GPU_INVALIDATE_ALL) + framebufferManager_.UpdateFromMemory(addr, size); } void GLES_GPU::ClearCacheNextFrame() { diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index ec0f05f409..c4972ca33d 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -659,6 +659,38 @@ void FramebufferManager::DestroyAllFBOs() { vfbs_.clear(); } +void FramebufferManager::UpdateFromMemory(u32 addr, int size) { + addr &= ~0x40000000; + + // TODO: Could go through all FBOs, but probably not important? + // TODO: Could also check for inner changes, but video is most important. + if (addr == DisplayFramebufAddr() || addr == PrevDisplayFramebufAddr()) { + // TODO: Deleting the FBO is a heavy hammer solution, so let's only do it if it'd help. + if (!Memory::IsValidAddress(displayFramebufPtr_)) + return; + + fbo_unbind(); + for (auto iter = vfbs_.begin(); iter != vfbs_.end(); ) { + VirtualFramebuffer *vfb = *iter; + if (MaskedEqual(vfb->fb_address, addr)) { + // TODO: This without the fbo_unbind() above would be better than destroying the FBO. + // However, it doesn't seem to work for Star Ocean, at least + //DrawPixels(Memory::GetPointer(addr), vfb->format, vfb->fb_stride); + textureCache_->NotifyFramebufferDestroyed(vfb->fb_address, vfb); + INFO_LOG(HLE, "Invalidating FBO for %08x (%i x %i x %i)", vfb->fb_address, vfb->width, vfb->height, vfb->format) + if (vfb->fbo) { + fbo_destroy(vfb->fbo); + vfb->fbo = 0; + } + delete vfb; + vfbs_.erase(iter++); + } + else + ++iter; + } + } +} + void FramebufferManager::Resized() { resized_ = true; } diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index f67929f56f..7af8ef7270 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -96,6 +96,7 @@ public: void Resized(); void CopyDisplayToOutput(); void SetRenderFrameBuffer(); // Uses parameters computed from gstate + void UpdateFromMemory(u32 addr, int size); // TODO: Break out into some form of FBO manager VirtualFramebuffer *GetDisplayFBO(); void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format);