From fbb4019ed5c12c4a888c7b09db648ac595366896 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 29 Jun 2021 14:32:02 -0300 Subject: Initial support for separate GPU address spaces (#2394) * Make GPU memory manager a member of GPU channel * Move physical memory instance to the memory manager, and the caches to the physical memory * PR feedback --- Ryujinx.Graphics.Gpu/Image/Pool.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image/Pool.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/Pool.cs b/Ryujinx.Graphics.Gpu/Image/Pool.cs index 0b4c2993..a06a7ccf 100644 --- a/Ryujinx.Graphics.Gpu/Image/Pool.cs +++ b/Ryujinx.Graphics.Gpu/Image/Pool.cs @@ -1,4 +1,5 @@ using Ryujinx.Cpu.Tracking; +using Ryujinx.Graphics.Gpu.Memory; using System; namespace Ryujinx.Graphics.Gpu.Image @@ -13,6 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Image protected const int DescriptorSize = 0x20; protected GpuContext Context; + protected PhysicalMemory PhysicalMemory; protected T1[] Items; protected T2[] DescriptorCache; @@ -38,9 +40,17 @@ namespace Ryujinx.Graphics.Gpu.Image private readonly CpuMultiRegionHandle _memoryTracking; private readonly Action _modifiedDelegate; - public Pool(GpuContext context, ulong address, int maximumId) + /// + /// Creates a new instance of the GPU resource pool. + /// + /// GPU context that the pool belongs to + /// Physical memory where the resource descriptors are mapped + /// Address of the pool in physical memory + /// Maximum index of an item on the pool (inclusive) + public Pool(GpuContext context, PhysicalMemory physicalMemory, ulong address, int maximumId) { - Context = context; + Context = context; + PhysicalMemory = physicalMemory; MaximumId = maximumId; int count = maximumId + 1; @@ -53,11 +63,10 @@ namespace Ryujinx.Graphics.Gpu.Image Address = address; Size = size; - _memoryTracking = context.PhysicalMemory.BeginGranularTracking(address, size); + _memoryTracking = physicalMemory.BeginGranularTracking(address, size); _modifiedDelegate = RegionModified; } - /// /// Gets the descriptor for a given ID. /// @@ -65,7 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The descriptor public T2 GetDescriptor(int id) { - return Context.PhysicalMemory.Read(Address + (ulong)id * DescriptorSize); + return PhysicalMemory.Read(Address + (ulong)id * DescriptorSize); } /// -- cgit v1.2.3