summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureCacheBase.h
diff options
context:
space:
mode:
authorDolphin Bot <dolphin-emu-bot@users.noreply.github.com>2016-06-17 18:31:03 +0200
committerGitHub <noreply@github.com>2016-06-17 18:31:03 +0200
commit847cb540d9d2113032c28fda71e8467f5a75579a (patch)
tree30fe00352cd52adda49d910887a8901b5e03da9b /Source/Core/VideoCommon/TextureCacheBase.h
parent08764c10e6c2bdbaa219ecf760e16a23da9a1471 (diff)
parent96ab76f81d264a0b76207b3303dbb336b6909cfc (diff)
Merge pull request #3902 from phire/lets_just_release_5_0_already
TextureCache: Track efb copies used in a partially updated texture (fixes regression for 5.0)
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.h')
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h
index e87dfc29d1..0acbdfb361 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.h
+++ b/Source/Core/VideoCommon/TextureCacheBase.h
@@ -8,6 +8,7 @@
#include <memory>
#include <tuple>
#include <unordered_map>
+#include <unordered_set>
#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<u64, TCacheEntryBase*>::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<TCacheEntryBase*> references;
+
void SetGeneralParameters(u32 _addr, u32 _size, u32 _format)
{
addr = _addr;
@@ -89,6 +95,22 @@ public:
hash = _hash;
}
+ // 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);
TCacheEntryBase(const TCacheEntryConfig& c) : config(c) {}
@@ -164,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);