diff options
| author | 2019-02-08 19:24:04 -0400 | |
|---|---|---|
| committer | 2019-02-27 21:57:33 -0400 | |
| commit | 45b6d2d349b35bd056dcb95a252da27a57c04c5f (patch) | |
| tree | b3dd91ca9da7cf80083d75159a333d7d066b8d34 /src | |
| parent | Merge pull request #2163 from ReinUsesLisp/bitset-dirty (diff) | |
| download | yuzu-45b6d2d349b35bd056dcb95a252da27a57c04c5f.tar.gz yuzu-45b6d2d349b35bd056dcb95a252da27a57c04c5f.tar.xz yuzu-45b6d2d349b35bd056dcb95a252da27a57c04c5f.zip | |
rasterizer_cache: Expose FlushObject to Child classes and allow redefining of Register and Unregister
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/rasterizer_cache.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/video_core/rasterizer_cache.h b/src/video_core/rasterizer_cache.h index bcf0c15a4..b239dff84 100644 --- a/src/video_core/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache.h | |||
| @@ -104,7 +104,7 @@ protected: | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | /// Register an object into the cache | 106 | /// Register an object into the cache |
| 107 | void Register(const T& object) { | 107 | virtual void Register(const T& object) { |
| 108 | object->SetIsRegistered(true); | 108 | object->SetIsRegistered(true); |
| 109 | interval_cache.add({GetInterval(object), ObjectSet{object}}); | 109 | interval_cache.add({GetInterval(object), ObjectSet{object}}); |
| 110 | map_cache.insert({object->GetAddr(), object}); | 110 | map_cache.insert({object->GetAddr(), object}); |
| @@ -112,7 +112,7 @@ protected: | |||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | /// Unregisters an object from the cache | 114 | /// Unregisters an object from the cache |
| 115 | void Unregister(const T& object) { | 115 | virtual void Unregister(const T& object) { |
| 116 | object->SetIsRegistered(false); | 116 | object->SetIsRegistered(false); |
| 117 | rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1); | 117 | rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1); |
| 118 | // Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit | 118 | // Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit |
| @@ -129,6 +129,15 @@ protected: | |||
| 129 | return ++modified_ticks; | 129 | return ++modified_ticks; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | /// Flushes the specified object, updating appropriate cache state as needed | ||
| 133 | void FlushObject(const T& object) { | ||
| 134 | if (!object->IsDirty()) { | ||
| 135 | return; | ||
| 136 | } | ||
| 137 | object->Flush(); | ||
| 138 | object->MarkAsModified(false, *this); | ||
| 139 | } | ||
| 140 | |||
| 132 | private: | 141 | private: |
| 133 | /// Returns a list of cached objects from the specified memory region, ordered by access time | 142 | /// Returns a list of cached objects from the specified memory region, ordered by access time |
| 134 | std::vector<T> GetSortedObjectsFromRegion(VAddr addr, u64 size) { | 143 | std::vector<T> GetSortedObjectsFromRegion(VAddr addr, u64 size) { |
| @@ -154,15 +163,6 @@ private: | |||
| 154 | return objects; | 163 | return objects; |
| 155 | } | 164 | } |
| 156 | 165 | ||
| 157 | /// Flushes the specified object, updating appropriate cache state as needed | ||
| 158 | void FlushObject(const T& object) { | ||
| 159 | if (!object->IsDirty()) { | ||
| 160 | return; | ||
| 161 | } | ||
| 162 | object->Flush(); | ||
| 163 | object->MarkAsModified(false, *this); | ||
| 164 | } | ||
| 165 | |||
| 166 | using ObjectSet = std::set<T>; | 166 | using ObjectSet = std::set<T>; |
| 167 | using ObjectCache = std::unordered_map<VAddr, T>; | 167 | using ObjectCache = std::unordered_map<VAddr, T>; |
| 168 | using IntervalCache = boost::icl::interval_map<VAddr, ObjectSet>; | 168 | using IntervalCache = boost::icl::interval_map<VAddr, ObjectSet>; |