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.
This commit is contained in:
Unknown W. Brackets 2013-06-08 04:37:40 -07:00
parent f628b4319f
commit dbb2dfdcff
4 changed files with 43 additions and 1 deletions

View file

@ -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;
}

View file

@ -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() {

View file

@ -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;
}

View file

@ -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);