aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2021-10-04 19:38:59 +0100
committerGitHub <noreply@github.com>2021-10-04 15:38:59 -0300
commitfff48bb45a197e4c1307340112cfed7fd45f5a83 (patch)
treecac718838e9da631541d9a73293ed026cb8b8cdb /Ryujinx.Graphics.Gpu/Memory
parent75f4b1ff2de8d8bd57dd84f2c3cb4cb3c353b93b (diff)
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.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/Buffer.cs43
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs4
2 files changed, 26 insertions, 21 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index 76125e31..0eaf0123 100644
--- a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -259,10 +259,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="size">The size of the region</param>
public void ClearModified(ulong address, ulong size)
{
- if (_modifiedRanges != null)
- {
- _modifiedRanges.Clear(address, size);
- }
+ _modifiedRanges?.Clear(address, size);
}
/// <summary>
@@ -275,7 +272,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (_useGranular)
{
- _modifiedRanges.GetRanges(Address, Size, (address, size) =>
+ _modifiedRanges?.GetRanges(Address, Size, (address, size) =>
{
_memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
SynchronizeMemory(address, size);
@@ -302,18 +299,25 @@ namespace Ryujinx.Graphics.Gpu.Memory
_syncActionRegistered = true;
}
- EnsureRangeList();
- _modifiedRanges.InheritRanges(from._modifiedRanges, (ulong address, ulong size) =>
+ if (_modifiedRanges == null)
{
- if (_useGranular)
- {
- _memoryTrackingGranular.RegisterAction(address, size, _externalFlushDelegate);
- }
- else
+ _modifiedRanges = from._modifiedRanges;
+ from._modifiedRanges = null;
+ }
+ else
+ {
+ _modifiedRanges.InheritRanges(from._modifiedRanges, (ulong address, ulong size) =>
{
- _memoryTracking.RegisterAction(_externalFlushDelegate);
- }
- });
+ if (_useGranular)
+ {
+ _memoryTrackingGranular.RegisterAction(address, size, _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>
public void ForceDirty(ulong mAddress, ulong mSize)
{
- if (_modifiedRanges != null)
- {
- _modifiedRanges.Clear(mAddress, mSize);
- }
+ _modifiedRanges?.Clear(mAddress, mSize);
if (_useGranular)
{
@@ -497,7 +498,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="size">Size of the unmapped region</param>
public void Unmapped(ulong address, ulong size)
{
- _modifiedRanges?.Clear(address, size);
+ BufferModifiedRangeList modifiedRanges = _modifiedRanges;
+
+ modifiedRanges?.Clear(address, size);
UnmappedSequence++;
}
diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
index 63227431..84cf0dd8 100644
--- a/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
@@ -60,6 +60,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
class BufferModifiedRangeList : RangeList<BufferModifiedRange>
{
+ private const int BackingInitialSize = 8;
+
private GpuContext _context;
private object _lock = new object();
@@ -68,7 +70,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// Creates a new instance of a modified range list.
/// </summary>
/// <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;
}