diff options
author | bunnei <bunneidev@gmail.com> | 2022-01-04 01:40:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 01:40:36 +0100 |
commit | e7733544779f2706d108682dd027d44e7fa5ff4b (patch) | |
tree | 9662605d300e28c2e7722ecdc978b65f97b568cb /src/video_core | |
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 yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.tar.gz yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.tar.bz2 yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.tar.lz yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.tar.xz yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.tar.zst yuzu-e7733544779f2706d108682dd027d44e7fa5ff4b.zip |
Diffstat (limited to 'src/video_core')
-rw-r--r-- | src/video_core/gpu.cpp | 19 | ||||
-rw-r--r-- | src/video_core/gpu.h | 3 |
2 files changed, 8 insertions, 14 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 { } /// 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, std::stop_token stop_token = {}) { // Synced GPU, is always in sync if (!is_async) { return; @@ -218,13 +218,8 @@ struct GPU::Impl { } MICROPROFILE_SCOPE(GPU_wait); std::unique_lock lock{sync_mutex}; - sync_cv.wait(lock, [=, this] { - if (shutting_down.load(std::memory_order_relaxed)) { - // We're shutting down, ensure no threads continue to wait for the next syncpoint - return true; - } - return syncpoints.at(syncpoint_id).load() >= value; - }); + sync_cv.wait(lock, stop_token, + [=, this] { return syncpoints.at(syncpoint_id).load() >= value; }); } void IncrementSyncPoint(u32 syncpoint_id) { @@ -670,8 +665,6 @@ struct GPU::Impl { std::unique_ptr<Engines::KeplerMemory> kepler_memory; /// Shader build notifier std::unique_ptr<VideoCore::ShaderNotify> shader_notify; - /// When true, we are about to shut down emulation session, so terminate outstanding tasks - std::atomic_bool shutting_down{}; std::array<std::atomic<u32>, Service::Nvidia::MaxSyncPoints> syncpoints{}; @@ -680,7 +673,7 @@ struct GPU::Impl { std::mutex sync_mutex; std::mutex device_mutex; - std::condition_variable sync_cv; + std::condition_variable_any sync_cv; struct FlushRequest { explicit FlushRequest(u64 fence_, VAddr addr_, std::size_t size_) @@ -819,8 +812,8 @@ const VideoCore::ShaderNotify& GPU::ShaderNotify() const { return impl->ShaderNotify(); } -void GPU::WaitFence(u32 syncpoint_id, u32 value) { - impl->WaitFence(syncpoint_id, value); +void GPU::WaitFence(u32 syncpoint_id, u32 value, std::stop_token stop_token) { + impl->WaitFence(syncpoint_id, value, stop_token); } void GPU::IncrementSyncPoint(u32 syncpoint_id) { diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 500411176..cc65a7870 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -5,6 +5,7 @@ #pragma once #include <memory> +#include <stop_token> #include "common/bit_field.h" #include "common/common_types.h" @@ -209,7 +210,7 @@ public: [[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const; /// 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, std::stop_token stop_token = {}); void IncrementSyncPoint(u32 syncpoint_id); |