diff options
| author | 2019-04-01 12:29:59 -0400 | |
|---|---|---|
| committer | 2019-04-01 12:53:47 -0400 | |
| commit | 781ab8407b50d303197ab6fb888ed35ecbcce23a (patch) | |
| tree | eaf2aabd5471c13fe89ac5f7da247b3bf1248e83 /src/video_core/rasterizer_cache.h | |
| parent | Merge pull request #2304 from lioncash/memsize (diff) | |
| download | yuzu-781ab8407b50d303197ab6fb888ed35ecbcce23a.tar.gz yuzu-781ab8407b50d303197ab6fb888ed35ecbcce23a.tar.xz yuzu-781ab8407b50d303197ab6fb888ed35ecbcce23a.zip | |
general: Use deducation guides for std::lock_guard and std::unique_lock
Since C++17, the introduction of deduction guides for locking facilities
means that we no longer need to hardcode the mutex type into the locks
themselves, making it easier to switch mutex types, should it ever be
necessary in the future.
Diffstat (limited to 'src/video_core/rasterizer_cache.h')
| -rw-r--r-- | src/video_core/rasterizer_cache.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/video_core/rasterizer_cache.h b/src/video_core/rasterizer_cache.h index 110ad7d26..291772186 100644 --- a/src/video_core/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache.h | |||
| @@ -84,7 +84,7 @@ public: | |||
| 84 | 84 | ||
| 85 | /// Write any cached resources overlapping the specified region back to memory | 85 | /// Write any cached resources overlapping the specified region back to memory |
| 86 | void FlushRegion(CacheAddr addr, std::size_t size) { | 86 | void FlushRegion(CacheAddr addr, std::size_t size) { |
| 87 | std::lock_guard<std::recursive_mutex> lock{mutex}; | 87 | std::lock_guard lock{mutex}; |
| 88 | 88 | ||
| 89 | const auto& objects{GetSortedObjectsFromRegion(addr, size)}; | 89 | const auto& objects{GetSortedObjectsFromRegion(addr, size)}; |
| 90 | for (auto& object : objects) { | 90 | for (auto& object : objects) { |
| @@ -94,7 +94,7 @@ public: | |||
| 94 | 94 | ||
| 95 | /// Mark the specified region as being invalidated | 95 | /// Mark the specified region as being invalidated |
| 96 | void InvalidateRegion(CacheAddr addr, u64 size) { | 96 | void InvalidateRegion(CacheAddr addr, u64 size) { |
| 97 | std::lock_guard<std::recursive_mutex> lock{mutex}; | 97 | std::lock_guard lock{mutex}; |
| 98 | 98 | ||
| 99 | const auto& objects{GetSortedObjectsFromRegion(addr, size)}; | 99 | const auto& objects{GetSortedObjectsFromRegion(addr, size)}; |
| 100 | for (auto& object : objects) { | 100 | for (auto& object : objects) { |
| @@ -108,7 +108,7 @@ public: | |||
| 108 | 108 | ||
| 109 | /// Invalidates everything in the cache | 109 | /// Invalidates everything in the cache |
| 110 | void InvalidateAll() { | 110 | void InvalidateAll() { |
| 111 | std::lock_guard<std::recursive_mutex> lock{mutex}; | 111 | std::lock_guard lock{mutex}; |
| 112 | 112 | ||
| 113 | while (interval_cache.begin() != interval_cache.end()) { | 113 | while (interval_cache.begin() != interval_cache.end()) { |
| 114 | Unregister(*interval_cache.begin()->second.begin()); | 114 | Unregister(*interval_cache.begin()->second.begin()); |
| @@ -133,7 +133,7 @@ protected: | |||
| 133 | 133 | ||
| 134 | /// Register an object into the cache | 134 | /// Register an object into the cache |
| 135 | virtual void Register(const T& object) { | 135 | virtual void Register(const T& object) { |
| 136 | std::lock_guard<std::recursive_mutex> lock{mutex}; | 136 | std::lock_guard lock{mutex}; |
| 137 | 137 | ||
| 138 | object->SetIsRegistered(true); | 138 | object->SetIsRegistered(true); |
| 139 | interval_cache.add({GetInterval(object), ObjectSet{object}}); | 139 | interval_cache.add({GetInterval(object), ObjectSet{object}}); |
| @@ -143,7 +143,7 @@ protected: | |||
| 143 | 143 | ||
| 144 | /// Unregisters an object from the cache | 144 | /// Unregisters an object from the cache |
| 145 | virtual void Unregister(const T& object) { | 145 | virtual void Unregister(const T& object) { |
| 146 | std::lock_guard<std::recursive_mutex> lock{mutex}; | 146 | std::lock_guard lock{mutex}; |
| 147 | 147 | ||
| 148 | object->SetIsRegistered(false); | 148 | object->SetIsRegistered(false); |
| 149 | rasterizer.UpdatePagesCachedCount(object->GetCpuAddr(), object->GetSizeInBytes(), -1); | 149 | rasterizer.UpdatePagesCachedCount(object->GetCpuAddr(), object->GetSizeInBytes(), -1); |
| @@ -153,14 +153,14 @@ protected: | |||
| 153 | 153 | ||
| 154 | /// Returns a ticks counter used for tracking when cached objects were last modified | 154 | /// Returns a ticks counter used for tracking when cached objects were last modified |
| 155 | u64 GetModifiedTicks() { | 155 | u64 GetModifiedTicks() { |
| 156 | std::lock_guard<std::recursive_mutex> lock{mutex}; | 156 | std::lock_guard lock{mutex}; |
| 157 | 157 | ||
| 158 | return ++modified_ticks; | 158 | return ++modified_ticks; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | /// Flushes the specified object, updating appropriate cache state as needed | 161 | /// Flushes the specified object, updating appropriate cache state as needed |
| 162 | void FlushObject(const T& object) { | 162 | void FlushObject(const T& object) { |
| 163 | std::lock_guard<std::recursive_mutex> lock{mutex}; | 163 | std::lock_guard lock{mutex}; |
| 164 | 164 | ||
| 165 | if (!object->IsDirty()) { | 165 | if (!object->IsDirty()) { |
| 166 | return; | 166 | return; |