diff options
author | bunnei <bunneidev@gmail.com> | 2021-09-19 05:37:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 05:37:40 +0200 |
commit | a9c3619d26beaaae338c5e902635147b9237350a (patch) | |
tree | b86f29a288fa5bc5a337ba61a6833fa1c89c2270 /src/video_core/renderer_vulkan/vk_scheduler.cpp | |
parent | Merge pull request #6485 from MonsterDruide1/tas (diff) | |
parent | vk_scheduler: Use std::jthread (diff) | |
download | yuzu-a9c3619d26beaaae338c5e902635147b9237350a.tar yuzu-a9c3619d26beaaae338c5e902635147b9237350a.tar.gz yuzu-a9c3619d26beaaae338c5e902635147b9237350a.tar.bz2 yuzu-a9c3619d26beaaae338c5e902635147b9237350a.tar.lz yuzu-a9c3619d26beaaae338c5e902635147b9237350a.tar.xz yuzu-a9c3619d26beaaae338c5e902635147b9237350a.tar.zst yuzu-a9c3619d26beaaae338c5e902635147b9237350a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_scheduler.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index 1d438787a..0c11c814f 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -43,17 +43,10 @@ VKScheduler::VKScheduler(const Device& device_, StateTracker& state_tracker_) command_pool{std::make_unique<CommandPool>(*master_semaphore, device)} { AcquireNewChunk(); AllocateWorkerCommandBuffer(); - worker_thread = std::thread(&VKScheduler::WorkerThread, this); + worker_thread = std::jthread([this](std::stop_token token) { WorkerThread(token); }); } -VKScheduler::~VKScheduler() { - { - std::lock_guard lock{work_mutex}; - quit = true; - } - work_cv.notify_all(); - worker_thread.join(); -} +VKScheduler::~VKScheduler() = default; void VKScheduler::Flush(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) { SubmitExecution(signal_semaphore, wait_semaphore); @@ -135,7 +128,7 @@ bool VKScheduler::UpdateGraphicsPipeline(GraphicsPipeline* pipeline) { return true; } -void VKScheduler::WorkerThread() { +void VKScheduler::WorkerThread(std::stop_token stop_token) { Common::SetCurrentThreadName("yuzu:VulkanWorker"); do { if (work_queue.empty()) { @@ -144,8 +137,8 @@ void VKScheduler::WorkerThread() { std::unique_ptr<CommandChunk> work; { std::unique_lock lock{work_mutex}; - work_cv.wait(lock, [this] { return !work_queue.empty() || quit; }); - if (quit) { + work_cv.wait(lock, stop_token, [this] { return !work_queue.empty(); }); + if (stop_token.stop_requested()) { continue; } work = std::move(work_queue.front()); @@ -158,7 +151,7 @@ void VKScheduler::WorkerThread() { } std::lock_guard reserve_lock{reserve_mutex}; chunk_reserve.push_back(std::move(work)); - } while (!quit); + } while (!stop_token.stop_requested()); } void VKScheduler::AllocateWorkerCommandBuffer() { |