mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 01:25:25 +00:00
Smaller initial size for ModifiedRangeList & directly inherit range list (#2663)
This fixes a potential regression with the new range list changes, where the cost for creating new ones would be rather large due to creating a 1024 size array. Also reduces cost for range list inheritance by using the first existing range list as a base, rather than creating a new one then adding both lists to it. The growth size for the RangeList is now identical to its initial size. Every 32 elements was probably a little too common - now it is 1024 for most things and 8 for the buffer modified range list. The Unmapped and SyncMethod methods have been changed to ensure that they behave properly if the range list is set null. Cleaned up a few calls to use the null-conditional operator.
This commit is contained in:
parent
75f4b1ff2d
commit
fff48bb45a
|
@ -259,10 +259,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// <param name="size">The size of the region</param>
|
/// <param name="size">The size of the region</param>
|
||||||
public void ClearModified(ulong address, ulong size)
|
public void ClearModified(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
if (_modifiedRanges != null)
|
_modifiedRanges?.Clear(address, size);
|
||||||
{
|
|
||||||
_modifiedRanges.Clear(address, size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -275,7 +272,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
|
|
||||||
if (_useGranular)
|
if (_useGranular)
|
||||||
{
|
{
|
||||||
_modifiedRanges.GetRanges(Address, Size, (address, size) =>
|
_modifiedRanges?.GetRanges(Address, Size, (address, size) =>
|
||||||
{
|
{
|
||||||
_memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
|
_memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
|
||||||
SynchronizeMemory(address, size);
|
SynchronizeMemory(address, size);
|
||||||
|
@ -302,18 +299,25 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
_syncActionRegistered = true;
|
_syncActionRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureRangeList();
|
if (_modifiedRanges == null)
|
||||||
_modifiedRanges.InheritRanges(from._modifiedRanges, (ulong address, ulong size) =>
|
|
||||||
{
|
{
|
||||||
if (_useGranular)
|
_modifiedRanges = from._modifiedRanges;
|
||||||
|
from._modifiedRanges = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_modifiedRanges.InheritRanges(from._modifiedRanges, (ulong address, ulong size) =>
|
||||||
{
|
{
|
||||||
_memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
|
if (_useGranular)
|
||||||
}
|
{
|
||||||
else
|
_memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
|
||||||
{
|
}
|
||||||
_memoryTracking.RegisterAction(_externalFlushDelegate);
|
else
|
||||||
}
|
{
|
||||||
});
|
_memoryTracking.RegisterAction(_externalFlushDelegate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,10 +385,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// <param name="mSize">Size of the region to force dirty</param>
|
/// <param name="mSize">Size of the region to force dirty</param>
|
||||||
public void ForceDirty(ulong mAddress, ulong mSize)
|
public void ForceDirty(ulong mAddress, ulong mSize)
|
||||||
{
|
{
|
||||||
if (_modifiedRanges != null)
|
_modifiedRanges?.Clear(mAddress, mSize);
|
||||||
{
|
|
||||||
_modifiedRanges.Clear(mAddress, mSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_useGranular)
|
if (_useGranular)
|
||||||
{
|
{
|
||||||
|
@ -497,7 +498,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// <param name="size">Size of the unmapped region</param>
|
/// <param name="size">Size of the unmapped region</param>
|
||||||
public void Unmapped(ulong address, ulong size)
|
public void Unmapped(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
_modifiedRanges?.Clear(address, size);
|
BufferModifiedRangeList modifiedRanges = _modifiedRanges;
|
||||||
|
|
||||||
|
modifiedRanges?.Clear(address, size);
|
||||||
|
|
||||||
UnmappedSequence++;
|
UnmappedSequence++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class BufferModifiedRangeList : RangeList<BufferModifiedRange>
|
class BufferModifiedRangeList : RangeList<BufferModifiedRange>
|
||||||
{
|
{
|
||||||
|
private const int BackingInitialSize = 8;
|
||||||
|
|
||||||
private GpuContext _context;
|
private GpuContext _context;
|
||||||
|
|
||||||
private object _lock = new object();
|
private object _lock = new object();
|
||||||
|
@ -68,7 +70,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// Creates a new instance of a modified range list.
|
/// Creates a new instance of a modified range list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">GPU context that the buffer range list belongs to</param>
|
/// <param name="context">GPU context that the buffer range list belongs to</param>
|
||||||
public BufferModifiedRangeList(GpuContext context)
|
public BufferModifiedRangeList(GpuContext context) : base(BackingInitialSize)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,22 @@ namespace Ryujinx.Memory.Range
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const int BackingInitialSize = 1024;
|
||||||
private const int ArrayGrowthSize = 32;
|
private const int ArrayGrowthSize = 32;
|
||||||
private const int BackingGrowthSize = 1024;
|
|
||||||
|
|
||||||
private RangeItem<T>[] _items;
|
private RangeItem<T>[] _items;
|
||||||
|
private readonly int _backingGrowthSize;
|
||||||
|
|
||||||
public int Count { get; protected set; }
|
public int Count { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new range list.
|
/// Creates a new range list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RangeList()
|
/// <param name="backingInitialSize">The initial size of the backing array</param>
|
||||||
|
public RangeList(int backingInitialSize = BackingInitialSize)
|
||||||
{
|
{
|
||||||
_items = new RangeItem<T>[BackingGrowthSize];
|
_backingGrowthSize = backingInitialSize;
|
||||||
|
_items = new RangeItem<T>[backingInitialSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -68,7 +72,7 @@ namespace Ryujinx.Memory.Range
|
||||||
{
|
{
|
||||||
if (Count + 1 > _items.Length)
|
if (Count + 1 > _items.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _items, _items.Length + ArrayGrowthSize);
|
Array.Resize(ref _items, _items.Length + _backingGrowthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= Count)
|
if (index >= Count)
|
||||||
|
|
Loading…
Reference in a new issue