diff options
author | riperiperi <rhy3756547@hotmail.com> | 2022-09-09 00:30:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 20:30:19 -0300 |
commit | c6d82209abeacd2336cde99e5a02b4596e70da83 (patch) | |
tree | 8dc8e1055f402c07e6ed9e4ff247ca420729808c /Ryujinx.Graphics.Vulkan/PipelineConverter.cs | |
parent | ee1825219b8ccca13df7198d4e9ffb966e44c883 (diff) |
Restride vertex buffer when stride causes attributes to misalign in Vulkan. (#3679)1.1.254
* Vertex Buffer Alignment part 1
* Update CacheByRange
* Add Stride Change compute shader, fix storage buffers in helpers
* An AMD exclusive
* Reword
* Change rules - stride conversion when attrs misalign
* Fix stupid mistake
* Fix background pipeline compile
* Improve a few things.
* Fix some feedback
* Address Feedback
(the shader binary didn't change when i changed the source to use the subgroup size)
* Fix bug where rewritten buffer would be disposed instantly.
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/PipelineConverter.cs')
-rw-r--r-- | Ryujinx.Graphics.Vulkan/PipelineConverter.cs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index 315df1b1..c0930351 100644 --- a/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -202,6 +202,9 @@ namespace Ryujinx.Graphics.Vulkan pipeline.Topology = state.Topology.Convert(); int vaCount = Math.Min(Constants.MaxVertexAttributes, state.VertexAttribCount); + int vbCount = Math.Min(Constants.MaxVertexBuffers, state.VertexBufferCount); + + Span<int> vbScalarSizes = stackalloc int[vbCount]; for (int i = 0; i < vaCount; i++) { @@ -213,13 +216,16 @@ namespace Ryujinx.Graphics.Vulkan (uint)bufferIndex, gd.FormatCapabilities.ConvertToVertexVkFormat(attribute.Format), (uint)attribute.Offset); + + if (!attribute.IsZero && bufferIndex < vbCount) + { + vbScalarSizes[bufferIndex - 1] = Math.Max(attribute.Format.GetScalarSize(), vbScalarSizes[bufferIndex - 1]); + } } int descriptorIndex = 1; pipeline.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, 0, VertexInputRate.Vertex); - int vbCount = Math.Min(Constants.MaxVertexBuffers, state.VertexBufferCount); - for (int i = 0; i < vbCount; i++) { var vertexBuffer = state.VertexBuffers[i]; @@ -228,10 +234,17 @@ namespace Ryujinx.Graphics.Vulkan { var inputRate = vertexBuffer.Divisor != 0 ? VertexInputRate.Instance : VertexInputRate.Vertex; + int alignedStride = vertexBuffer.Stride; + + if (gd.NeedsVertexBufferAlignment(vbScalarSizes[i], out int alignment)) + { + alignedStride = (vertexBuffer.Stride + (alignment - 1)) & -alignment; + } + // TODO: Support divisor > 1 pipeline.Internal.VertexBindingDescriptions[descriptorIndex++] = new VertexInputBindingDescription( (uint)i + 1, - (uint)vertexBuffer.Stride, + (uint)alignedStride, inputRate); } } |