diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2020-12-03 18:34:32 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-03 19:34:32 +0100 |
| commit | 2c39a4f15d44156779c6c926d8feda26a4a24605 (patch) | |
| tree | 4698a5eab3a7599c3e753070c01d5bbb3f802e23 /Ryujinx.Graphics.Gpu/Image | |
| parent | 0ab1c42eeae48530853ec22a8790a492c254006d (diff) | |
Cache delegate for QueryModified, use regular multi handle. (#1771)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/Pool.cs | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/Pool.cs b/Ryujinx.Graphics.Gpu/Image/Pool.cs index dc0774ec..c2c1a9a1 100644 --- a/Ryujinx.Graphics.Gpu/Image/Pool.cs +++ b/Ryujinx.Graphics.Gpu/Image/Pool.cs @@ -36,6 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Image public ulong Size { get; } private readonly CpuMultiRegionHandle _memoryTracking; + private readonly Action<ulong, ulong> _modifiedDelegate; public Pool(GpuContext context, ulong address, int maximumId) { @@ -44,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu.Image int count = maximumId + 1; - ulong size = (ulong)(uint)count * DescriptorSize;; + ulong size = (ulong)(uint)count * DescriptorSize; Items = new T[count]; @@ -52,6 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Image Size = size; _memoryTracking = context.PhysicalMemory.BeginGranularTracking(address, size); + _modifiedDelegate = RegionModified; } /// <summary> @@ -68,22 +70,29 @@ namespace Ryujinx.Graphics.Gpu.Image /// </summary> public void SynchronizeMemory() { - _memoryTracking.QueryModified((ulong mAddress, ulong mSize) => + _memoryTracking.QueryModified(_modifiedDelegate); + } + + /// <summary> + /// Indicate that a region of the pool 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) { - if (mAddress < Address) - { - mAddress = Address; - } + mAddress = Address; + } - ulong maxSize = Address + Size - mAddress; + ulong maxSize = Address + Size - mAddress; - if (mSize > maxSize) - { - mSize = maxSize; - } + if (mSize > maxSize) + { + mSize = maxSize; + } - InvalidateRangeImpl(mAddress, mSize); - }); + InvalidateRangeImpl(mAddress, mSize); } protected abstract void InvalidateRangeImpl(ulong address, ulong size); |
