diff options
| author | Scott Mansell <phiren@gmail.com> | 2022-07-27 19:35:51 +1200 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2023-01-31 18:29:47 +1300 |
| commit | a01d5283ec1dc6a4dc50e4b8da48e6de1c6ac1dd (patch) | |
| tree | 6cc929598384493142132506c1483cefc784cbb8 /Source/Core/VideoCommon/TextureCacheBase.h | |
| parent | 606c18210dd4f651655b2c84e9e332e6c6c6e21b (diff) | |
TextureCache: Add content locking
Texture cache occasionally mutates textures for efficiency.
Which is awkward if we want to borrow those textures from texture cache
to do something else, such as a graphics debugger, or async presentation
on another thread.
Content locking provides a way to signal that the contents of a texture
cache entry should not change. Texture cache will be forced to use
alternative strategies.
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.h')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index c0540cd0df..8b9010a50e 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -19,7 +19,6 @@ #include "Common/BitSet.h" #include "Common/CommonTypes.h" #include "Common/MathUtil.h" -#include "Common/RcPtr.h" #include "VideoCommon/AbstractTexture.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/TextureConfig.h" @@ -127,6 +126,7 @@ struct TCacheEntry bool is_xfb_copy = false; bool is_xfb_container = false; u64 id = 0; + u32 content_semaphore = 0; // Counts up // Indicates that this TCacheEntry has been invalided from textures_by_address bool invalidated = false; @@ -143,7 +143,7 @@ struct TCacheEntry // 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, Common::rc_ptr<TCacheEntry>>::iterator textures_by_hash_iter; + std::multimap<u64, std::shared_ptr<TCacheEntry>>::iterator textures_by_hash_iter; // This is used to keep track of both: // * efb copies used by this partially updated texture @@ -194,6 +194,14 @@ struct TCacheEntry other_entry->references.emplace(this); } + // Acquiring a content lock will lock the current contents and prevent texture cache from + // reusing the same entry for a newer version of the texture. + void AcquireContentLock() { content_semaphore++; } + void ReleaseContentLock() { content_semaphore--; } + + // Can this be mutated? + bool IsLocked() const { return content_semaphore > 0; } + void SetXfbCopy(u32 stride); void SetEfbCopy(u32 stride); void SetNotCopy(); @@ -217,7 +225,7 @@ struct TCacheEntry void DoState(PointerWrap& p); }; -using RcTcacheEntry = Common::rc_ptr<TCacheEntry>; +using RcTcacheEntry = std::shared_ptr<TCacheEntry>; class TextureCacheBase { |
