summaryrefslogtreecommitdiff
path: root/src/video_core/gpu.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-05-29 01:06:04 -0700
committerGravatar bunnei2021-05-29 01:06:04 -0700
commit8592f8a2b4cae1320b7e152f4d3a68ac7b39bfa3 (patch)
tree0e7ef0aa4ff134d53a46c0f1748a140c95db44fe /src/video_core/gpu.cpp
parentMerge pull request #6373 from bunnei/use-slabheap-tls (diff)
downloadyuzu-8592f8a2b4cae1320b7e152f4d3a68ac7b39bfa3.tar.gz
yuzu-8592f8a2b4cae1320b7e152f4d3a68ac7b39bfa3.tar.xz
yuzu-8592f8a2b4cae1320b7e152f4d3a68ac7b39bfa3.zip
video_core: gpu: WaitFence: Do not block threads during shutdown.
- Fixes a hang on shutdown when NVFlinger thread is waiting on a syncpoint that will never occur. - Commonly observed when stopping emulation in Super Mario Odyssey.
Diffstat (limited to 'src/video_core/gpu.cpp')
-rw-r--r--src/video_core/gpu.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 37f7b24e1..35cc561be 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -104,7 +104,13 @@ void GPU::WaitFence(u32 syncpoint_id, u32 value) {
104 } 104 }
105 MICROPROFILE_SCOPE(GPU_wait); 105 MICROPROFILE_SCOPE(GPU_wait);
106 std::unique_lock lock{sync_mutex}; 106 std::unique_lock lock{sync_mutex};
107 sync_cv.wait(lock, [=, this] { return syncpoints.at(syncpoint_id).load() >= value; }); 107 sync_cv.wait(lock, [=, this] {
108 if (shutting_down.load(std::memory_order_relaxed)) {
109 // We're shutting down, ensure no threads continue to wait for the next syncpoint
110 return true;
111 }
112 return syncpoints.at(syncpoint_id).load() >= value;
113 });
108} 114}
109 115
110void GPU::IncrementSyncPoint(const u32 syncpoint_id) { 116void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
@@ -523,6 +529,10 @@ void GPU::TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const {
523} 529}
524 530
525void GPU::ShutDown() { 531void GPU::ShutDown() {
532 // Signal that threads should no longer block on syncpoint fences
533 shutting_down.store(true, std::memory_order_relaxed);
534 sync_cv.notify_all();
535
526 gpu_thread.ShutDown(); 536 gpu_thread.ShutDown();
527} 537}
528 538