From 84ad81ee6798ece6c66016c4581b5fe57ce7b20e Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 9 Feb 2019 11:37:11 -0500 Subject: gpu_thread: Fix deadlock with threading idle state check. --- src/video_core/gpu_thread.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/video_core/gpu_thread.h') diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index ad9f9462b..2ad8214cc 100644 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h @@ -70,6 +70,7 @@ using CommandData = std::variant is_running{true}; + std::atomic is_idle{true}; std::condition_variable signal_condition; std::mutex signal_mutex; std::condition_variable idle_condition; @@ -84,9 +85,9 @@ struct SynchState final { CommandQueue* push_queue{&command_queues[0]}; CommandQueue* pop_queue{&command_queues[1]}; - /// Returns true if the GPU thread should be idle, meaning there are no commands to process - bool IsIdle() const { - return command_queues[0].empty() && command_queues[1].empty(); + void UpdateIdleState() { + std::lock_guard lock{idle_mutex}; + is_idle = command_queues[0].empty() && command_queues[1].empty(); } }; -- cgit v1.2.3