mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 21:06:58 -05:00
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:
parent
4aec060f6d
commit
5145133a60
5 changed files with 28 additions and 15 deletions
|
@ -296,7 +296,7 @@ struct System::Impl {
|
||||||
exit_lock = false;
|
exit_lock = false;
|
||||||
|
|
||||||
if (gpu_core) {
|
if (gpu_core) {
|
||||||
gpu_core->WaitIdle();
|
gpu_core->ShutDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
services.reset();
|
services.reset();
|
||||||
|
|
|
@ -517,8 +517,8 @@ void GPU::TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const {
|
||||||
interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value);
|
interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::WaitIdle() const {
|
void GPU::ShutDown() {
|
||||||
gpu_thread.WaitIdle();
|
gpu_thread.ShutDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::OnCommandListEnd() {
|
void GPU::OnCommandListEnd() {
|
||||||
|
|
|
@ -219,8 +219,8 @@ public:
|
||||||
return *shader_notify;
|
return *shader_notify;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Waits for the GPU to finish working
|
// Stops the GPU execution and waits for the GPU to finish working
|
||||||
void WaitIdle() const;
|
void ShutDown();
|
||||||
|
|
||||||
/// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame.
|
/// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame.
|
||||||
void WaitFence(u32 syncpoint_id, u32 value);
|
void WaitFence(u32 syncpoint_id, u32 value);
|
||||||
|
|
|
@ -68,13 +68,7 @@ ThreadManager::ThreadManager(Core::System& system_, bool is_async_)
|
||||||
: system{system_}, is_async{is_async_} {}
|
: system{system_}, is_async{is_async_} {}
|
||||||
|
|
||||||
ThreadManager::~ThreadManager() {
|
ThreadManager::~ThreadManager() {
|
||||||
if (!thread.joinable()) {
|
ShutDown();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify GPU thread that a shutdown is pending
|
|
||||||
PushCommand(EndProcessingCommand());
|
|
||||||
thread.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadManager::StartThread(VideoCore::RendererBase& renderer,
|
void ThreadManager::StartThread(VideoCore::RendererBase& renderer,
|
||||||
|
@ -132,10 +126,26 @@ void ThreadManager::FlushAndInvalidateRegion(VAddr addr, u64 size) {
|
||||||
|
|
||||||
void ThreadManager::WaitIdle() const {
|
void ThreadManager::WaitIdle() const {
|
||||||
while (state.last_fence > state.signaled_fence.load(std::memory_order_relaxed) &&
|
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() {
|
void ThreadManager::OnCommandListEnd() {
|
||||||
PushCommand(OnCommandListEndCommand());
|
PushCommand(OnCommandListEndCommand());
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,8 +132,8 @@ public:
|
||||||
/// Notify rasterizer that any caches of the specified region should be flushed and invalidated
|
/// Notify rasterizer that any caches of the specified region should be flushed and invalidated
|
||||||
void FlushAndInvalidateRegion(VAddr addr, u64 size);
|
void FlushAndInvalidateRegion(VAddr addr, u64 size);
|
||||||
|
|
||||||
// Wait until the gpu thread is idle.
|
// Stops the GPU execution and waits for the GPU to finish working
|
||||||
void WaitIdle() const;
|
void ShutDown();
|
||||||
|
|
||||||
void OnCommandListEnd();
|
void OnCommandListEnd();
|
||||||
|
|
||||||
|
@ -141,6 +141,9 @@ private:
|
||||||
/// Pushes a command to be executed by the GPU thread
|
/// Pushes a command to be executed by the GPU thread
|
||||||
u64 PushCommand(CommandData&& command_data);
|
u64 PushCommand(CommandData&& command_data);
|
||||||
|
|
||||||
|
// Wait until the gpu thread is idle.
|
||||||
|
void WaitIdle() const;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
const bool is_async;
|
const bool is_async;
|
||||||
VideoCore::RasterizerInterface* rasterizer = nullptr;
|
VideoCore::RasterizerInterface* rasterizer = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue