Memory changes 3

General memory improvements to decrease GC pressure and frequency.

Pool big arrays and objects that are created and deleted often.

Skip data copies when they aren't needed.

Inline flag checks to skip unneeded allocations.

From my testing the performance is about the same, but the GC frequency is much lower and collection is faster causing less and smaller spikes.
This commit is contained in:
LotP 2025-10-30 20:55:58 -05:00 committed by KeatonTheBot
parent 2c50fbcc1f
commit e3ee28605d
42 changed files with 703 additions and 331 deletions

View file

@ -58,6 +58,8 @@ namespace Ryujinx.Graphics.Vulkan
private Dictionary<ulong, StagingBufferReserved> _mirrors;
private bool _useMirrors;
private Action _decrementReferenceCount;
public BufferHolder(VulkanRenderer gd, Device device, VkBuffer buffer, MemoryAllocation allocation, int size, BufferAllocationType type, BufferAllocationType currentType)
{
_gd = gd;
@ -75,6 +77,8 @@ namespace Ryujinx.Graphics.Vulkan
_flushLock = new ReaderWriterLockSlim();
_useMirrors = gd.IsTBDR;
_decrementReferenceCount = _buffer.DecrementReferenceCount;
}
public BufferHolder(VulkanRenderer gd, Device device, VkBuffer buffer, Auto<MemoryAllocation> allocation, int size, BufferAllocationType type, BufferAllocationType currentType, int offset)
@ -444,7 +448,7 @@ namespace Ryujinx.Graphics.Vulkan
_flushLock.ExitReadLock();
return PinnedSpan<byte>.UnsafeFromSpan(result, _buffer.DecrementReferenceCount);
return PinnedSpan<byte>.UnsafeFromSpan(result, _decrementReferenceCount);
}
BackgroundResource resource = _gd.BackgroundResources.Get();