aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs24
1 files changed, 21 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
index 8b2401c7..3d2af532 100644
--- a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -12,19 +12,24 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// Represents physical memory, accessible from the GPU.
/// This is actually working CPU virtual addresses, of memory mapped on the application process.
/// </summary>
- class PhysicalMemory
+ class PhysicalMemory : IDisposable
{
public const int PageSize = 0x1000;
- private readonly Cpu.MemoryManager _cpuMemory;
+ private IVirtualMemoryManagerTracked _cpuMemory;
/// <summary>
/// Creates a new instance of the physical memory.
/// </summary>
/// <param name="cpuMemory">CPU memory manager of the application process</param>
- public PhysicalMemory(Cpu.MemoryManager cpuMemory)
+ public PhysicalMemory(IVirtualMemoryManagerTracked cpuMemory)
{
_cpuMemory = cpuMemory;
+
+ if (_cpuMemory is IRefCounted rc)
+ {
+ rc.IncrementReferenceCount();
+ }
}
/// <summary>
@@ -213,5 +218,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
return _cpuMemory.BeginSmartGranularTracking(address, size, granularity);
}
+
+ /// <summary>
+ /// Release our reference to the CPU memory manager.
+ /// </summary>
+ public void Dispose()
+ {
+ if (_cpuMemory is IRefCounted rc)
+ {
+ rc.DecrementReferenceCount();
+
+ _cpuMemory = null;
+ }
+ }
}
} \ No newline at end of file