From 4adfc9bb0870296b372dc96296436538d6aa6c32 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 18 Feb 2020 13:24:38 -0400 Subject: Rasterizer: Document SignalFence & ReleaseFences and setup skeletons on Vulkan. --- src/video_core/engines/maxwell_3d.cpp | 1 - src/video_core/gpu_thread.cpp | 5 ++++- src/video_core/rasterizer_interface.h | 6 ++++-- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 25 ++++++++++++++++++++++++ src/video_core/renderer_vulkan/vk_rasterizer.h | 2 ++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index cff90bc1d..a7e951433 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -410,7 +410,6 @@ void Maxwell3D::ProcessQueryGet() { StampQueryResult(regs.query.query_sequence, regs.query.query_get.short_query == 0); } break; - } case Regs::QueryOperation::Acquire: // TODO(Blinkhawk): Under this operation, the GPU waits for the CPU to write a value that // matches the current payload. diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 672f8d2fa..1c3ab2145 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp @@ -81,9 +81,12 @@ void ThreadManager::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { } void ThreadManager::FlushRegion(VAddr addr, u64 size) { + if (!Settings::IsGPULevelExtreme()) { + return; + } if (system.Renderer().Rasterizer().MustFlushRegion(addr, size)) { u64 fence = PushCommand(FlushRegionCommand(addr, size)); - while (fence < state.signaled_fence.load(std::memory_order_relaxed)) { + while (fence > state.signaled_fence.load(std::memory_order_relaxed)) { } } } diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index 228752131..b49f15df2 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h @@ -49,9 +49,11 @@ public: /// Records a GPU query and caches it virtual void Query(GPUVAddr gpu_addr, QueryType type, std::optional timestamp) = 0; - virtual void SignalFence(GPUVAddr addr, u32 value) {} + /// Signal a GPU based fence + virtual void SignalFence(GPUVAddr addr, u32 value) = 0; - virtual void ReleaseFences() {} + /// Release all pending fences. + virtual void ReleaseFences() = 0; /// Notify rasterizer that all caches should be flushed to Switch memory virtual void FlushAll() = 0; diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 9437a4aa1..1d75a4766 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -535,6 +535,7 @@ void RasterizerVulkan::OnCPUWrite(VAddr addr, u64 size) { texture_cache.OnCPUWrite(addr, size); pipeline_cache.InvalidateRegion(addr, size); buffer_cache.OnCPUWrite(addr, size); + query_cache.InvalidateRegion(addr, size); } void RasterizerVulkan::SyncGuestHost() { @@ -542,6 +543,30 @@ void RasterizerVulkan::SyncGuestHost() { buffer_cache.SyncGuestHost(); } +void RasterizerVulkan::SignalFence(GPUVAddr addr, u32 value) { + auto& gpu{system.GPU()}; + auto& memory_manager{gpu.MemoryManager()}; + memory_manager.Write(addr, value); + /* + if (!gpu.IsAsync()) { + auto& memory_manager{gpu.MemoryManager()}; + memory_manager.Write(addr, value); + return; + } + fence_manager.SignalFence(addr, value); + */ +} + +void RasterizerVulkan::ReleaseFences() { + /* + auto& gpu{system.GPU()}; + if (!gpu.IsAsync()) { + return; + } + fence_manager.WaitPendingFences(); + */ +} + void RasterizerVulkan::FlushAndInvalidateRegion(VAddr addr, u64 size) { FlushRegion(addr, size); InvalidateRegion(addr, size); diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 7002a4fa3..08a9af401 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -122,6 +122,8 @@ public: void InvalidateRegion(VAddr addr, u64 size) override; void OnCPUWrite(VAddr addr, u64 size) override; void SyncGuestHost() override; + void SignalFence(GPUVAddr addr, u32 value) override; + void ReleaseFences() override; void FlushAndInvalidateRegion(VAddr addr, u64 size) override; void FlushCommands() override; void TickFrame() override; -- cgit v1.2.3