mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-24 19:00:54 +00:00
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:
parent
095d8cb52a
commit
19877144ba
@ -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;
|
||||
|
@ -870,11 +870,14 @@ 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);
|
||||
|
||||
// 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);
|
||||
@ -885,6 +888,7 @@ namespace DX9 {
|
||||
textureCache_->ForgetLastTexture();
|
||||
RebindFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
if (Memory::IsValidAddress(fb_address | 0x04000000)) {
|
||||
Memory::MemcpyUnchecked(clut, fb_address | 0x04000000, loadBytes);
|
||||
|
@ -1256,11 +1256,14 @@ 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);
|
||||
|
||||
// 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);
|
||||
@ -1271,6 +1274,7 @@ void FramebufferManager::DownloadFramebufferForClut(void *clut, u32 fb_address,
|
||||
textureCache_->ForgetLastTexture();
|
||||
RebindFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
if (Memory::IsValidAddress(fb_address | 0x04000000)) {
|
||||
Memory::MemcpyUnchecked(clut, fb_address | 0x04000000, loadBytes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user