aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Vulkan/Auto.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2023-08-14 18:18:47 +0100
committerGitHub <noreply@github.com>2023-08-14 14:18:47 -0300
commit492a0463358e7706e0fb34537d55810d833ae695 (patch)
tree97f56eaf2813db7305f072a69e959c163586fc6f /src/Ryujinx.Graphics.Vulkan/Auto.cs
parent550fd4a7338eded794bf961ef6fd0c38643471c8 (diff)
Vulkan: Buffer Mirrors for MacOS performance (#4899)1.1.988
* Initial implementation of buffer mirrors Generally slower right now, goal is to reduce render passes in games that do inline updates Fix support buffer mirrors Reintroduce vertex buffer mirror Add storage buffer support Optimisation part 1 More optimisation Avoid useless data copies. Remove unused cbIndex stuff Properly set write flag for storage buffers. Fix minor issues Not sure why this was here. Fix BufferRangeList Fix some big issues Align storage buffers rather than getting full buffer as a range Improves mirrorability of read-only storage buffers Increase staging buffer size, as it now contains mirrors Fix some issues with buffers not updating Fix buffer SetDataUnchecked offset for one of the paths when using mirrors Fix buffer mirrors interaction with buffer textures Fix mirror rebinding Move GetBuffer calls on indirect draws before BeginRenderPass to avoid draws without render pass Fix mirrors rebase Fix rebase 2023 * Fix crash when using stale vertex buffer Similar to `Get` with a size that's too large, just treat it as a clamp. * Explicitly set support buffer as mirrorable * Address feedback * Remove unused fragment of MVK workaround * Replace logging for staging buffer OOM * Address format issues * Address more format issues * Mini cleanup * Address more things * Rename BufferRangeList * Support bounding range for ClearMirrors and UploadPendingData * Add maximum size for vertex buffer mirrors * Enable index buffer mirrors Enabled on all platforms for the IbStreamer. * Feedback * Remove mystery BufferCache change Probably macos related? * Fix mirrors not creating when staging buffer is empty. * Change log level to debug
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/Auto.cs')
-rw-r--r--src/Ryujinx.Graphics.Vulkan/Auto.cs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/Auto.cs b/src/Ryujinx.Graphics.Vulkan/Auto.cs
index fdce7232..026dd2b6 100644
--- a/src/Ryujinx.Graphics.Vulkan/Auto.cs
+++ b/src/Ryujinx.Graphics.Vulkan/Auto.cs
@@ -18,6 +18,12 @@ namespace Ryujinx.Graphics.Vulkan
void AddCommandBufferDependencies(CommandBufferScoped cbs);
}
+ interface IMirrorable<T> where T : IDisposable
+ {
+ Auto<T> GetMirrorable(CommandBufferScoped cbs, ref int offset, int size, out bool mirrored);
+ void ClearMirrors(CommandBufferScoped cbs, int offset, int size);
+ }
+
class Auto<T> : IAutoPrivate, IDisposable where T : IDisposable
{
private int _referenceCount;
@@ -26,6 +32,7 @@ namespace Ryujinx.Graphics.Vulkan
private readonly BitMap _cbOwnership;
private readonly MultiFenceHolder _waitable;
private readonly IAutoPrivate[] _referencedObjs;
+ private readonly IMirrorable<T> _mirrorable;
private bool _disposed;
private bool _destroyed;
@@ -37,6 +44,11 @@ namespace Ryujinx.Graphics.Vulkan
_cbOwnership = new BitMap(CommandBufferPool.MaxCommandBuffers);
}
+ public Auto(T value, IMirrorable<T> mirrorable, MultiFenceHolder waitable, params IAutoPrivate[] referencedObjs) : this(value, waitable, referencedObjs)
+ {
+ _mirrorable = mirrorable;
+ }
+
public Auto(T value, MultiFenceHolder waitable, params IAutoPrivate[] referencedObjs) : this(value)
{
_waitable = waitable;
@@ -48,9 +60,17 @@ namespace Ryujinx.Graphics.Vulkan
}
}
- public T Get(CommandBufferScoped cbs, int offset, int size)
+ public T GetMirrorable(CommandBufferScoped cbs, ref int offset, int size, out bool mirrored)
+ {
+ var mirror = _mirrorable.GetMirrorable(cbs, ref offset, size, out mirrored);
+ mirror._waitable?.AddBufferUse(cbs.CommandBufferIndex, offset, size, false);
+ return mirror.Get(cbs);
+ }
+
+ public T Get(CommandBufferScoped cbs, int offset, int size, bool write = false)
{
- _waitable?.AddBufferUse(cbs.CommandBufferIndex, offset, size);
+ _mirrorable?.ClearMirrors(cbs, offset, size);
+ _waitable?.AddBufferUse(cbs.CommandBufferIndex, offset, size, write);
return Get(cbs);
}