From a64fee29dc6b8e523d61abb7e79ceaa95a558c6c Mon Sep 17 00:00:00 2001 From: riperiperi Date: Tue, 11 Apr 2023 08:23:41 +0100 Subject: Vulkan: add situational "Fast Flush" mode (#4667) * Flush in the middle of long command buffers. * Vulkan: add situational "Fast Flush" mode The AutoFlushCounter class was added to periodically flush Vulkan command buffers throughout a frame, which reduces latency to the GPU as commands are submitted and processed much sooner. This was done by allowing command buffers to flush when framebuffer attachments changed. However, some games have incredibly long render passes with a large number of draws, and really aggressive data access that forces GPU sync. The Vulkan backend could potentially end up building a single command buffer for 4-5ms if a pass has enough draws, such as in BOTW. In the scenario where sync is waited on immediately after submission, this would have to wait for the completion of a much longer command buffer than usual. The solution is to force command buffer submission periodically in a "fast flush" mode. This will end up splitting render passes, but it will only enable if sync is aggressive enough. This should improve performance in GPU limited scenarios, or in games that aggressively wait on synchronization. In some games, it may only kick in when res scaling. It won't trigger in games like SMO where sync is not an issue. Improves performance in Pokemon Scarlet/Violet (res scaled) and BOTW (in general). * Add conversions in milliseconds next to flush timers. --- Ryujinx.Graphics.Vulkan/VulkanRenderer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Ryujinx.Graphics.Vulkan/VulkanRenderer.cs') diff --git a/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index 193cdce3..92b453fb 100644 --- a/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -49,6 +49,7 @@ namespace Ryujinx.Graphics.Vulkan internal PipelineLayoutCache PipelineLayoutCache { get; private set; } internal BackgroundResources BackgroundResources { get; private set; } internal Action InterruptAction { get; private set; } + internal SyncManager SyncManager { get; private set; } internal BufferManager BufferManager { get; private set; } @@ -58,7 +59,6 @@ namespace Ryujinx.Graphics.Vulkan private VulkanDebugMessenger _debugMessenger; private Counters _counters; - private SyncManager _syncManager; private PipelineFull _pipeline; @@ -327,7 +327,7 @@ namespace Ryujinx.Graphics.Vulkan BufferManager = new BufferManager(this, _device); - _syncManager = new SyncManager(this, _device); + SyncManager = new SyncManager(this, _device); _pipeline = new PipelineFull(this, _device); _pipeline.Initialize(); @@ -436,7 +436,7 @@ namespace Ryujinx.Graphics.Vulkan internal void RegisterFlush() { - _syncManager.RegisterFlush(); + SyncManager.RegisterFlush(); } public PinnedSpan GetBufferData(BufferHandle buffer, int offset, int size) @@ -696,7 +696,7 @@ namespace Ryujinx.Graphics.Vulkan public void PreFrame() { - _syncManager.Cleanup(); + SyncManager.Cleanup(); } public ICounterEvent ReportCounter(CounterType type, EventHandler resultHandler, bool hostReserved) @@ -736,7 +736,7 @@ namespace Ryujinx.Graphics.Vulkan public void CreateSync(ulong id, bool strict) { - _syncManager.Create(id, strict); + SyncManager.Create(id, strict); } public IProgram LoadProgramBinary(byte[] programBinary, bool isFragment, ShaderInfo info) @@ -746,12 +746,12 @@ namespace Ryujinx.Graphics.Vulkan public void WaitSync(ulong id) { - _syncManager.Wait(id); + SyncManager.Wait(id); } public ulong GetCurrentSync() { - return _syncManager.GetCurrent(); + return SyncManager.GetCurrent(); } public void SetInterruptAction(Action interruptAction) -- cgit v1.2.3