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.Vulkan/DescriptorSetUpdater.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs') diff --git a/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs b/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs index 8479bcf7..4cf9ce87 100644 --- a/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs +++ b/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs @@ -163,12 +163,13 @@ namespace Ryujinx.Graphics.Vulkan SignalDirty(DirtyFlags.Image); } - public void SetStorageBuffers(CommandBuffer commandBuffer, int first, ReadOnlySpan buffers) + public void SetStorageBuffers(CommandBuffer commandBuffer, ReadOnlySpan buffers) { for (int i = 0; i < buffers.Length; i++) { - var buffer = buffers[i]; - int index = first + i; + var assignment = buffers[i]; + var buffer = assignment.Range; + int index = assignment.Binding; Auto vkBuffer = _gd.BufferManager.GetBuffer(commandBuffer, buffer.Handle, false); ref Auto currentVkBuffer = ref _storageBufferRefs[index]; @@ -243,12 +244,13 @@ namespace Ryujinx.Graphics.Vulkan SignalDirty(DirtyFlags.Texture); } - public void SetUniformBuffers(CommandBuffer commandBuffer, int first, ReadOnlySpan buffers) + public void SetUniformBuffers(CommandBuffer commandBuffer, ReadOnlySpan buffers) { for (int i = 0; i < buffers.Length; i++) { - var buffer = buffers[i]; - int index = first + i; + var assignment = buffers[i]; + var buffer = assignment.Range; + int index = assignment.Binding; Auto vkBuffer = _gd.BufferManager.GetBuffer(commandBuffer, buffer.Handle, false); ref Auto currentVkBuffer = ref _uniformBufferRefs[index]; -- cgit v1.2.3