diff options
author | David Marcec <dmarcecguzman@gmail.com> | 2020-07-16 10:38:35 +0200 |
---|---|---|
committer | David Marcec <dmarcecguzman@gmail.com> | 2020-07-17 06:26:17 +0200 |
commit | f48187449ed4772044da55a8a3745d578c1b8c48 (patch) | |
tree | 4dc7eea4e3e88b30b3b1af22326dc723811f2352 /src/video_core/shader/async_shaders.cpp | |
parent | Drop max workers from 8->2 for testing (diff) | |
download | yuzu-f48187449ed4772044da55a8a3745d578c1b8c48.tar yuzu-f48187449ed4772044da55a8a3745d578c1b8c48.tar.gz yuzu-f48187449ed4772044da55a8a3745d578c1b8c48.tar.bz2 yuzu-f48187449ed4772044da55a8a3745d578c1b8c48.tar.lz yuzu-f48187449ed4772044da55a8a3745d578c1b8c48.tar.xz yuzu-f48187449ed4772044da55a8a3745d578c1b8c48.tar.zst yuzu-f48187449ed4772044da55a8a3745d578c1b8c48.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/shader/async_shaders.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/video_core/shader/async_shaders.cpp b/src/video_core/shader/async_shaders.cpp index fb94ac2e7..84d86c32f 100644 --- a/src/video_core/shader/async_shaders.cpp +++ b/src/video_core/shader/async_shaders.cpp @@ -59,7 +59,6 @@ void AsyncShaders::KillWorkers() { } bool AsyncShaders::HasWorkQueued() { - std::shared_lock lock(queue_mutex); return !pending_queue.empty(); } @@ -118,26 +117,31 @@ void AsyncShaders::QueueOpenGLShader(const OpenGL::Device& device, cpu_addr}; std::unique_lock lock(queue_mutex); pending_queue.push_back(std::move(params)); + cv.notify_one(); } void AsyncShaders::ShaderCompilerThread(Core::Frontend::GraphicsContext* context) { using namespace std::chrono_literals; while (!is_thread_exiting.load(std::memory_order_relaxed)) { + std::unique_lock<std::mutex> lock(queue_mutex); + cv.wait(lock, [&] { return HasWorkQueued() || is_thread_exiting; }); + if (is_thread_exiting) { + return; + } + // Partial lock to allow all threads to read at the same time if (!HasWorkQueued()) { continue; } - // Complete lock for pulling workload - queue_mutex.lock(); // Another thread beat us, just unlock and wait for the next load if (pending_queue.empty()) { - queue_mutex.unlock(); continue; } // Pull work from queue WorkerParams work = std::move(pending_queue.front()); pending_queue.pop_front(); - queue_mutex.unlock(); + + lock.unlock(); if (work.backend == AsyncShaders::Backend::OpenGL || work.backend == AsyncShaders::Backend::GLASM) { |