mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 13:16:24 +02:00
Add a separate device memory manager (#6153)
* Add a separate device memory manager * Still need this * Device writes are always tracked * Device writes are always tracked (2) * Rename more instances of gmm to mm
This commit is contained in:
parent
90455a05e6
commit
f241f88558
33 changed files with 555 additions and 157 deletions
|
@ -1,4 +1,4 @@
|
|||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Device;
|
||||
using Ryujinx.Graphics.Host1x;
|
||||
using Ryujinx.Graphics.Nvdec;
|
||||
using Ryujinx.Graphics.Vic;
|
||||
|
@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
{
|
||||
class Host1xContext : IDisposable
|
||||
{
|
||||
public MemoryManager Smmu { get; }
|
||||
public DeviceMemoryManager Smmu { get; }
|
||||
public NvMemoryAllocator MemoryAllocator { get; }
|
||||
public Host1xDevice Host1x { get; }
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
{
|
||||
MemoryAllocator = new NvMemoryAllocator();
|
||||
Host1x = new Host1xDevice(gpu.Synchronization);
|
||||
Smmu = gpu.CreateMemoryManager(pid);
|
||||
Smmu = gpu.CreateDeviceMemoryManager(pid);
|
||||
var nvdec = new NvdecDevice(Smmu);
|
||||
var vic = new VicDevice(Smmu);
|
||||
Host1x.RegisterDevice(ClassId.Nvdec, nvdec);
|
||||
|
|
|
@ -266,7 +266,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
if (size == 0)
|
||||
{
|
||||
size = (uint)map.Size;
|
||||
size = map.Size;
|
||||
}
|
||||
|
||||
NvInternalResult result = NvInternalResult.Success;
|
||||
|
|
|
@ -250,12 +250,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
{
|
||||
if (map.DmaMapAddress == 0)
|
||||
{
|
||||
ulong va = _host1xContext.MemoryAllocator.GetFreeAddress((ulong)map.Size, out ulong freeAddressStartPosition, 1, MemoryManager.PageSize);
|
||||
ulong va = _host1xContext.MemoryAllocator.GetFreeAddress(map.Size, out ulong freeAddressStartPosition, 1, MemoryManager.PageSize);
|
||||
|
||||
if (va != NvMemoryAllocator.PteUnmapped && va <= uint.MaxValue && (va + (uint)map.Size) <= uint.MaxValue)
|
||||
if (va != NvMemoryAllocator.PteUnmapped && va <= uint.MaxValue && (va + map.Size) <= uint.MaxValue)
|
||||
{
|
||||
_host1xContext.MemoryAllocator.AllocateRange(va, (uint)map.Size, freeAddressStartPosition);
|
||||
_host1xContext.Smmu.Map(map.Address, va, (uint)map.Size, PteKind.Pitch); // FIXME: This should not use the GMMU.
|
||||
_host1xContext.MemoryAllocator.AllocateRange(va, map.Size, freeAddressStartPosition);
|
||||
_host1xContext.Smmu.Map(map.Address, va, map.Size);
|
||||
map.DmaMapAddress = va;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
||||
int size = BitUtils.AlignUp(arguments.Size, (int)MemoryManager.PageSize);
|
||||
uint size = BitUtils.AlignUp(arguments.Size, (uint)MemoryManager.PageSize);
|
||||
|
||||
arguments.Handle = CreateHandleFromMap(new NvMapHandle(size));
|
||||
|
||||
|
@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
map.Align = arguments.Align;
|
||||
map.Kind = (byte)arguments.Kind;
|
||||
|
||||
int size = BitUtils.AlignUp(map.Size, (int)MemoryManager.PageSize);
|
||||
uint size = BitUtils.AlignUp(map.Size, (uint)MemoryManager.PageSize);
|
||||
|
||||
ulong address = arguments.Address;
|
||||
|
||||
|
@ -191,7 +191,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
switch (arguments.Param)
|
||||
{
|
||||
case NvMapHandleParam.Size:
|
||||
arguments.Result = map.Size;
|
||||
arguments.Result = (int)map.Size;
|
||||
break;
|
||||
case NvMapHandleParam.Align:
|
||||
arguments.Result = map.Align;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct NvMapCreate
|
||||
{
|
||||
public int Size;
|
||||
public uint Size;
|
||||
public int Handle;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
public int Handle;
|
||||
public int Padding;
|
||||
public ulong Address;
|
||||
public int Size;
|
||||
public uint Size;
|
||||
public int Flags;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
public int Handle;
|
||||
public int Id;
|
||||
#pragma warning restore CS0649
|
||||
public int Size;
|
||||
public uint Size;
|
||||
public int Align;
|
||||
public int Kind;
|
||||
public ulong Address;
|
||||
|
@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
_dupes = 1;
|
||||
}
|
||||
|
||||
public NvMapHandle(int size) : this()
|
||||
public NvMapHandle(uint size) : this()
|
||||
{
|
||||
Size = size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue