From 7f4de3466ac60624268a3e99363409867261e055 Mon Sep 17 00:00:00 2001 From: FernandoS27 Date: Mon, 4 Oct 2021 20:46:58 +0200 Subject: Vulkan: Fix the master Semaphore --- src/video_core/renderer_vulkan/vk_master_semaphore.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h index 4f8688118..3d298d0b6 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,20 @@ 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); + auto this_tick = gpu_tick.load(std::memory_order_acquire); + u64 counter{}; + do { + 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 -- cgit v1.2.3 From bb8bf740e9e80bfcd4bdb527aac2c7ad6a7ccff5 Mon Sep 17 00:00:00 2001 From: FernandoS27 Date: Mon, 4 Oct 2021 20:47:31 +0200 Subject: RasterizerInterface: Correct size of CPU addresses to cache. --- src/video_core/rasterizer_accelerated.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_core/rasterizer_accelerated.h b/src/video_core/rasterizer_accelerated.h index ea879bfdd..249644e50 100644 --- a/src/video_core/rasterizer_accelerated.h +++ b/src/video_core/rasterizer_accelerated.h @@ -42,7 +42,7 @@ private: }; static_assert(sizeof(CacheEntry) == 8, "CacheEntry should be 8 bytes!"); - std::array cached_pages; + std::array cached_pages; Core::Memory::Memory& cpu_memory; }; -- cgit v1.2.3 From 0498669b4bc72b7b6c9cd4a397ce7c4ebd18d28d Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 4 Oct 2021 20:53:20 +0200 Subject: Vulkan: Fix failing barrier on refresh. --- src/video_core/renderer_vulkan/vk_master_semaphore.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h index 3d298d0b6..0886b7da8 100644 --- a/src/video_core/renderer_vulkan/vk_master_semaphore.h +++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h @@ -46,9 +46,10 @@ public: /// Refresh the known GPU tick void Refresh() { - auto this_tick = gpu_tick.load(std::memory_order_acquire); + u64 this_tick{}; u64 counter{}; do { + this_tick = gpu_tick.load(std::memory_order_acquire); counter = semaphore.GetCounter(); if (counter < this_tick) { return; -- cgit v1.2.3