From ece36b274da3957d727387d2f7c96adbd0f29bc3 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Thu, 24 Nov 2022 07:50:59 +0000 Subject: GAL: Send all buffer assignments at once rather than individually (#3881) * GAL: Send all buffer assignments at once rather than individually The `(int first, BufferRange[] ranges)` method call has very significant performance implications when the bindings are spread out, which they generally always are in Vulkan. This change makes it so that these methods are only called a maximum of one time per draw. Significantly improves GPU thread performance in Pokemon Scarlet/Violet. * Address Feedback Removed SetUniformBuffers(int first, ReadOnlySpan buffers) --- Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs') diff --git a/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs b/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs index fcf09f9f..24b0af2d 100644 --- a/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs +++ b/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs @@ -142,6 +142,30 @@ namespace Ryujinx.Graphics.GAL.Multithreading return ranges; } + internal Span MapBufferRanges(Span ranges) + { + // Rewrite the buffer ranges to point to the mapped handles. + + lock (_bufferMap) + { + for (int i = 0; i < ranges.Length; i++) + { + ref BufferAssignment assignment = ref ranges[i]; + BufferRange range = assignment.Range; + BufferHandle result; + + if (!_bufferMap.TryGetValue(range.Handle, out result)) + { + result = BufferHandle.Null; + } + + assignment = new BufferAssignment(ranges[i].Binding, new BufferRange(result, range.Offset, range.Size)); + } + } + + return ranges; + } + internal Span MapBufferRanges(Span ranges) { // Rewrite the buffer ranges to point to the mapped handles. -- cgit v1.2.3