summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2022-01-04 02:28:54 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2022-01-04 02:28:54 +0100
commit76525432317fcc4b4847c5414bed6660c85e582b (patch)
tree38f9f01b22cb2bc4cd1c012725094133b7587d22 /src/video_core
parentMerge pull request #7668 from ameerj/fence-stop-token (diff)
downloadyuzu-76525432317fcc4b4847c5414bed6660c85e582b.tar
yuzu-76525432317fcc4b4847c5414bed6660c85e582b.tar.gz
yuzu-76525432317fcc4b4847c5414bed6660c85e582b.tar.bz2
yuzu-76525432317fcc4b4847c5414bed6660c85e582b.tar.lz
yuzu-76525432317fcc4b4847c5414bed6660c85e582b.tar.xz
yuzu-76525432317fcc4b4847c5414bed6660c85e582b.tar.zst
yuzu-76525432317fcc4b4847c5414bed6660c85e582b.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/gpu.cpp19
-rw-r--r--src/video_core/gpu.h3
2 files changed, 14 insertions, 8 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index d98874150..8788f5148 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, std::stop_token stop_token = {}) {
+ void WaitFence(u32 syncpoint_id, u32 value) {
// Synced GPU, is always in sync
if (!is_async) {
return;
@@ -218,8 +218,13 @@ struct GPU::Impl {
}
MICROPROFILE_SCOPE(GPU_wait);
std::unique_lock lock{sync_mutex};
- sync_cv.wait(lock, stop_token,
- [=, this] { return syncpoints.at(syncpoint_id).load() >= value; });
+ 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;
+ });
}
void IncrementSyncPoint(u32 syncpoint_id) {
@@ -665,6 +670,8 @@ 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{};
@@ -673,7 +680,7 @@ struct GPU::Impl {
std::mutex sync_mutex;
std::mutex device_mutex;
- std::condition_variable_any sync_cv;
+ std::condition_variable sync_cv;
struct FlushRequest {
explicit FlushRequest(u64 fence_, VAddr addr_, std::size_t size_)
@@ -812,8 +819,8 @@ const VideoCore::ShaderNotify& GPU::ShaderNotify() const {
return impl->ShaderNotify();
}
-void GPU::WaitFence(u32 syncpoint_id, u32 value, std::stop_token stop_token) {
- impl->WaitFence(syncpoint_id, value, stop_token);
+void GPU::WaitFence(u32 syncpoint_id, u32 value) {
+ impl->WaitFence(syncpoint_id, value);
}
void GPU::IncrementSyncPoint(u32 syncpoint_id) {
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index cc65a7870..500411176 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -5,7 +5,6 @@
#pragma once
#include <memory>
-#include <stop_token>
#include "common/bit_field.h"
#include "common/common_types.h"
@@ -210,7 +209,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, std::stop_token stop_token = {});
+ void WaitFence(u32 syncpoint_id, u32 value);
void IncrementSyncPoint(u32 syncpoint_id);