summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-06-20 17:41:38 +0200
committerLiam <byteslice@airmail.cc>2023-06-22 15:25:23 +0200
commit1586f1c0b174bec6b1db7de48b46ff75e29f3bb2 (patch)
treef84b5d604f05552f55a03b6a159bdb4cc57cba24 /src/video_core/renderer_vulkan
parentMerge pull request #10086 from Morph1984/coretiming-ng-1 (diff)
downloadyuzu-1586f1c0b174bec6b1db7de48b46ff75e29f3bb2.tar
yuzu-1586f1c0b174bec6b1db7de48b46ff75e29f3bb2.tar.gz
yuzu-1586f1c0b174bec6b1db7de48b46ff75e29f3bb2.tar.bz2
yuzu-1586f1c0b174bec6b1db7de48b46ff75e29f3bb2.tar.lz
yuzu-1586f1c0b174bec6b1db7de48b46ff75e29f3bb2.tar.xz
yuzu-1586f1c0b174bec6b1db7de48b46ff75e29f3bb2.tar.zst
yuzu-1586f1c0b174bec6b1db7de48b46ff75e29f3bb2.zip
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_master_semaphore.cpp22
-rw-r--r--src/video_core/renderer_vulkan/vk_master_semaphore.h1
2 files changed, 10 insertions, 13 deletions
diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.cpp b/src/video_core/renderer_vulkan/vk_master_semaphore.cpp
index 5eeda08d2..6b288b994 100644
--- a/src/video_core/renderer_vulkan/vk_master_semaphore.cpp
+++ b/src/video_core/renderer_vulkan/vk_master_semaphore.cpp
@@ -75,15 +75,9 @@ void MasterSemaphore::Refresh() {
void MasterSemaphore::Wait(u64 tick) {
if (!semaphore) {
- // If we don't support timeline semaphores, use an atomic wait
- while (true) {
- u64 current_value = gpu_tick.load(std::memory_order_relaxed);
- if (current_value >= tick) {
- return;
- }
- gpu_tick.wait(current_value);
- }
-
+ // If we don't support timeline semaphores, wait for the value normally
+ std::unique_lock lk{free_mutex};
+ free_cv.wait(lk, [&] { return gpu_tick.load(std::memory_order_relaxed) >= tick; });
return;
}
@@ -198,11 +192,13 @@ void MasterSemaphore::WaitThread(std::stop_token token) {
fence.Wait();
fence.Reset();
- gpu_tick.store(host_tick);
- gpu_tick.notify_all();
- std::scoped_lock lock{free_mutex};
- free_queue.push_front(std::move(fence));
+ {
+ std::scoped_lock lock{free_mutex};
+ free_queue.push_front(std::move(fence));
+ gpu_tick.store(host_tick);
+ }
+ free_cv.notify_one();
}
}
diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h
index 1e7c90215..3f599d7bd 100644
--- a/src/video_core/renderer_vulkan/vk_master_semaphore.h
+++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h
@@ -72,6 +72,7 @@ private:
std::atomic<u64> current_tick{1}; ///< Current logical tick.
std::mutex wait_mutex;
std::mutex free_mutex;
+ std::condition_variable free_cv;
std::condition_variable_any wait_cv;
std::queue<Waitable> wait_queue; ///< Queue for the fences to be waited on by the wait thread.
std::deque<vk::Fence> free_queue; ///< Holds available fences for submission.