Avoid redownloading CLUT when reloaded.

In Brave Story, the game reloads the CLUT frequently, but doesn't actually
render to the CLUT that often.  It also switches between a few different
rendered CLUTs - so caching that we've downloaded is a HUGE win.

In case someone reading this message is interested, it actually renders
these CLUT tables from what appears to be a color wheel.  Crazy huh?
This commit is contained in:
Unknown W. Brackets 2016-01-04 22:21:33 -08:00
parent 095d8cb52a
commit 19877144ba
3 changed files with 36 additions and 26 deletions

View File

@ -57,6 +57,7 @@ struct VirtualFramebuffer {
int last_frame_render;
int last_frame_displayed;
int last_frame_clut;
u32 clutUpdatedBytes;
bool memoryUpdated;
bool depthUpdated;
@ -254,6 +255,7 @@ protected:
void SetColorUpdated(VirtualFramebuffer *dstBuffer, int skipDrawReason) {
dstBuffer->memoryUpdated = false;
dstBuffer->clutUpdatedBytes = 0;
dstBuffer->dirtyAfterDisplay = true;
dstBuffer->drawnWidth = dstBuffer->width;
dstBuffer->drawnHeight = dstBuffer->height;

View File

@ -870,20 +870,24 @@ namespace DX9 {
int w = std::min(pixels % vfb->fb_stride, (int)vfb->width);
int h = std::min((pixels + vfb->fb_stride - 1) / vfb->fb_stride, (int)vfb->height);
// We intentionally don't call OptimizeDownloadRange() here - we don't want to over download.
// CLUT framebuffers are often incorrectly estimated in size.
if (x == 0 && y == 0 && w == vfb->width && h == vfb->height) {
vfb->memoryUpdated = true;
// No need to download if we already have it.
if (!vfb->memoryUpdated && vfb->clutUpdatedBytes < loadBytes) {
// We intentionally don't call OptimizeDownloadRange() here - we don't want to over download.
// CLUT framebuffers are often incorrectly estimated in size.
if (x == 0 && y == 0 && w == vfb->width && h == vfb->height) {
vfb->memoryUpdated = true;
}
vfb->clutUpdatedBytes = loadBytes;
// We'll pseudo-blit framebuffers here to get a resized version of vfb.
VirtualFramebuffer *nvfb = FindDownloadTempBuffer(vfb);
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0);
PackFramebufferDirectx9_(nvfb, x, y, w, h);
textureCache_->ForgetLastTexture();
RebindFramebuffer();
}
// We'll pseudo-blit framebuffers here to get a resized version of vfb.
VirtualFramebuffer *nvfb = FindDownloadTempBuffer(vfb);
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0);
PackFramebufferDirectx9_(nvfb, x, y, w, h);
textureCache_->ForgetLastTexture();
RebindFramebuffer();
}
if (Memory::IsValidAddress(fb_address | 0x04000000)) {

View File

@ -1256,20 +1256,24 @@ void FramebufferManager::DownloadFramebufferForClut(void *clut, u32 fb_address,
int w = std::min(pixels % vfb->fb_stride, (int)vfb->width);
int h = std::min((pixels + vfb->fb_stride - 1) / vfb->fb_stride, (int)vfb->height);
// We intentionally don't call OptimizeDownloadRange() here - we don't want to over download.
// CLUT framebuffers are often incorrectly estimated in size.
if (x == 0 && y == 0 && w == vfb->width && h == vfb->height) {
vfb->memoryUpdated = true;
// No need to download if we already have it.
if (!vfb->memoryUpdated && vfb->clutUpdatedBytes < loadBytes) {
// We intentionally don't call OptimizeDownloadRange() here - we don't want to over download.
// CLUT framebuffers are often incorrectly estimated in size.
if (x == 0 && y == 0 && w == vfb->width && h == vfb->height) {
vfb->memoryUpdated = true;
}
vfb->clutUpdatedBytes = loadBytes;
// We'll pseudo-blit framebuffers here to get a resized version of vfb.
VirtualFramebuffer *nvfb = FindDownloadTempBuffer(vfb);
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0);
PackFramebufferSync_(nvfb, x, y, w, h);
textureCache_->ForgetLastTexture();
RebindFramebuffer();
}
// We'll pseudo-blit framebuffers here to get a resized version of vfb.
VirtualFramebuffer *nvfb = FindDownloadTempBuffer(vfb);
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0);
PackFramebufferSync_(nvfb, x, y, w, h);
textureCache_->ForgetLastTexture();
RebindFramebuffer();
}
if (Memory::IsValidAddress(fb_address | 0x04000000)) {