Initialize GPU physical memory accessor from KProcess, to allow homebrew that never maps anything on the GPU to work

This commit is contained in:
gdkchan 2019-12-25 20:28:17 -03:00 committed by Thog
parent 6cf9a04d98
commit 647d0962df
7 changed files with 40 additions and 61 deletions

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu
{
public IRenderer Renderer { get; }
internal IPhysicalMemory PhysicalMemory { get; private set; }
internal PhysicalMemory PhysicalMemory { get; private set; }
public MemoryManager MemoryManager { get; }
@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Gpu
internal int SequenceNumber { get; private set; }
private Lazy<Capabilities> _caps;
private readonly Lazy<Capabilities> _caps;
internal Capabilities Capabilities => _caps.Value;
@ -53,9 +53,9 @@ namespace Ryujinx.Graphics.Gpu
SequenceNumber++;
}
public void SetVmm(IPhysicalMemory mm)
public void SetVmm(ARMeilleure.Memory.MemoryManager cpuMemory)
{
PhysicalMemory = mm;
PhysicalMemory = new PhysicalMemory(cpuMemory);
}
}
}

View file

@ -212,14 +212,6 @@ namespace Ryujinx.Graphics.Gpu.Image
return;
}
ulong pageSize = (uint)_context.PhysicalMemory.GetPageSize();
ulong pageMask = pageSize - 1;
ulong rangeAddress = Address & ~pageMask;
ulong rangeSize = (EndAddress - Address + pageMask) & ~pageMask;
Span<byte> data = _context.PhysicalMemory.Read(Address, Size);
if (_info.IsLinear)

View file

@ -1,15 +0,0 @@
using System;
namespace Ryujinx.Graphics.Gpu.Memory
{
public interface IPhysicalMemory
{
int GetPageSize();
Span<byte> Read(ulong address, ulong size);
void Write(ulong address, Span<byte> data);
(ulong, ulong)[] GetModifiedRanges(ulong address, ulong size, ResourceName name);
}
}

View file

@ -0,0 +1,31 @@
using System;
namespace Ryujinx.Graphics.Gpu.Memory
{
using CpuMemoryManager = ARMeilleure.Memory.MemoryManager;
class PhysicalMemory
{
private readonly CpuMemoryManager _cpuMemory;
public PhysicalMemory(CpuMemoryManager cpuMemory)
{
_cpuMemory = cpuMemory;
}
public Span<byte> Read(ulong address, ulong size)
{
return _cpuMemory.ReadBytes((long)address, (long)size);
}
public void Write(ulong address, Span<byte> data)
{
_cpuMemory.WriteBytes((long)address, data.ToArray());
}
public (ulong, ulong)[] GetModifiedRanges(ulong address, ulong size, ResourceName name)
{
return _cpuMemory.GetModifiedRanges(address, size, (int)name);
}
}
}

View file

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.GAL\Ryujinx.Graphics.GAL.csproj" />
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.Texture\Ryujinx.Graphics.Texture.csproj" />