diff options
author | Ameer J <52414509+ameerj@users.noreply.github.com> | 2021-10-17 03:37:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-17 03:37:43 +0200 |
commit | 5b735a4c9dc14b63f68d8ef15f720e92f035f151 (patch) | |
tree | 5d7db8de5a5e40a4e5a6cf6756b2a2de31bdc466 /src/video_core/renderer_vulkan | |
parent | Merge pull request #7195 from MightyCreak/fix-warning-typo (diff) | |
parent | Vulkan: Fix failing barrier on refresh. (diff) | |
download | yuzu-5b735a4c9dc14b63f68d8ef15f720e92f035f151.tar yuzu-5b735a4c9dc14b63f68d8ef15f720e92f035f151.tar.gz yuzu-5b735a4c9dc14b63f68d8ef15f720e92f035f151.tar.bz2 yuzu-5b735a4c9dc14b63f68d8ef15f720e92f035f151.tar.lz yuzu-5b735a4c9dc14b63f68d8ef15f720e92f035f151.tar.xz yuzu-5b735a4c9dc14b63f68d8ef15f720e92f035f151.tar.zst yuzu-5b735a4c9dc14b63f68d8ef15f720e92f035f151.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_master_semaphore.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h index 4f8688118..0886b7da8 100644 --- a/src/video_core/renderer_vulkan/vk_master_semaphore.h +++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h @@ -21,12 +21,12 @@ public: /// Returns the current logical tick. [[nodiscard]] u64 CurrentTick() const noexcept { - return current_tick.load(std::memory_order_relaxed); + return current_tick.load(std::memory_order_acquire); } /// Returns the last known GPU tick. [[nodiscard]] u64 KnownGpuTick() const noexcept { - return gpu_tick.load(std::memory_order_relaxed); + return gpu_tick.load(std::memory_order_acquire); } /// Returns the timeline semaphore handle. @@ -41,12 +41,21 @@ public: /// Advance to the logical tick and return the old one [[nodiscard]] u64 NextTick() noexcept { - return current_tick.fetch_add(1, std::memory_order::relaxed); + return current_tick.fetch_add(1, std::memory_order_release); } /// Refresh the known GPU tick void Refresh() { - gpu_tick.store(semaphore.GetCounter(), std::memory_order_relaxed); + u64 this_tick{}; + u64 counter{}; + do { + this_tick = gpu_tick.load(std::memory_order_acquire); + counter = semaphore.GetCounter(); + if (counter < this_tick) { + return; + } + } while (!gpu_tick.compare_exchange_weak(this_tick, counter, std::memory_order_release, + std::memory_order_relaxed)); } /// Waits for a tick to be hit on the GPU |