diff options
| author | 2022-01-03 16:40:36 -0800 | |
|---|---|---|
| committer | 2022-01-03 16:40:36 -0800 | |
| commit | e7733544779f2706d108682dd027d44e7fa5ff4b (patch) | |
| tree | 9662605d300e28c2e7722ecdc978b65f97b568cb /src/video_core/gpu.cpp | |
| parent | Merge pull request #7664 from german77/fallback (diff) | |
| parent | gpu: Use std::stop_token in WaitFence for VSync thread (diff) | |
| download | yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.tar.gz yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.tar.xz yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.zip | |
Merge pull request #7668 from ameerj/fence-stop-token
gpu: Use std::stop_token in WaitFence for VSync thread
Diffstat (limited to 'src/video_core/gpu.cpp')
| -rw-r--r-- | src/video_core/gpu.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 8788f5148..d98874150 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -206,7 +206,7 @@ struct GPU::Impl { | |||
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. | 208 | /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. |
| 209 | void WaitFence(u32 syncpoint_id, u32 value) { | 209 | void WaitFence(u32 syncpoint_id, u32 value, std::stop_token stop_token = {}) { |
| 210 | // Synced GPU, is always in sync | 210 | // Synced GPU, is always in sync |
| 211 | if (!is_async) { | 211 | if (!is_async) { |
| 212 | return; | 212 | return; |
| @@ -218,13 +218,8 @@ struct GPU::Impl { | |||
| 218 | } | 218 | } |
| 219 | MICROPROFILE_SCOPE(GPU_wait); | 219 | MICROPROFILE_SCOPE(GPU_wait); |
| 220 | std::unique_lock lock{sync_mutex}; | 220 | std::unique_lock lock{sync_mutex}; |
| 221 | sync_cv.wait(lock, [=, this] { | 221 | sync_cv.wait(lock, stop_token, |
| 222 | if (shutting_down.load(std::memory_order_relaxed)) { | 222 | [=, this] { return syncpoints.at(syncpoint_id).load() >= value; }); |
| 223 | // We're shutting down, ensure no threads continue to wait for the next syncpoint | ||
| 224 | return true; | ||
| 225 | } | ||
| 226 | return syncpoints.at(syncpoint_id).load() >= value; | ||
| 227 | }); | ||
| 228 | } | 223 | } |
| 229 | 224 | ||
| 230 | void IncrementSyncPoint(u32 syncpoint_id) { | 225 | void IncrementSyncPoint(u32 syncpoint_id) { |
| @@ -670,8 +665,6 @@ struct GPU::Impl { | |||
| 670 | std::unique_ptr<Engines::KeplerMemory> kepler_memory; | 665 | std::unique_ptr<Engines::KeplerMemory> kepler_memory; |
| 671 | /// Shader build notifier | 666 | /// Shader build notifier |
| 672 | std::unique_ptr<VideoCore::ShaderNotify> shader_notify; | 667 | std::unique_ptr<VideoCore::ShaderNotify> shader_notify; |
| 673 | /// When true, we are about to shut down emulation session, so terminate outstanding tasks | ||
| 674 | std::atomic_bool shutting_down{}; | ||
| 675 | 668 | ||
| 676 | std::array<std::atomic<u32>, Service::Nvidia::MaxSyncPoints> syncpoints{}; | 669 | std::array<std::atomic<u32>, Service::Nvidia::MaxSyncPoints> syncpoints{}; |
| 677 | 670 | ||
| @@ -680,7 +673,7 @@ struct GPU::Impl { | |||
| 680 | std::mutex sync_mutex; | 673 | std::mutex sync_mutex; |
| 681 | std::mutex device_mutex; | 674 | std::mutex device_mutex; |
| 682 | 675 | ||
| 683 | std::condition_variable sync_cv; | 676 | std::condition_variable_any sync_cv; |
| 684 | 677 | ||
| 685 | struct FlushRequest { | 678 | struct FlushRequest { |
| 686 | explicit FlushRequest(u64 fence_, VAddr addr_, std::size_t size_) | 679 | explicit FlushRequest(u64 fence_, VAddr addr_, std::size_t size_) |
| @@ -819,8 +812,8 @@ const VideoCore::ShaderNotify& GPU::ShaderNotify() const { | |||
| 819 | return impl->ShaderNotify(); | 812 | return impl->ShaderNotify(); |
| 820 | } | 813 | } |
| 821 | 814 | ||
| 822 | void GPU::WaitFence(u32 syncpoint_id, u32 value) { | 815 | void GPU::WaitFence(u32 syncpoint_id, u32 value, std::stop_token stop_token) { |
| 823 | impl->WaitFence(syncpoint_id, value); | 816 | impl->WaitFence(syncpoint_id, value, stop_token); |
| 824 | } | 817 | } |
| 825 | 818 | ||
| 826 | void GPU::IncrementSyncPoint(u32 syncpoint_id) { | 819 | void GPU::IncrementSyncPoint(u32 syncpoint_id) { |