From 00daa00ae5e9bffed4676bde6c19f3e9920630e1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 29 Aug 2018 22:07:27 -0700 Subject: [PATCH 1/2] TexCache: Keep maxSeenV on clut variants in sync. This ensures that we detect changes properly even when they are outside the max V used with one CLUT. Fixes #9355, enemy fade out in FF2. --- GPU/Common/TextureCacheCommon.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index cadf9abf0d..171c0bb297 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -257,6 +257,19 @@ void TextureCacheCommon::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache void TextureCacheCommon::UpdateMaxSeenV(TexCacheEntry *entry, bool throughMode) { // If the texture is >= 512 pixels tall... if (entry->dim >= 0x900) { + if (entry->cluthash != 0 && entry->maxSeenV == 0) { + const u64 cachekeyMin = (u64)(entry->addr & 0x3FFFFFFF) << 32; + const u64 cachekeyMax = cachekeyMin + (1ULL << 32); + for (auto it = cache_.lower_bound(cachekeyMin), end = cache_.upper_bound(cachekeyMax); it != end; ++it) { + // They should all be the same, just make sure we take any that has already increased. + // This is for a new texture. + if (it->second->maxSeenV != 0) { + entry->maxSeenV = it->second->maxSeenV; + break; + } + } + } + // Texture scale/offset and gen modes don't apply in through. // So we can optimize how much of the texture we look at. if (throughMode) { @@ -274,6 +287,16 @@ void TextureCacheCommon::UpdateMaxSeenV(TexCacheEntry *entry, bool throughMode) // TODO: We could tell for texcoord UV gen, and apply scale to max? entry->maxSeenV = 512; } + + // We need to keep all CLUT variants in sync so we detect changes properly. + // See HandleTextureChange / STATUS_CLUT_RECHECK. + if (entry->cluthash != 0) { + const u64 cachekeyMin = (u64)(entry->addr & 0x3FFFFFFF) << 32; + const u64 cachekeyMax = cachekeyMin + (1ULL << 32); + for (auto it = cache_.lower_bound(cachekeyMin), end = cache_.upper_bound(cachekeyMax); it != end; ++it) { + it->second->maxSeenV = entry->maxSeenV; + } + } } } From 1b79924038f134d22e3a18a41ac30643ada7fd08 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 29 Aug 2018 22:09:10 -0700 Subject: [PATCH 2/2] Debugger: Fix texture readback in GLES. Was using the wrong size, causing the buffer not to be allocated large enough. This caused crashes sometimes. --- ext/native/thin3d/GLQueueRunner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index d3ad94095e..c8380d012f 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -1166,7 +1166,7 @@ void GLQueueRunner::PerformReadbackImage(const GLRStep &pass) { int pixelStride = pass.readback_image.srcRect.w; glPixelStorei(GL_PACK_ALIGNMENT, 4); - GLRect2D rect = pass.readback.srcRect; + GLRect2D rect = pass.readback_image.srcRect; int size = 4 * rect.w * rect.h; if (size > readbackBufferSize_) {