diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 180cbfa52745..ae51418a760e 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -67,6 +67,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: @@ -325,6 +327,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; } @@ -343,6 +348,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()); } @@ -362,9 +370,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_; @@ -380,6 +394,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; @@ -398,6 +413,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { if (entry->status & TexCacheEntry::STATUS_FORCE_REBUILD) { match = false; entry->status &= ~TexCacheEntry::STATUS_FORCE_REBUILD; + reason = "force rebuild"; } if (match) { @@ -457,9 +473,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 809921d790e8..10089f12caaa 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 54ebc209cae4..f322e966eb9c 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), @@ -600,7 +602,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; @@ -957,6 +963,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; }