diff options
| author | 2022-04-07 19:32:40 +0100 | |
|---|---|---|
| committer | 2022-04-07 19:44:07 +0100 | |
| commit | bbc585881a69b899bfaa9c2982c87a2034d4331e (patch) | |
| tree | aa24a84a9a885da4a112d943ec267b02bba83e39 /src/video_core | |
| parent | input_common: Replace lock_guard with scoped_lock (diff) | |
| download | yuzu-bbc585881a69b899bfaa9c2982c87a2034d4331e.tar.gz yuzu-bbc585881a69b899bfaa9c2982c87a2034d4331e.tar.xz yuzu-bbc585881a69b899bfaa9c2982c87a2034d4331e.zip | |
video_core: Replace lock_guard with scoped_lock
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/gpu.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_thread.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_graphics_pipeline.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/pipeline_statistics.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_compute_pipeline.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_render_pass_cache.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_scheduler.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/shader_cache.cpp | 2 |
11 files changed, 18 insertions, 18 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index ba9ba082f..789af452d 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -230,7 +230,7 @@ struct GPU::Impl { | |||
| 230 | void IncrementSyncPoint(u32 syncpoint_id) { | 230 | void IncrementSyncPoint(u32 syncpoint_id) { |
| 231 | auto& syncpoint = syncpoints.at(syncpoint_id); | 231 | auto& syncpoint = syncpoints.at(syncpoint_id); |
| 232 | syncpoint++; | 232 | syncpoint++; |
| 233 | std::lock_guard lock{sync_mutex}; | 233 | std::scoped_lock lock{sync_mutex}; |
| 234 | sync_cv.notify_all(); | 234 | sync_cv.notify_all(); |
| 235 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | 235 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); |
| 236 | if (!interrupt.empty()) { | 236 | if (!interrupt.empty()) { |
| @@ -252,7 +252,7 @@ struct GPU::Impl { | |||
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) { | 254 | void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) { |
| 255 | std::lock_guard lock{sync_mutex}; | 255 | std::scoped_lock lock{sync_mutex}; |
| 256 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | 256 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); |
| 257 | bool contains = std::any_of(interrupt.begin(), interrupt.end(), | 257 | bool contains = std::any_of(interrupt.begin(), interrupt.end(), |
| 258 | [value](u32 in_value) { return in_value == value; }); | 258 | [value](u32 in_value) { return in_value == value; }); |
| @@ -263,7 +263,7 @@ struct GPU::Impl { | |||
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | [[nodiscard]] bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value) { | 265 | [[nodiscard]] bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value) { |
| 266 | std::lock_guard lock{sync_mutex}; | 266 | std::scoped_lock lock{sync_mutex}; |
| 267 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | 267 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); |
| 268 | const auto iter = | 268 | const auto iter = |
| 269 | std::find_if(interrupt.begin(), interrupt.end(), | 269 | std::find_if(interrupt.begin(), interrupt.end(), |
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 9547f277a..4e8999915 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp | |||
| @@ -56,7 +56,7 @@ static void RunThread(std::stop_token stop_token, Core::System& system, | |||
| 56 | if (next.block) { | 56 | if (next.block) { |
| 57 | // We have to lock the write_lock to ensure that the condition_variable wait not get a | 57 | // We have to lock the write_lock to ensure that the condition_variable wait not get a |
| 58 | // race between the check and the lock itself. | 58 | // race between the check and the lock itself. |
| 59 | std::lock_guard lk(state.write_lock); | 59 | std::scoped_lock lk{state.write_lock}; |
| 60 | state.cv.notify_all(); | 60 | state.cv.notify_all(); |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp index 9e6732abd..fd40966d5 100644 --- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp | |||
| @@ -253,7 +253,7 @@ GraphicsPipeline::GraphicsPipeline( | |||
| 253 | } | 253 | } |
| 254 | } | 254 | } |
| 255 | if (in_parallel) { | 255 | if (in_parallel) { |
| 256 | std::lock_guard lock{built_mutex}; | 256 | std::scoped_lock lock{built_mutex}; |
| 257 | built_fence.Create(); | 257 | built_fence.Create(); |
| 258 | // Flush this context to ensure compilation commands and fence are in the GPU pipe. | 258 | // Flush this context to ensure compilation commands and fence are in the GPU pipe. |
| 259 | glFlush(); | 259 | glFlush(); |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 6423992c3..05c5e702c 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -258,7 +258,7 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading, | |||
| 258 | [this, key, env = std::move(env), &state, &callback](Context* ctx) mutable { | 258 | [this, key, env = std::move(env), &state, &callback](Context* ctx) mutable { |
| 259 | ctx->pools.ReleaseContents(); | 259 | ctx->pools.ReleaseContents(); |
| 260 | auto pipeline{CreateComputePipeline(ctx->pools, key, env)}; | 260 | auto pipeline{CreateComputePipeline(ctx->pools, key, env)}; |
| 261 | std::lock_guard lock{state.mutex}; | 261 | std::scoped_lock lock{state.mutex}; |
| 262 | if (pipeline) { | 262 | if (pipeline) { |
| 263 | compute_cache.emplace(key, std::move(pipeline)); | 263 | compute_cache.emplace(key, std::move(pipeline)); |
| 264 | } | 264 | } |
| @@ -280,7 +280,7 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading, | |||
| 280 | } | 280 | } |
| 281 | ctx->pools.ReleaseContents(); | 281 | ctx->pools.ReleaseContents(); |
| 282 | auto pipeline{CreateGraphicsPipeline(ctx->pools, key, MakeSpan(env_ptrs), false)}; | 282 | auto pipeline{CreateGraphicsPipeline(ctx->pools, key, MakeSpan(env_ptrs), false)}; |
| 283 | std::lock_guard lock{state.mutex}; | 283 | std::scoped_lock lock{state.mutex}; |
| 284 | if (pipeline) { | 284 | if (pipeline) { |
| 285 | graphics_cache.emplace(key, std::move(pipeline)); | 285 | graphics_cache.emplace(key, std::move(pipeline)); |
| 286 | } | 286 | } |
diff --git a/src/video_core/renderer_vulkan/pipeline_statistics.cpp b/src/video_core/renderer_vulkan/pipeline_statistics.cpp index bfec931a6..7ccadf084 100644 --- a/src/video_core/renderer_vulkan/pipeline_statistics.cpp +++ b/src/video_core/renderer_vulkan/pipeline_statistics.cpp | |||
| @@ -57,7 +57,7 @@ void PipelineStatistics::Collect(VkPipeline pipeline) { | |||
| 57 | stage_stats.basic_block_count = GetUint64(statistic); | 57 | stage_stats.basic_block_count = GetUint64(statistic); |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | std::lock_guard lock{mutex}; | 60 | std::scoped_lock lock{mutex}; |
| 61 | collected_stats.push_back(stage_stats); | 61 | collected_stats.push_back(stage_stats); |
| 62 | } | 62 | } |
| 63 | } | 63 | } |
| @@ -66,7 +66,7 @@ void PipelineStatistics::Report() const { | |||
| 66 | double num{}; | 66 | double num{}; |
| 67 | Stats total; | 67 | Stats total; |
| 68 | { | 68 | { |
| 69 | std::lock_guard lock{mutex}; | 69 | std::scoped_lock lock{mutex}; |
| 70 | for (const Stats& stats : collected_stats) { | 70 | for (const Stats& stats : collected_stats) { |
| 71 | total.code_size += stats.code_size; | 71 | total.code_size += stats.code_size; |
| 72 | total.register_count += stats.register_count; | 72 | total.register_count += stats.register_count; |
diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index de36bcdb7..97b3594c2 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp | |||
| @@ -77,7 +77,7 @@ ComputePipeline::ComputePipeline(const Device& device_, DescriptorPool& descript | |||
| 77 | if (pipeline_statistics) { | 77 | if (pipeline_statistics) { |
| 78 | pipeline_statistics->Collect(*pipeline); | 78 | pipeline_statistics->Collect(*pipeline); |
| 79 | } | 79 | } |
| 80 | std::lock_guard lock{build_mutex}; | 80 | std::scoped_lock lock{build_mutex}; |
| 81 | is_built = true; | 81 | is_built = true; |
| 82 | build_condvar.notify_one(); | 82 | build_condvar.notify_one(); |
| 83 | if (shader_notify) { | 83 | if (shader_notify) { |
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index d514b71d0..8959d6059 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -258,7 +258,7 @@ GraphicsPipeline::GraphicsPipeline( | |||
| 258 | pipeline_statistics->Collect(*pipeline); | 258 | pipeline_statistics->Collect(*pipeline); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | std::lock_guard lock{build_mutex}; | 261 | std::scoped_lock lock{build_mutex}; |
| 262 | is_built = true; | 262 | is_built = true; |
| 263 | build_condvar.notify_one(); | 263 | build_condvar.notify_one(); |
| 264 | if (shader_notify) { | 264 | if (shader_notify) { |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 27e59df73..336d1e9dc 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -404,7 +404,7 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading | |||
| 404 | workers.QueueWork([this, key, env = std::move(env), &state, &callback]() mutable { | 404 | workers.QueueWork([this, key, env = std::move(env), &state, &callback]() mutable { |
| 405 | ShaderPools pools; | 405 | ShaderPools pools; |
| 406 | auto pipeline{CreateComputePipeline(pools, key, env, state.statistics.get(), false)}; | 406 | auto pipeline{CreateComputePipeline(pools, key, env, state.statistics.get(), false)}; |
| 407 | std::lock_guard lock{state.mutex}; | 407 | std::scoped_lock lock{state.mutex}; |
| 408 | if (pipeline) { | 408 | if (pipeline) { |
| 409 | compute_cache.emplace(key, std::move(pipeline)); | 409 | compute_cache.emplace(key, std::move(pipeline)); |
| 410 | } | 410 | } |
| @@ -434,7 +434,7 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading | |||
| 434 | auto pipeline{CreateGraphicsPipeline(pools, key, MakeSpan(env_ptrs), | 434 | auto pipeline{CreateGraphicsPipeline(pools, key, MakeSpan(env_ptrs), |
| 435 | state.statistics.get(), false)}; | 435 | state.statistics.get(), false)}; |
| 436 | 436 | ||
| 437 | std::lock_guard lock{state.mutex}; | 437 | std::scoped_lock lock{state.mutex}; |
| 438 | graphics_cache.emplace(key, std::move(pipeline)); | 438 | graphics_cache.emplace(key, std::move(pipeline)); |
| 439 | ++state.built; | 439 | ++state.built; |
| 440 | if (state.has_loaded) { | 440 | if (state.has_loaded) { |
diff --git a/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp b/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp index 451ffe019..d22bb6694 100644 --- a/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp | |||
| @@ -36,7 +36,7 @@ VkAttachmentDescription AttachmentDescription(const Device& device, PixelFormat | |||
| 36 | RenderPassCache::RenderPassCache(const Device& device_) : device{&device_} {} | 36 | RenderPassCache::RenderPassCache(const Device& device_) : device{&device_} {} |
| 37 | 37 | ||
| 38 | VkRenderPass RenderPassCache::Get(const RenderPassKey& key) { | 38 | VkRenderPass RenderPassCache::Get(const RenderPassKey& key) { |
| 39 | std::lock_guard lock{mutex}; | 39 | std::scoped_lock lock{mutex}; |
| 40 | const auto [pair, is_new] = cache.try_emplace(key); | 40 | const auto [pair, is_new] = cache.try_emplace(key); |
| 41 | if (!is_new) { | 41 | if (!is_new) { |
| 42 | return *pair->second; | 42 | return *pair->second; |
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index ad320991b..6a9416457 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp | |||
| @@ -73,7 +73,7 @@ void VKScheduler::DispatchWork() { | |||
| 73 | return; | 73 | return; |
| 74 | } | 74 | } |
| 75 | { | 75 | { |
| 76 | std::lock_guard lock{work_mutex}; | 76 | std::scoped_lock lock{work_mutex}; |
| 77 | work_queue.push(std::move(chunk)); | 77 | work_queue.push(std::move(chunk)); |
| 78 | } | 78 | } |
| 79 | work_cv.notify_one(); | 79 | work_cv.notify_one(); |
| @@ -157,7 +157,7 @@ void VKScheduler::WorkerThread(std::stop_token stop_token) { | |||
| 157 | if (has_submit) { | 157 | if (has_submit) { |
| 158 | AllocateWorkerCommandBuffer(); | 158 | AllocateWorkerCommandBuffer(); |
| 159 | } | 159 | } |
| 160 | std::lock_guard reserve_lock{reserve_mutex}; | 160 | std::scoped_lock reserve_lock{reserve_mutex}; |
| 161 | chunk_reserve.push_back(std::move(work)); | 161 | chunk_reserve.push_back(std::move(work)); |
| 162 | } while (!stop_token.stop_requested()); | 162 | } while (!stop_token.stop_requested()); |
| 163 | } | 163 | } |
| @@ -282,7 +282,7 @@ void VKScheduler::EndRenderPass() { | |||
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | void VKScheduler::AcquireNewChunk() { | 284 | void VKScheduler::AcquireNewChunk() { |
| 285 | std::lock_guard lock{reserve_mutex}; | 285 | std::scoped_lock lock{reserve_mutex}; |
| 286 | if (chunk_reserve.empty()) { | 286 | if (chunk_reserve.empty()) { |
| 287 | chunk = std::make_unique<CommandChunk>(); | 287 | chunk = std::make_unique<CommandChunk>(); |
| 288 | return; | 288 | return; |
diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp index 87636857d..75031767a 100644 --- a/src/video_core/shader_cache.cpp +++ b/src/video_core/shader_cache.cpp | |||
| @@ -25,7 +25,7 @@ void ShaderCache::InvalidateRegion(VAddr addr, size_t size) { | |||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | void ShaderCache::OnCPUWrite(VAddr addr, size_t size) { | 27 | void ShaderCache::OnCPUWrite(VAddr addr, size_t size) { |
| 28 | std::lock_guard lock{invalidation_mutex}; | 28 | std::scoped_lock lock{invalidation_mutex}; |
| 29 | InvalidatePagesInRegion(addr, size); | 29 | InvalidatePagesInRegion(addr, size); |
| 30 | } | 30 | } |
| 31 | 31 | ||