From 7df4fcada702dbc01d09b8f6fa027f5d409e33e3 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Fri, 5 May 2023 22:40:46 +0100 Subject: [PATCH] GPU: Remove CPU region handle containers (#4817) * GPU: Remove CPU region handle containers. Another one for the "I don't know why I didn't do this earlier" pile. This removes the "Cpu" prefixed region handle classes, which each mirror a region handle type from Ryujinx.Memory. Originally, not all projects had a reference to Ryujinx.Memory, so these classes were introduced to bridge the gap. Someone else crossed that bridge since, so these classes don't have much of a purpose anymore. This PR replaces all uses of CpuRegionHandle etc to their direct Ryujinx.Memory versions. RegionHandle methods (specifically QueryModified) are about the hottest path there is in the entire emulator, so there is a nice boost from doing this. * Add docs --- src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs | 13 +++---- .../IVirtualMemoryManagerTracked.cs | 9 ++--- src/Ryujinx.Cpu/Jit/MemoryManager.cs | 13 +++---- .../Jit/MemoryManagerHostMapped.cs | 13 +++---- .../Tracking/CpuMultiRegionHandle.cs | 28 -------------- src/Ryujinx.Cpu/Tracking/CpuRegionHandle.cs | 37 ------------------- .../Tracking/CpuSmartMultiRegionHandle.cs | 26 ------------- src/Ryujinx.Graphics.Gpu/Image/Pool.cs | 4 +- .../Image/TextureGroup.cs | 22 +++++------ .../Image/TextureGroupHandle.cs | 10 ++--- src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs | 7 ++-- .../Memory/GpuRegionHandle.cs | 7 ++-- .../Memory/PhysicalMemory.cs | 9 ++--- src/Ryujinx.Memory/Tracking/RegionHandle.cs | 11 ++++++ 14 files changed, 61 insertions(+), 148 deletions(-) delete mode 100644 src/Ryujinx.Cpu/Tracking/CpuMultiRegionHandle.cs delete mode 100644 src/Ryujinx.Cpu/Tracking/CpuRegionHandle.cs delete mode 100644 src/Ryujinx.Cpu/Tracking/CpuSmartMultiRegionHandle.cs diff --git a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs index 437e02ae..56a329e0 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs @@ -1,5 +1,4 @@ using ARMeilleure.Memory; -using Ryujinx.Cpu.Tracking; using Ryujinx.Memory; using Ryujinx.Memory.Range; using Ryujinx.Memory.Tracking; @@ -822,21 +821,21 @@ namespace Ryujinx.Cpu.AppleHv } /// - public CpuRegionHandle BeginTracking(ulong address, ulong size, int id) + public RegionHandle BeginTracking(ulong address, ulong size, int id) { - return new CpuRegionHandle(Tracking.BeginTracking(address, size, id)); + return Tracking.BeginTracking(address, size, id); } /// - public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id) + public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id) { - return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id)); + return Tracking.BeginGranularTracking(address, size, handles, granularity, id); } /// - public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id) + public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id) { - return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id)); + return Tracking.BeginSmartGranularTracking(address, size, granularity, id); } /// diff --git a/src/Ryujinx.Cpu/IVirtualMemoryManagerTracked.cs b/src/Ryujinx.Cpu/IVirtualMemoryManagerTracked.cs index 92d3c76c..5fa88d62 100644 --- a/src/Ryujinx.Cpu/IVirtualMemoryManagerTracked.cs +++ b/src/Ryujinx.Cpu/IVirtualMemoryManagerTracked.cs @@ -1,5 +1,4 @@ -using Ryujinx.Cpu.Tracking; -using Ryujinx.Memory; +using Ryujinx.Memory; using Ryujinx.Memory.Tracking; using System; using System.Collections.Generic; @@ -30,7 +29,7 @@ namespace Ryujinx.Cpu /// Size of the region /// Handle ID /// The memory tracking handle - CpuRegionHandle BeginTracking(ulong address, ulong size, int id); + RegionHandle BeginTracking(ulong address, ulong size, int id); /// /// Obtains a memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with. @@ -41,7 +40,7 @@ namespace Ryujinx.Cpu /// Desired granularity of write tracking /// Handle ID /// The memory tracking handle - CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id); + MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id); /// /// Obtains a smart memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with. @@ -51,6 +50,6 @@ namespace Ryujinx.Cpu /// Desired granularity of write tracking /// Handle ID /// The memory tracking handle - CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id); + SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id); } } diff --git a/src/Ryujinx.Cpu/Jit/MemoryManager.cs b/src/Ryujinx.Cpu/Jit/MemoryManager.cs index 8542d53e..6da11fb8 100644 --- a/src/Ryujinx.Cpu/Jit/MemoryManager.cs +++ b/src/Ryujinx.Cpu/Jit/MemoryManager.cs @@ -1,5 +1,4 @@ using ARMeilleure.Memory; -using Ryujinx.Cpu.Tracking; using Ryujinx.Memory; using Ryujinx.Memory.Range; using Ryujinx.Memory.Tracking; @@ -629,21 +628,21 @@ namespace Ryujinx.Cpu.Jit } /// - public CpuRegionHandle BeginTracking(ulong address, ulong size, int id) + public RegionHandle BeginTracking(ulong address, ulong size, int id) { - return new CpuRegionHandle(Tracking.BeginTracking(address, size, id)); + return Tracking.BeginTracking(address, size, id); } /// - public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id) + public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id) { - return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id)); + return Tracking.BeginGranularTracking(address, size, handles, granularity, id); } /// - public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id) + public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id) { - return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id)); + return Tracking.BeginSmartGranularTracking(address, size, granularity, id); } /// diff --git a/src/Ryujinx.Cpu/Jit/MemoryManagerHostMapped.cs b/src/Ryujinx.Cpu/Jit/MemoryManagerHostMapped.cs index 090740ab..363f9000 100644 --- a/src/Ryujinx.Cpu/Jit/MemoryManagerHostMapped.cs +++ b/src/Ryujinx.Cpu/Jit/MemoryManagerHostMapped.cs @@ -1,5 +1,4 @@ using ARMeilleure.Memory; -using Ryujinx.Cpu.Tracking; using Ryujinx.Memory; using Ryujinx.Memory.Range; using Ryujinx.Memory.Tracking; @@ -706,21 +705,21 @@ namespace Ryujinx.Cpu.Jit } /// - public CpuRegionHandle BeginTracking(ulong address, ulong size, int id) + public RegionHandle BeginTracking(ulong address, ulong size, int id) { - return new CpuRegionHandle(Tracking.BeginTracking(address, size, id)); + return Tracking.BeginTracking(address, size, id); } /// - public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id) + public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable handles, ulong granularity, int id) { - return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id)); + return Tracking.BeginGranularTracking(address, size, handles, granularity, id); } /// - public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id) + public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id) { - return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id)); + return Tracking.BeginSmartGranularTracking(address, size, granularity, id); } /// diff --git a/src/Ryujinx.Cpu/Tracking/CpuMultiRegionHandle.cs b/src/Ryujinx.Cpu/Tracking/CpuMultiRegionHandle.cs deleted file mode 100644 index 0ed8bfc5..00000000 --- a/src/Ryujinx.Cpu/Tracking/CpuMultiRegionHandle.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Ryujinx.Memory.Tracking; -using System; -using System.Collections.Generic; - -namespace Ryujinx.Cpu.Tracking -{ - public class CpuMultiRegionHandle : IMultiRegionHandle - { - private readonly MultiRegionHandle _impl; - - public bool Dirty => _impl.Dirty; - - internal CpuMultiRegionHandle(MultiRegionHandle impl) - { - _impl = impl; - } - - public void Dispose() => _impl.Dispose(); - public void ForceDirty(ulong address, ulong size) => _impl.ForceDirty(address, size); - public IEnumerable GetHandles() => _impl.GetHandles(); - public void QueryModified(Action modifiedAction) => _impl.QueryModified(modifiedAction); - public void QueryModified(ulong address, ulong size, Action modifiedAction) => _impl.QueryModified(address, size, modifiedAction); - public void QueryModified(ulong address, ulong size, Action modifiedAction, int sequenceNumber) => _impl.QueryModified(address, size, modifiedAction, sequenceNumber); - public void RegisterAction(ulong address, ulong size, RegionSignal action) => _impl.RegisterAction(address, size, action); - public void RegisterPreciseAction(ulong address, ulong size, PreciseRegionSignal action) => _impl.RegisterPreciseAction(address, size, action); - public void SignalWrite() => _impl.SignalWrite(); - } -} diff --git a/src/Ryujinx.Cpu/Tracking/CpuRegionHandle.cs b/src/Ryujinx.Cpu/Tracking/CpuRegionHandle.cs deleted file mode 100644 index e766460f..00000000 --- a/src/Ryujinx.Cpu/Tracking/CpuRegionHandle.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Ryujinx.Memory.Tracking; -using System; - -namespace Ryujinx.Cpu.Tracking -{ - public class CpuRegionHandle : IRegionHandle - { - private readonly RegionHandle _impl; - - public bool Dirty => _impl.Dirty; - public bool Unmapped => _impl.Unmapped; - public ulong Address => _impl.Address; - public ulong Size => _impl.Size; - public ulong EndAddress => _impl.EndAddress; - - internal CpuRegionHandle(RegionHandle impl) - { - _impl = impl; - } - - public void Dispose() => _impl.Dispose(); - public bool DirtyOrVolatile() => _impl.DirtyOrVolatile(); - public void ForceDirty() => _impl.ForceDirty(); - public IRegionHandle GetHandle() => _impl; - public void RegisterAction(RegionSignal action) => _impl.RegisterAction(action); - public void RegisterPreciseAction(PreciseRegionSignal action) => _impl.RegisterPreciseAction(action); - public void RegisterDirtyEvent(Action action) => _impl.RegisterDirtyEvent(action); - public void Reprotect(bool asDirty = false) => _impl.Reprotect(asDirty); - - public bool OverlapsWith(ulong address, ulong size) => _impl.OverlapsWith(address, size); - - public bool RangeEquals(CpuRegionHandle other) - { - return _impl.RealAddress == other._impl.RealAddress && _impl.RealSize == other._impl.RealSize; - } - } -} diff --git a/src/Ryujinx.Cpu/Tracking/CpuSmartMultiRegionHandle.cs b/src/Ryujinx.Cpu/Tracking/CpuSmartMultiRegionHandle.cs deleted file mode 100644 index 665271c6..00000000 --- a/src/Ryujinx.Cpu/Tracking/CpuSmartMultiRegionHandle.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Ryujinx.Memory.Tracking; -using System; - -namespace Ryujinx.Cpu.Tracking -{ - public class CpuSmartMultiRegionHandle : IMultiRegionHandle - { - private readonly SmartMultiRegionHandle _impl; - - public bool Dirty => _impl.Dirty; - - internal CpuSmartMultiRegionHandle(SmartMultiRegionHandle impl) - { - _impl = impl; - } - - public void Dispose() => _impl.Dispose(); - public void ForceDirty(ulong address, ulong size) => _impl.ForceDirty(address, size); - public void RegisterAction(RegionSignal action) => _impl.RegisterAction(action); - public void RegisterPreciseAction(PreciseRegionSignal action) => _impl.RegisterPreciseAction(action); - public void QueryModified(Action modifiedAction) => _impl.QueryModified(modifiedAction); - public void QueryModified(ulong address, ulong size, Action modifiedAction) => _impl.QueryModified(address, size, modifiedAction); - public void QueryModified(ulong address, ulong size, Action modifiedAction, int sequenceNumber) => _impl.QueryModified(address, size, modifiedAction, sequenceNumber); - public void SignalWrite() => _impl.SignalWrite(); - } -} diff --git a/src/Ryujinx.Graphics.Gpu/Image/Pool.cs b/src/Ryujinx.Graphics.Gpu/Image/Pool.cs index 3e557c0b..63be151f 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/Pool.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/Pool.cs @@ -1,5 +1,5 @@ -using Ryujinx.Cpu.Tracking; using Ryujinx.Graphics.Gpu.Memory; +using Ryujinx.Memory.Tracking; using System; using System.Runtime.InteropServices; @@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// public ulong Size { get; } - private readonly CpuMultiRegionHandle _memoryTracking; + private readonly MultiRegionHandle _memoryTracking; private readonly Action _modifiedDelegate; private int _modifiedSequenceOffset; diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs index 14ab5d1e..b36b16e9 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs @@ -1,10 +1,10 @@ using Ryujinx.Common.Memory; -using Ryujinx.Cpu.Tracking; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Texture; using Ryujinx.Memory; using Ryujinx.Memory.Range; +using Ryujinx.Memory.Tracking; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -255,7 +255,7 @@ namespace Ryujinx.Graphics.Gpu.Image { TextureGroupHandle group = _handles[baseHandle + i]; - foreach (CpuRegionHandle handle in group.Handles) + foreach (RegionHandle handle in group.Handles) { if (handle.Dirty) { @@ -296,7 +296,7 @@ namespace Ryujinx.Graphics.Gpu.Image bool handleDirty = false; bool handleUnmapped = false; - foreach (CpuRegionHandle handle in group.Handles) + foreach (RegionHandle handle in group.Handles) { if (handle.Dirty) { @@ -703,7 +703,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The group to register an action for public void RegisterAction(TextureGroupHandle group) { - foreach (CpuRegionHandle handle in group.Handles) + foreach (RegionHandle handle in group.Handles) { handle.RegisterAction((address, size) => FlushAction(group, address, size)); } @@ -985,7 +985,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The start address of the tracked region /// The size of the tracked region /// A CpuRegionHandle covering the given range - private CpuRegionHandle GenerateHandle(ulong address, ulong size) + private RegionHandle GenerateHandle(ulong address, ulong size) { return _physicalMemory.BeginTracking(address, size, ResourceKind.Texture); } @@ -1005,7 +1005,7 @@ namespace Ryujinx.Graphics.Gpu.Image int endOffset = _allOffsets[viewEnd] + _sliceSizes[lastLevel]; int size = endOffset - offset; - var result = new List(); + var result = new List(); for (int i = 0; i < TextureRange.Count; i++) { @@ -1050,7 +1050,7 @@ namespace Ryujinx.Graphics.Gpu.Image views, result.ToArray()); - foreach (CpuRegionHandle handle in result) + foreach (RegionHandle handle in result) { handle.RegisterDirtyEvent(() => DirtyAction(groupHandle)); } @@ -1248,7 +1248,7 @@ namespace Ryujinx.Graphics.Gpu.Image continue; } - foreach (CpuRegionHandle handle in groupHandle.Handles) + foreach (RegionHandle handle in groupHandle.Handles) { bool hasMatch = false; @@ -1270,7 +1270,7 @@ namespace Ryujinx.Graphics.Gpu.Image } else { - foreach (CpuRegionHandle handle in groupHandle.Handles) + foreach (RegionHandle handle in groupHandle.Handles) { handle.Reprotect(); } @@ -1303,7 +1303,7 @@ namespace Ryujinx.Graphics.Gpu.Image if (!(_hasMipViews || _hasLayerViews)) { // Single dirty region. - var cpuRegionHandles = new CpuRegionHandle[TextureRange.Count]; + var cpuRegionHandles = new RegionHandle[TextureRange.Count]; int count = 0; for (int i = 0; i < TextureRange.Count; i++) @@ -1322,7 +1322,7 @@ namespace Ryujinx.Graphics.Gpu.Image var groupHandle = new TextureGroupHandle(this, 0, Storage.Size, _views, 0, 0, 0, _allOffsets.Length, cpuRegionHandles); - foreach (CpuRegionHandle handle in cpuRegionHandles) + foreach (RegionHandle handle in cpuRegionHandles) { handle.RegisterDirtyEvent(() => DirtyAction(groupHandle)); } diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs index 9f66744b..fd66269d 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs @@ -1,5 +1,5 @@ -using Ryujinx.Cpu.Tracking; -using Ryujinx.Graphics.Gpu.Synchronization; +using Ryujinx.Graphics.Gpu.Synchronization; +using Ryujinx.Memory.Tracking; using System; using System.Collections.Generic; using System.Linq; @@ -85,7 +85,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// /// The CPU memory tracking handles that cover this handle. /// - public CpuRegionHandle[] Handles { get; } + public RegionHandle[] Handles { get; } /// /// True if a texture overlapping this handle has been modified. Is set false when the flush action is called. @@ -127,7 +127,7 @@ namespace Ryujinx.Graphics.Gpu.Image int firstLevel, int baseSlice, int sliceCount, - CpuRegionHandle[] handles) + RegionHandle[] handles) { _group = group; _firstLayer = firstLayer; @@ -642,7 +642,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// public void Dispose() { - foreach (CpuRegionHandle handle in Handles) + foreach (RegionHandle handle in Handles) { handle.Dispose(); } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index 8e16b3ae..dc5037c5 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -1,4 +1,3 @@ -using Ryujinx.Cpu.Tracking; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Synchronization; using Ryujinx.Memory.Range; @@ -54,8 +53,8 @@ namespace Ryujinx.Graphics.Gpu.Memory /// private BufferModifiedRangeList _modifiedRanges = null; - private readonly CpuMultiRegionHandle _memoryTrackingGranular; - private readonly CpuRegionHandle _memoryTracking; + private readonly MultiRegionHandle _memoryTrackingGranular; + private readonly RegionHandle _memoryTracking; private readonly RegionSignal _externalFlushDelegate; private readonly Action _loadDelegate; @@ -102,7 +101,7 @@ namespace Ryujinx.Graphics.Gpu.Memory } else { - return Enumerable.Repeat(buffer._memoryTracking.GetHandle(), 1); + return Enumerable.Repeat(buffer._memoryTracking, 1); } }); } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs b/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs index bc07bfad..9f73de4e 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs @@ -1,5 +1,4 @@ -using Ryujinx.Cpu.Tracking; -using Ryujinx.Memory.Tracking; +using Ryujinx.Memory.Tracking; using System; namespace Ryujinx.Graphics.Gpu.Memory @@ -9,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// class GpuRegionHandle : IRegionHandle { - private readonly CpuRegionHandle[] _cpuRegionHandles; + private readonly RegionHandle[] _cpuRegionHandles; public bool Dirty { @@ -35,7 +34,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Create a new GpuRegionHandle, made up of mulitple CpuRegionHandles. /// /// The CpuRegionHandles that make up this handle - public GpuRegionHandle(CpuRegionHandle[] cpuRegionHandles) + public GpuRegionHandle(RegionHandle[] cpuRegionHandles) { _cpuRegionHandles = cpuRegionHandles; } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs index b976667c..364488aa 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs @@ -1,5 +1,4 @@ using Ryujinx.Cpu; -using Ryujinx.Cpu.Tracking; using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Gpu.Shader; using Ryujinx.Memory; @@ -348,7 +347,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Size of the region /// Kind of the resource being tracked /// The memory tracking handle - public CpuRegionHandle BeginTracking(ulong address, ulong size, ResourceKind kind) + public RegionHandle BeginTracking(ulong address, ulong size, ResourceKind kind) { return _cpuMemory.BeginTracking(address, size, (int)kind); } @@ -361,7 +360,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// The memory tracking handle public GpuRegionHandle BeginTracking(MultiRange range, ResourceKind kind) { - var cpuRegionHandles = new CpuRegionHandle[range.Count]; + var cpuRegionHandles = new RegionHandle[range.Count]; int count = 0; for (int i = 0; i < range.Count; i++) @@ -390,7 +389,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Handles to inherit state from or reuse /// Desired granularity of write tracking /// The memory tracking handle - public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, ResourceKind kind, IEnumerable handles = null, ulong granularity = 4096) + public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, ResourceKind kind, IEnumerable handles = null, ulong granularity = 4096) { return _cpuMemory.BeginGranularTracking(address, size, handles, granularity, (int)kind); } @@ -403,7 +402,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Kind of the resource being tracked /// Desired granularity of write tracking /// The memory tracking handle - public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ResourceKind kind, ulong granularity = 4096) + public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ResourceKind kind, ulong granularity = 4096) { return _cpuMemory.BeginSmartGranularTracking(address, size, granularity, (int)kind); } diff --git a/src/Ryujinx.Memory/Tracking/RegionHandle.cs b/src/Ryujinx.Memory/Tracking/RegionHandle.cs index 7a59f9f2..63a16884 100644 --- a/src/Ryujinx.Memory/Tracking/RegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/RegionHandle.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata; using System.Threading; namespace Ryujinx.Memory.Tracking @@ -443,6 +444,16 @@ namespace Ryujinx.Memory.Tracking return Address < address + size && address < EndAddress; } + /// + /// Determines if this handle's memory range matches another exactly. + /// + /// The other handle + /// True on a match, false otherwise + public bool RangeEquals(RegionHandle other) + { + return RealAddress == other.RealAddress && RealSize == other.RealSize; + } + /// /// Dispose the handle. Within the tracking lock, this removes references from virtual regions. ///