diff options
| author | 2021-04-07 08:42:54 +0200 | |
|---|---|---|
| committer | 2021-04-07 22:38:52 +0200 | |
| commit | 5145133a604f626c05f832465ac22019b003c32a (patch) | |
| tree | 81aa729ab6897cadeb1251f6adcafaeab1010f0d /src/video_core/gpu_thread.cpp | |
| parent | common/threadsafe_queue: Provide Wait() method. (diff) | |
| download | yuzu-5145133a604f626c05f832465ac22019b003c32a.tar.gz yuzu-5145133a604f626c05f832465ac22019b003c32a.tar.xz yuzu-5145133a604f626c05f832465ac22019b003c32a.zip | |
video_core/gpu_thread: Implement a ShutDown method.
This was implicitly done by `is_powered_on = false`, however the explicit method allows us to block until the GPU is actually gone.
This should fix a race condition while removing the other subsystems while the GPU is still active.
Diffstat (limited to 'src/video_core/gpu_thread.cpp')
| -rw-r--r-- | src/video_core/gpu_thread.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index cd59a7faf..6b8f06f78 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp | |||
| @@ -68,13 +68,7 @@ ThreadManager::ThreadManager(Core::System& system_, bool is_async_) | |||
| 68 | : system{system_}, is_async{is_async_} {} | 68 | : system{system_}, is_async{is_async_} {} |
| 69 | 69 | ||
| 70 | ThreadManager::~ThreadManager() { | 70 | ThreadManager::~ThreadManager() { |
| 71 | if (!thread.joinable()) { | 71 | ShutDown(); |
| 72 | return; | ||
| 73 | } | ||
| 74 | |||
| 75 | // Notify GPU thread that a shutdown is pending | ||
| 76 | PushCommand(EndProcessingCommand()); | ||
| 77 | thread.join(); | ||
| 78 | } | 72 | } |
| 79 | 73 | ||
| 80 | void ThreadManager::StartThread(VideoCore::RendererBase& renderer, | 74 | void ThreadManager::StartThread(VideoCore::RendererBase& renderer, |
| @@ -132,10 +126,26 @@ void ThreadManager::FlushAndInvalidateRegion(VAddr addr, u64 size) { | |||
| 132 | 126 | ||
| 133 | void ThreadManager::WaitIdle() const { | 127 | void ThreadManager::WaitIdle() const { |
| 134 | while (state.last_fence > state.signaled_fence.load(std::memory_order_relaxed) && | 128 | while (state.last_fence > state.signaled_fence.load(std::memory_order_relaxed) && |
| 135 | system.IsPoweredOn()) { | 129 | state.is_running) { |
| 136 | } | 130 | } |
| 137 | } | 131 | } |
| 138 | 132 | ||
| 133 | void ThreadManager::ShutDown() { | ||
| 134 | if (!state.is_running) { | ||
| 135 | return; | ||
| 136 | } | ||
| 137 | |||
| 138 | state.is_running = false; | ||
| 139 | |||
| 140 | if (!thread.joinable()) { | ||
| 141 | return; | ||
| 142 | } | ||
| 143 | |||
| 144 | // Notify GPU thread that a shutdown is pending | ||
| 145 | PushCommand(EndProcessingCommand()); | ||
| 146 | thread.join(); | ||
| 147 | } | ||
| 148 | |||
| 139 | void ThreadManager::OnCommandListEnd() { | 149 | void ThreadManager::OnCommandListEnd() { |
| 140 | PushCommand(OnCommandListEndCommand()); | 150 | PushCommand(OnCommandListEndCommand()); |
| 141 | } | 151 | } |