Memory Changes part 2

* Slightly refactors RangeLists from the last Memory Changes MR, which fixes issue 61.

* Convert as many const size array iterators to span iterators as possible. When iterating over a const size array, every iteration created a Span, now only the first iteration does in most places.

* Now using object pooling for a few object types that were rapidly deleted and recreated.

* Converted a few flag checks to binary operations to save memory allocations.
This commit is contained in:
LotP
2025-09-12 21:24:19 -05:00
committed by KeatonTheBot
parent ff0daa9f35
commit 3deddbd491
89 changed files with 2121 additions and 1154 deletions
+15 -7
View File
@@ -552,13 +552,11 @@ namespace Ryujinx.Graphics.Vulkan
PAttachments = pColorBlendAttachmentState,
};
PipelineColorBlendAdvancedStateCreateInfoEXT colorBlendAdvancedState;
if (!AdvancedBlendSrcPreMultiplied ||
!AdvancedBlendDstPreMultiplied ||
AdvancedBlendOverlap != BlendOverlapEXT.UncorrelatedExt)
{
colorBlendAdvancedState = new PipelineColorBlendAdvancedStateCreateInfoEXT
PipelineColorBlendAdvancedStateCreateInfoEXT colorBlendAdvancedState = new()
{
SType = StructureType.PipelineColorBlendAdvancedStateCreateInfoExt,
SrcPremultiplied = AdvancedBlendSrcPreMultiplied,
@@ -674,14 +672,21 @@ namespace Ryujinx.Graphics.Vulkan
// To work around this, we reduce the format to something that doesn't exceed the stride if possible.
// The assumption is that the exceeding components are not actually accessed on the shader.
Span<VertexInputAttributeDescription> vertexAttributeDescriptionsSpan =
Internal.VertexAttributeDescriptions.AsSpan();
Span<VertexInputBindingDescription> vertexBindingDescriptionsSpan =
Internal.VertexBindingDescriptions.AsSpan();
Span<VertexInputAttributeDescription> vertexAttributeDescriptions2Span =
_vertexAttributeDescriptions2.AsSpan();
for (int index = 0; index < VertexAttributeDescriptionsCount; index++)
{
var attribute = Internal.VertexAttributeDescriptions[index];
var attribute = vertexAttributeDescriptionsSpan[index];
int vbIndex = GetVertexBufferIndex(attribute.Binding);
if (vbIndex >= 0)
{
ref var vb = ref Internal.VertexBindingDescriptions[vbIndex];
ref var vb = ref vertexBindingDescriptionsSpan[vbIndex];
Format format = attribute.Format;
@@ -706,15 +711,18 @@ namespace Ryujinx.Graphics.Vulkan
}
}
_vertexAttributeDescriptions2[index] = attribute;
vertexAttributeDescriptions2Span[index] = attribute;
}
}
private int GetVertexBufferIndex(uint binding)
{
Span<VertexInputBindingDescription> vertexBindingDescriptionsSpan =
Internal.VertexBindingDescriptions.AsSpan();
for (int index = 0; index < VertexBindingDescriptionsCount; index++)
{
if (Internal.VertexBindingDescriptions[index].Binding == binding)
if (vertexBindingDescriptionsSpan[index].Binding == binding)
{
return index;
}