diff options
author | Markus Wick <[email protected]> | 2021-04-06 20:30:22 +0200 |
---|---|---|
committer | Markus Wick <[email protected]> | 2021-04-07 22:38:52 +0200 |
commit | 4aec060f6de410698d5b0a5bffd42d4327b258e4 (patch) | |
tree | 224799482cc260b15af31274497d92c308393113 /src | |
parent | 3173a53db9f9b97bb45d510467c939ab33eeac1e (diff) | |
download | yuzu-mainline-4aec060f6de410698d5b0a5bffd42d4327b258e4.tar.gz yuzu-mainline-4aec060f6de410698d5b0a5bffd42d4327b258e4.zip |
common/threadsafe_queue: Provide Wait() method.
It shall block until there is something to consume in the queue.
And use it for the GPU emulation instead of the spin loop.
This is only in booting the emulator, however in BOTW this is the case for about 1 second.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/threadsafe_queue.h | 10 | ||||
-rw-r--r-- | src/video_core/gpu_thread.cpp | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h index a4647314a..ad04df8ca 100644 --- a/src/common/threadsafe_queue.h +++ b/src/common/threadsafe_queue.h @@ -83,11 +83,15 @@ public: return true; } - T PopWait() { + void Wait() { if (Empty()) { std::unique_lock lock{cv_mutex}; cv.wait(lock, [this]() { return !Empty(); }); } + } + + T PopWait() { + Wait(); T t; Pop(t); return t; @@ -156,6 +160,10 @@ public: return spsc_queue.Pop(t); } + void Wait() { + spsc_queue.Wait(); + } + T PopWait() { return spsc_queue.PopWait(); } diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 99353f15f..cd59a7faf 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp @@ -29,8 +29,7 @@ static void RunThread(Core::System& system, VideoCore::RendererBase& renderer, system.RegisterHostThread(); // Wait for first GPU command before acquiring the window context - while (state.queue.Empty()) - ; + state.queue.Wait(); // If emulation was stopped during disk shader loading, abort before trying to acquire context if (!state.is_running) { |