diff options
| author | 2019-04-01 14:36:24 -0400 | |
|---|---|---|
| committer | 2019-04-01 14:36:24 -0400 | |
| commit | e0eee250bb4d70f4fc4973f08649636faf9808cf (patch) | |
| tree | eaf2aabd5471c13fe89ac5f7da247b3bf1248e83 /src/video_core | |
| parent | Merge pull request #2304 from lioncash/memsize (diff) | |
| parent | general: Use deducation guides for std::lock_guard and std::unique_lock (diff) | |
| download | yuzu-e0eee250bb4d70f4fc4973f08649636faf9808cf.tar.gz yuzu-e0eee250bb4d70f4fc4973f08649636faf9808cf.tar.xz yuzu-e0eee250bb4d70f4fc4973f08649636faf9808cf.zip | |
Merge pull request #2312 from lioncash/locks
general: Use deducation guides for std::lock_guard and std::unique_lock
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 4 | ||||
| -rw-r--r-- | src/video_core/gpu_thread.h | 12 | ||||
| -rw-r--r-- | src/video_core/rasterizer_cache.h | 14 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 5ffb492ea..f0ef67535 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -10,7 +10,7 @@ namespace Tegra { | |||
| 10 | 10 | ||
| 11 | void DebugContext::DoOnEvent(Event event, void* data) { | 11 | void DebugContext::DoOnEvent(Event event, void* data) { |
| 12 | { | 12 | { |
| 13 | std::unique_lock<std::mutex> lock(breakpoint_mutex); | 13 | std::unique_lock lock{breakpoint_mutex}; |
| 14 | 14 | ||
| 15 | // TODO(Subv): Commit the rasterizer's caches so framebuffers, render targets, etc. will | 15 | // TODO(Subv): Commit the rasterizer's caches so framebuffers, render targets, etc. will |
| 16 | // show on debug widgets | 16 | // show on debug widgets |
| @@ -32,7 +32,7 @@ void DebugContext::DoOnEvent(Event event, void* data) { | |||
| 32 | 32 | ||
| 33 | void DebugContext::Resume() { | 33 | void DebugContext::Resume() { |
| 34 | { | 34 | { |
| 35 | std::lock_guard<std::mutex> lock(breakpoint_mutex); | 35 | std::lock_guard lock{breakpoint_mutex}; |
| 36 | 36 | ||
| 37 | // Tell all observers that we are about to resume | 37 | // Tell all observers that we are about to resume |
| 38 | for (auto& breakpoint_observer : breakpoint_observers) { | 38 | for (auto& breakpoint_observer : breakpoint_observers) { |
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index c235faf46..ac3a2eb01 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -40,7 +40,7 @@ public: | |||
| 40 | /// Constructs the object such that it observes events of the given DebugContext. | 40 | /// Constructs the object such that it observes events of the given DebugContext. |
| 41 | explicit BreakPointObserver(std::shared_ptr<DebugContext> debug_context) | 41 | explicit BreakPointObserver(std::shared_ptr<DebugContext> debug_context) |
| 42 | : context_weak(debug_context) { | 42 | : context_weak(debug_context) { |
| 43 | std::unique_lock<std::mutex> lock(debug_context->breakpoint_mutex); | 43 | std::unique_lock lock{debug_context->breakpoint_mutex}; |
| 44 | debug_context->breakpoint_observers.push_back(this); | 44 | debug_context->breakpoint_observers.push_back(this); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| @@ -48,7 +48,7 @@ public: | |||
| 48 | auto context = context_weak.lock(); | 48 | auto context = context_weak.lock(); |
| 49 | if (context) { | 49 | if (context) { |
| 50 | { | 50 | { |
| 51 | std::unique_lock<std::mutex> lock(context->breakpoint_mutex); | 51 | std::unique_lock lock{context->breakpoint_mutex}; |
| 52 | context->breakpoint_observers.remove(this); | 52 | context->breakpoint_observers.remove(this); |
| 53 | } | 53 | } |
| 54 | 54 | ||
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index 6ab7142f8..70acb2e79 100644 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h | |||
| @@ -95,13 +95,13 @@ struct SynchState final { | |||
| 95 | std::condition_variable frames_condition; | 95 | std::condition_variable frames_condition; |
| 96 | 96 | ||
| 97 | void IncrementFramesCounter() { | 97 | void IncrementFramesCounter() { |
| 98 | std::lock_guard<std::mutex> lock{frames_mutex}; | 98 | std::lock_guard lock{frames_mutex}; |
| 99 | ++queued_frame_count; | 99 | ++queued_frame_count; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | void DecrementFramesCounter() { | 102 | void DecrementFramesCounter() { |
| 103 | { | 103 | { |
| 104 | std::lock_guard<std::mutex> lock{frames_mutex}; | 104 | std::lock_guard lock{frames_mutex}; |
| 105 | --queued_frame_count; | 105 | --queued_frame_count; |
| 106 | 106 | ||
| 107 | if (queued_frame_count) { | 107 | if (queued_frame_count) { |
| @@ -113,7 +113,7 @@ struct SynchState final { | |||
| 113 | 113 | ||
| 114 | void WaitForFrames() { | 114 | void WaitForFrames() { |
| 115 | { | 115 | { |
| 116 | std::lock_guard<std::mutex> lock{frames_mutex}; | 116 | std::lock_guard lock{frames_mutex}; |
| 117 | if (!queued_frame_count) { | 117 | if (!queued_frame_count) { |
| 118 | return; | 118 | return; |
| 119 | } | 119 | } |
| @@ -121,14 +121,14 @@ struct SynchState final { | |||
| 121 | 121 | ||
| 122 | // Wait for the GPU to be idle (all commands to be executed) | 122 | // Wait for the GPU to be idle (all commands to be executed) |
| 123 | { | 123 | { |
| 124 | std::unique_lock<std::mutex> lock{frames_mutex}; | 124 | std::unique_lock lock{frames_mutex}; |
| 125 | frames_condition.wait(lock, [this] { return !queued_frame_count; }); | 125 | frames_condition.wait(lock, [this] { return !queued_frame_count; }); |
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | void SignalCommands() { | 129 | void SignalCommands() { |
| 130 | { | 130 | { |
| 131 | std::unique_lock<std::mutex> lock{commands_mutex}; | 131 | std::unique_lock lock{commands_mutex}; |
| 132 | if (queue.Empty()) { | 132 | if (queue.Empty()) { |
| 133 | return; | 133 | return; |
| 134 | } | 134 | } |
| @@ -138,7 +138,7 @@ struct SynchState final { | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | void WaitForCommands() { | 140 | void WaitForCommands() { |
| 141 | std::unique_lock<std::mutex> lock{commands_mutex}; | 141 | std::unique_lock lock{commands_mutex}; |
| 142 | commands_condition.wait(lock, [this] { return !queue.Empty(); }); | 142 | commands_condition.wait(lock, [this] { return !queue.Empty(); }); |
| 143 | } | 143 | } |
| 144 | 144 | ||
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; |