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.
This commit is contained in:
Markus Wick 2021-04-07 08:42:54 +02:00
parent b529aba9ce
commit 37ae463f9e
5 changed files with 28 additions and 15 deletions

View file

@ -68,13 +68,7 @@ ThreadManager::ThreadManager(Core::System& system_, bool is_async_)
: system{system_}, is_async{is_async_} {}
ThreadManager::~ThreadManager() {
if (!thread.joinable()) {
return;
}
// Notify GPU thread that a shutdown is pending
PushCommand(EndProcessingCommand());
thread.join();
ShutDown();
}
void ThreadManager::StartThread(VideoCore::RendererBase& renderer,
@ -132,10 +126,26 @@ void ThreadManager::FlushAndInvalidateRegion(VAddr addr, u64 size) {
void ThreadManager::WaitIdle() const {
while (state.last_fence > state.signaled_fence.load(std::memory_order_relaxed) &&
system.IsPoweredOn()) {
state.is_running) {
}
}
void ThreadManager::ShutDown() {
if (!state.is_running) {
return;
}
state.is_running = false;
if (!thread.joinable()) {
return;
}
// Notify GPU thread that a shutdown is pending
PushCommand(EndProcessingCommand());
thread.join();
}
void ThreadManager::OnCommandListEnd() {
PushCommand(OnCommandListEndCommand());
}