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
This commit is contained in:
parent
8cc872fb60
commit
fbb4019ed5
44 changed files with 780 additions and 481 deletions
|
@ -13,9 +13,10 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
/// </summary>
|
||||
class Buffer : IRange, IDisposable
|
||||
{
|
||||
private static ulong GranularBufferThreshold = 4096;
|
||||
private const ulong GranularBufferThreshold = 4096;
|
||||
|
||||
private readonly GpuContext _context;
|
||||
private readonly PhysicalMemory _physicalMemory;
|
||||
|
||||
/// <summary>
|
||||
/// Host buffer handle.
|
||||
|
@ -68,14 +69,16 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
/// Creates a new instance of the buffer.
|
||||
/// </summary>
|
||||
/// <param name="context">GPU context that the buffer belongs to</param>
|
||||
/// <param name="physicalMemory">Physical memory where the buffer is mapped</param>
|
||||
/// <param name="address">Start address of the buffer</param>
|
||||
/// <param name="size">Size of the buffer in bytes</param>
|
||||
/// <param name="baseBuffers">Buffers which this buffer contains, and will inherit tracking handles from</param>
|
||||
public Buffer(GpuContext context, ulong address, ulong size, IEnumerable<Buffer> baseBuffers = null)
|
||||
public Buffer(GpuContext context, PhysicalMemory physicalMemory, ulong address, ulong size, IEnumerable<Buffer> baseBuffers = null)
|
||||
{
|
||||
_context = context;
|
||||
Address = address;
|
||||
Size = size;
|
||||
_context = context;
|
||||
_physicalMemory = physicalMemory;
|
||||
Address = address;
|
||||
Size = size;
|
||||
|
||||
Handle = context.Renderer.CreateBuffer((int)size);
|
||||
|
||||
|
@ -100,11 +103,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
|
||||
if (_useGranular)
|
||||
{
|
||||
_memoryTrackingGranular = context.PhysicalMemory.BeginGranularTracking(address, size, baseHandles);
|
||||
_memoryTrackingGranular = physicalMemory.BeginGranularTracking(address, size, baseHandles);
|
||||
}
|
||||
else
|
||||
{
|
||||
_memoryTracking = context.PhysicalMemory.BeginTracking(address, size);
|
||||
_memoryTracking = physicalMemory.BeginTracking(address, size);
|
||||
|
||||
if (baseHandles != null)
|
||||
{
|
||||
|
@ -207,9 +210,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
}
|
||||
else
|
||||
{
|
||||
_context.Renderer.SetBufferData(Handle, 0, _context.PhysicalMemory.GetSpan(Address, (int)Size));
|
||||
_context.Renderer.SetBufferData(Handle, 0, _physicalMemory.GetSpan(Address, (int)Size));
|
||||
}
|
||||
|
||||
|
||||
_sequenceNumber = _context.SequenceNumber;
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +366,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
{
|
||||
int offset = (int)(mAddress - Address);
|
||||
|
||||
_context.Renderer.SetBufferData(Handle, offset, _context.PhysicalMemory.GetSpan(mAddress, (int)mSize));
|
||||
_context.Renderer.SetBufferData(Handle, offset, _physicalMemory.GetSpan(mAddress, (int)mSize));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -412,7 +415,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
byte[] data = _context.Renderer.GetBufferData(Handle, offset, (int)size);
|
||||
|
||||
// TODO: When write tracking shaders, they will need to be aware of changes in overlapping buffers.
|
||||
_context.PhysicalMemory.WriteUntracked(address, data);
|
||||
_physicalMemory.WriteUntracked(address, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue