From 94eaacae3036c421dcd346360c0bf835bd211469 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Thu, 16 Jun 2016 21:51:39 +1200 Subject: TextureCache: Track efb copies used in a partially updated texture Fixes a major preformance regression in Skies of Arcadia during battle transisions. I had plans for a more advanced version of this code after 5.0, but here is a minimal implemenation for now. --- Source/Core/VideoCommon/TextureCacheBase.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Source/Core/VideoCommon/TextureCacheBase.h') diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index e87dfc29d1..bb8dfe1111 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "Common/CommonTypes.h" #include "VideoCommon/BPMemory.h" @@ -68,6 +69,11 @@ public: // Keep an iterator to the entry in textures_by_hash, so it does not need to be searched when removing the cache entry std::multimap::iterator textures_by_hash_iter; + // This is used to keep track of both: + // * efb copies used by this partially updated texture + // * partially updated textures which refer to this efb copy + std::unordered_set references; + void SetGeneralParameters(u32 _addr, u32 _size, u32 _format) { addr = _addr; @@ -89,11 +95,20 @@ public: hash = _hash; } + // This texture entry is used by the other entry as a sub-texture + void CreateReference(TCacheEntryBase* other_entry) + { + this->references.emplace(other_entry); + other_entry->references.emplace(this); + } + void SetEfbCopy(u32 stride); + void Reset(); // Prepare for reuse TCacheEntryBase(const TCacheEntryConfig& c) : config(c) {} virtual ~TCacheEntryBase(); + virtual void Bind(unsigned int stage) = 0; virtual bool Save(const std::string& filename, unsigned int level) = 0; -- cgit v1.2.3 From 96ab76f81d264a0b76207b3303dbb336b6909cfc Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sat, 18 Jun 2016 03:28:57 +1200 Subject: TextureCache: Rename functions and add comments to clear up docs --- Source/Core/VideoCommon/TextureCacheBase.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.h') diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index bb8dfe1111..0acbdfb361 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -98,17 +98,24 @@ public: // This texture entry is used by the other entry as a sub-texture void CreateReference(TCacheEntryBase* other_entry) { + // References are two-way, so they can easily be destroyed later this->references.emplace(other_entry); other_entry->references.emplace(this); } + void DestroyAllReferences() + { + for (auto& reference : references) + reference->references.erase(this); + + references.clear(); + } + void SetEfbCopy(u32 stride); - void Reset(); // Prepare for reuse TCacheEntryBase(const TCacheEntryConfig& c) : config(c) {} virtual ~TCacheEntryBase(); - virtual void Bind(unsigned int stage) = 0; virtual bool Save(const std::string& filename, unsigned int level) = 0; @@ -179,7 +186,9 @@ private: static TCacheEntryBase* AllocateTexture(const TCacheEntryConfig& config); static TexCache::iterator GetTexCacheIter(TCacheEntryBase* entry); - static TexCache::iterator FreeTexture(TexCache::iterator t_iter); + + // Removes and unlinks texture from texture cache and returns it to the pool + static TexCache::iterator InvalidateTexture(TexCache::iterator t_iter); static TCacheEntryBase* ReturnEntry(unsigned int stage, TCacheEntryBase* entry); -- cgit v1.2.3