diff options
author | riperiperi <rhy3756547@hotmail.com> | 2023-04-11 08:23:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 09:23:41 +0200 |
commit | a64fee29dc6b8e523d61abb7e79ceaa95a558c6c (patch) | |
tree | 0caad4bd4df53db26532ba49c8e0835966fe3e0f /Ryujinx.Graphics.Vulkan/SyncManager.cs | |
parent | 9ef94c8292beda825fa76e05ad2e561c6d571c95 (diff) |
Vulkan: add situational "Fast Flush" mode (#4667)1.1.706
* 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.
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/SyncManager.cs')
-rw-r--r-- | Ryujinx.Graphics.Vulkan/SyncManager.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Vulkan/SyncManager.cs b/Ryujinx.Graphics.Vulkan/SyncManager.cs index c046dc3c..432d224f 100644 --- a/Ryujinx.Graphics.Vulkan/SyncManager.cs +++ b/Ryujinx.Graphics.Vulkan/SyncManager.cs @@ -1,6 +1,7 @@ using Ryujinx.Common.Logging; using Silk.NET.Vulkan; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; namespace Ryujinx.Graphics.Vulkan @@ -26,6 +27,7 @@ namespace Ryujinx.Graphics.Vulkan private readonly Device _device; private List<SyncHandle> _handles; private ulong FlushId; + private long WaitTicks; public SyncManager(VulkanRenderer gd, Device device) { @@ -130,6 +132,8 @@ namespace Ryujinx.Graphics.Vulkan return; } + long beforeTicks = Stopwatch.GetTimestamp(); + if (result.NeedsFlush(FlushId)) { _gd.InterruptAction(() => @@ -142,12 +146,14 @@ namespace Ryujinx.Graphics.Vulkan } bool signaled = result.Signalled || result.Waitable.WaitForFences(_gd.Api, _device, 1000000000); + if (!signaled) { Logger.Error?.PrintMsg(LogClass.Gpu, $"VK Sync Object {result.ID} failed to signal within 1000ms. Continuing..."); } else { + WaitTicks += Stopwatch.GetTimestamp() - beforeTicks; result.Signalled = true; } } @@ -188,5 +194,13 @@ namespace Ryujinx.Graphics.Vulkan } } } + + public long GetAndResetWaitTicks() + { + long result = WaitTicks; + WaitTicks = 0; + + return result; + } } } |