mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-08 03:58:54 +02:00
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:
@@ -86,37 +86,45 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Id6 * 23 ^
|
||||
Id7 * 23 ^
|
||||
Id8 * 23;
|
||||
|
||||
ReadOnlySpan<VertexInputAttributeDescription> vertexAttributeDescriptionsSpan = VertexAttributeDescriptions.AsSpan();
|
||||
|
||||
for (int i = 0; i < (int)VertexAttributeDescriptionsCount; i++)
|
||||
{
|
||||
hash64 ^= VertexAttributeDescriptions[i].Binding * 23;
|
||||
hash64 ^= (uint)VertexAttributeDescriptions[i].Format * 23;
|
||||
hash64 ^= VertexAttributeDescriptions[i].Location * 23;
|
||||
hash64 ^= VertexAttributeDescriptions[i].Offset * 23;
|
||||
hash64 ^= vertexAttributeDescriptionsSpan[i].Binding * 23;
|
||||
hash64 ^= (uint)vertexAttributeDescriptionsSpan[i].Format * 23;
|
||||
hash64 ^= vertexAttributeDescriptionsSpan[i].Location * 23;
|
||||
hash64 ^= vertexAttributeDescriptionsSpan[i].Offset * 23;
|
||||
}
|
||||
|
||||
ReadOnlySpan<VertexInputBindingDescription> vertexBindingDescriptionsSpan = VertexBindingDescriptions.AsSpan();
|
||||
|
||||
for (int i = 0; i < (int)VertexBindingDescriptionsCount; i++)
|
||||
{
|
||||
hash64 ^= VertexBindingDescriptions[i].Binding * 23;
|
||||
hash64 ^= (uint)VertexBindingDescriptions[i].InputRate * 23;
|
||||
hash64 ^= VertexBindingDescriptions[i].Stride * 23;
|
||||
hash64 ^= vertexBindingDescriptionsSpan[i].Binding * 23;
|
||||
hash64 ^= (uint)vertexBindingDescriptionsSpan[i].InputRate * 23;
|
||||
hash64 ^= vertexBindingDescriptionsSpan[i].Stride * 23;
|
||||
}
|
||||
|
||||
ReadOnlySpan<PipelineColorBlendAttachmentState> colorBlendAttachmentStateSpan = ColorBlendAttachmentState.AsSpan();
|
||||
|
||||
for (int i = 0; i < (int)ColorBlendAttachmentStateCount; i++)
|
||||
{
|
||||
hash64 ^= ColorBlendAttachmentState[i].BlendEnable * 23;
|
||||
hash64 ^= (uint)ColorBlendAttachmentState[i].SrcColorBlendFactor * 23;
|
||||
hash64 ^= (uint)ColorBlendAttachmentState[i].DstColorBlendFactor * 23;
|
||||
hash64 ^= (uint)ColorBlendAttachmentState[i].ColorBlendOp * 23;
|
||||
hash64 ^= (uint)ColorBlendAttachmentState[i].SrcAlphaBlendFactor * 23;
|
||||
hash64 ^= (uint)ColorBlendAttachmentState[i].DstAlphaBlendFactor * 23;
|
||||
hash64 ^= (uint)ColorBlendAttachmentState[i].AlphaBlendOp * 23;
|
||||
hash64 ^= (uint)ColorBlendAttachmentState[i].ColorWriteMask * 23;
|
||||
hash64 ^= colorBlendAttachmentStateSpan[i].BlendEnable * 23;
|
||||
hash64 ^= (uint)colorBlendAttachmentStateSpan[i].SrcColorBlendFactor * 23;
|
||||
hash64 ^= (uint)colorBlendAttachmentStateSpan[i].DstColorBlendFactor * 23;
|
||||
hash64 ^= (uint)colorBlendAttachmentStateSpan[i].ColorBlendOp * 23;
|
||||
hash64 ^= (uint)colorBlendAttachmentStateSpan[i].SrcAlphaBlendFactor * 23;
|
||||
hash64 ^= (uint)colorBlendAttachmentStateSpan[i].DstAlphaBlendFactor * 23;
|
||||
hash64 ^= (uint)colorBlendAttachmentStateSpan[i].AlphaBlendOp * 23;
|
||||
hash64 ^= (uint)colorBlendAttachmentStateSpan[i].ColorWriteMask * 23;
|
||||
}
|
||||
|
||||
ReadOnlySpan<Format> attachmentFormatsSpan = AttachmentFormats.AsSpan();
|
||||
|
||||
for (int i = 0; i < (int)ColorBlendAttachmentStateCount; i++)
|
||||
{
|
||||
hash64 ^= (uint)AttachmentFormats[i] * 23;
|
||||
hash64 ^= (uint)attachmentFormatsSpan[i] * 23;
|
||||
}
|
||||
|
||||
return (int)hash64 ^ ((int)(hash64 >> 32) * 17);
|
||||
|
||||
Reference in New Issue
Block a user