aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2020-12-03 18:34:32 +0000
committerGitHub <noreply@github.com>2020-12-03 19:34:32 +0100
commit2c39a4f15d44156779c6c926d8feda26a4a24605 (patch)
tree4698a5eab3a7599c3e753070c01d5bbb3f802e23 /Ryujinx.Graphics.Gpu/Memory
parent0ab1c42eeae48530853ec22a8790a492c254006d (diff)
Cache delegate for QueryModified, use regular multi handle. (#1771)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/Buffer.cs50
1 files changed, 30 insertions, 20 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index 3cc96432..bf245283 100644
--- a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -34,8 +34,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
public ulong EndAddress => Address + Size;
- private CpuSmartMultiRegionHandle _memoryTrackingGranular;
+ private CpuMultiRegionHandle _memoryTrackingGranular;
private CpuRegionHandle _memoryTracking;
+ private readonly Action<ulong, ulong> _modifiedDelegate;
private int _sequenceNumber;
private bool _useGranular;
@@ -58,12 +59,14 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (_useGranular)
{
- _memoryTrackingGranular = context.PhysicalMemory.BeginSmartGranularTracking(address, size);
+ _memoryTrackingGranular = context.PhysicalMemory.BeginGranularTracking(address, size);
}
else
{
_memoryTracking = context.PhysicalMemory.BeginTracking(address, size);
}
+
+ _modifiedDelegate = new Action<ulong, ulong>(RegionModified);
}
/// <summary>
@@ -106,24 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
if (_useGranular)
{
- _memoryTrackingGranular.QueryModified(address, size, (ulong mAddress, ulong mSize) =>
- {
- if (mAddress < Address)
- {
- mAddress = Address;
- }
-
- ulong maxSize = Address + Size - mAddress;
-
- if (mSize > maxSize)
- {
- mSize = maxSize;
- }
-
- int offset = (int)(mAddress - Address);
-
- _context.Renderer.SetBufferData(Handle, offset, _context.PhysicalMemory.GetSpan(mAddress, (int)mSize));
- }, _context.SequenceNumber);
+ _memoryTrackingGranular.QueryModified(address, size, _modifiedDelegate, _context.SequenceNumber);
}
else
{
@@ -137,6 +123,30 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
+ /// Indicate that a region of the buffer was modified, and must be loaded from memory.
+ /// </summary>
+ /// <param name="mAddress">Start address of the modified region</param>
+ /// <param name="mSize">Size of the modified region</param>
+ private void RegionModified(ulong mAddress, ulong mSize)
+ {
+ if (mAddress < Address)
+ {
+ mAddress = Address;
+ }
+
+ ulong maxSize = Address + Size - mAddress;
+
+ if (mSize > maxSize)
+ {
+ mSize = maxSize;
+ }
+
+ int offset = (int)(mAddress - Address);
+
+ _context.Renderer.SetBufferData(Handle, offset, _context.PhysicalMemory.GetSpan(mAddress, (int)mSize));
+ }
+
+ /// <summary>
/// Performs copy of all the buffer data from one buffer to another.
/// </summary>
/// <param name="destination">The destination buffer to copy the data into</param>