mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-04 08:48:51 +02:00
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:
@@ -93,6 +93,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
private ulong _dirtyStart = ulong.MaxValue;
|
||||
private ulong _dirtyEnd = ulong.MaxValue;
|
||||
|
||||
private readonly Action<ulong, ulong> _syncPreRangeAction;
|
||||
private readonly Action<ulong, ulong> _syncRangeAction;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the buffer.
|
||||
/// </summary>
|
||||
@@ -177,6 +180,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
_modifiedDelegate = RegionModified;
|
||||
|
||||
_virtualDependenciesLock = new ReaderWriterLockSlim();
|
||||
|
||||
_syncPreRangeAction = SyncPreRangeAction;
|
||||
_syncRangeAction = SyncRangeAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -401,13 +407,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
if (_preFlush.ShouldCopy)
|
||||
{
|
||||
_modifiedRanges?.GetRangesAtSync(Address, Size, _context.SyncNumber, (address, size) =>
|
||||
{
|
||||
_preFlush.CopyModified(address, size);
|
||||
});
|
||||
_modifiedRanges?.GetRangesAtSync(Address, Size, _context.SyncNumber, _syncPreRangeAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SyncPreRangeAction(ulong address, ulong size)
|
||||
{
|
||||
_preFlush.CopyModified(address, size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action to be performed when a syncpoint is reached after modification.
|
||||
@@ -420,11 +428,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
if (_useGranular)
|
||||
{
|
||||
_modifiedRanges?.GetRanges(Address, Size, (address, size) =>
|
||||
{
|
||||
_memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
|
||||
SynchronizeMemory(address, size);
|
||||
});
|
||||
|
||||
|
||||
_modifiedRanges?.GetRanges(Address, Size, _syncRangeAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -434,6 +440,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SyncRangeAction(ulong address, ulong size)
|
||||
{
|
||||
_memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
|
||||
SynchronizeMemory(address, size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inherit modified and dirty ranges from another buffer.
|
||||
|
||||
Reference in New Issue
Block a user