From dd01efc56be4b8552babdc6a13372cc5ce6ff6f1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 14 Feb 2021 11:46:42 -0800 Subject: [PATCH] DO NOT MERGE - Debug for #13741. This logs the impacts of #13762 so we can see why that helps, even though it doesn't look like a correct fix. --- GPU/Common/TextureCacheCommon.cpp | 22 ++++++++++++++++++++++ GPU/Common/TextureCacheCommon.h | 2 ++ GPU/Vulkan/DrawEngineVulkan.cpp | 9 ++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 91f54c06ff8a..cc02d85b6a95 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -64,6 +64,8 @@ #define TEXCACHE_MIN_PRESSURE 16 * 1024 * 1024 // Total in VRAM #define TEXCACHE_SECOND_MIN_PRESSURE 4 * 1024 * 1024 +bool texCacheDebugDifference = false; + // Just for reference // PSP Color formats: @@ -327,6 +329,9 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { u32 texaddr = gstate.getTextureAddress(level); if (!Memory::IsValidAddress(texaddr)) { // Bind a null texture and return. + if (texCacheDebugDifference) { + ERROR_LOG(HLE, "Bad texture found"); + } Unbind(); return nullptr; } @@ -345,6 +350,9 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { u32 cluthash; if (hasClut) { if (clutLastFormat_ != gstate.clutformat) { + if (texCacheDebugDifference) { + ERROR_LOG(HLE, "Clut change detected"); + } // We update here because the clut format can be specified after the load. UpdateCurrentClut(gstate.getClutPaletteFormat(), gstate.getClutIndexStartPos(), gstate.isClutIndexSimple()); } @@ -364,9 +372,15 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { // Note: It's necessary to reset needshadertexclamp, for otherwise DIRTY_TEXCLAMP won't get set later. // Should probably revisit how this works.. + if (texCacheDebugDifference && gstate_c.needShaderTexClamp) { + ERROR_LOG(HLE, "Clearing shader texclamp?"); + } gstate_c.SetNeedShaderTexclamp(false); gstate_c.skipDrawReason &= ~SKIPDRAW_BAD_FB_TEXTURE; if (gstate_c.bgraTexture != isBgraBackend_) { + if (texCacheDebugDifference) { + ERROR_LOG(HLE, "BGRA detected - how?"); + } gstate_c.Dirty(DIRTY_FRAGMENTSHADER_STATE); } gstate_c.bgraTexture = isBgraBackend_; @@ -382,6 +396,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { // Fall through to the end where we'll delete the entry if there's a framebuffer. entry->status &= ~TexCacheEntry::STATUS_FRAMEBUFFER_OVERLAP; match = false; + reason = "framebuffer overlap"; } bool rehash = entry->GetHashStatus() == TexCacheEntry::STATUS_UNRELIABLE; @@ -400,6 +415,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { if (entry->status & TexCacheEntry::STATUS_FORCE_REBUILD) { match = false; entry->status &= ~TexCacheEntry::STATUS_FORCE_REBUILD; + reason = "force rebuild"; } if (match) { @@ -458,9 +474,15 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { nextNeedsChange_ = false; // Might need a rebuild if the hash fails, but that will be set later. nextNeedsRebuild_ = false; + if (texCacheDebugDifference) { + INFO_LOG(HLE, "Wasted difference? Or something earlier?"); + } VERBOSE_LOG(G3D, "Texture at %08x found in cache, applying", texaddr); return entry; //Done! } else { + if (texCacheDebugDifference) { + ERROR_LOG(HLE, "NOT A MATCH? reason=%s", reason); + } // Wasn't a match, we will rebuild. nextChangeReason_ = reason; nextNeedsChange_ = true; diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 4ffa7f944826..78b014bdc3cc 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -52,6 +52,8 @@ enum FramebufferNotificationChannel { #define TEXCACHE_MAX_TEXELS_SCALED (256*256) // Per frame +extern bool texCacheDebugDifference; + struct VirtualFramebuffer; namespace Draw { diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 12897153a96a..da3c85bdc8f4 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -76,6 +76,8 @@ enum { TRANSFORMED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * sizeof(TransformedVertex) }; +static bool forceTexParamsDirty = false; + DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan, Draw::DrawContext *draw) : vulkan_(vulkan), draw_(draw), @@ -601,7 +603,11 @@ void DrawEngineVulkan::DoFlush() { bool tess = gstate_c.submitType == SubmitType::HW_BEZIER || gstate_c.submitType == SubmitType::HW_SPLINE; bool textureNeedsApply = false; - if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) { + if ((forceTexParamsDirty || gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS)) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) { + texCacheDebugDifference = forceTexParamsDirty && !gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); + if (texCacheDebugDifference) { + NOTICE_LOG(HLE, "#13741 - Force texture params check for tex %08x", gstate.getTextureAddress(0)); + } textureCache_->SetTexture(); gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); textureNeedsApply = true; @@ -960,6 +966,7 @@ void DrawEngineVulkan::DoFlush() { if (lastRenderStepId_ != curRenderStepId) { // Dirty everything that has dynamic state that will need re-recording. gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_BLEND_STATE); + forceTexParamsDirty = true; lastRenderStepId_ = curRenderStepId; }