aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2019-12-25 20:28:17 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit647d0962df5b54334af965b88f784409afbf6223 (patch)
tree3cd884099188341f869919c8235deecdea96be9b
parent6cf9a04d981a9e966cccb0dc90182e29aac7e270 (diff)
Initialize GPU physical memory accessor from KProcess, to allow homebrew that never maps anything on the GPU to work
-rw-r--r--Ryujinx.Graphics.Gpu/GpuContext.cs8
-rw-r--r--Ryujinx.Graphics.Gpu/Image/Texture.cs8
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/IPhysicalMemory.cs15
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs31
-rw-r--r--Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj1
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs4
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs34
7 files changed, 40 insertions, 61 deletions
diff --git a/Ryujinx.Graphics.Gpu/GpuContext.cs b/Ryujinx.Graphics.Gpu/GpuContext.cs
index 0906d10e..bb172c9e 100644
--- a/Ryujinx.Graphics.Gpu/GpuContext.cs
+++ b/Ryujinx.Graphics.Gpu/GpuContext.cs
@@ -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);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs
index e72b619c..11855592 100644
--- a/Ryujinx.Graphics.Gpu/Image/Texture.cs
+++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs
@@ -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)
diff --git a/Ryujinx.Graphics.Gpu/Memory/IPhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/IPhysicalMemory.cs
deleted file mode 100644
index 73b3a9e1..00000000
--- a/Ryujinx.Graphics.Gpu/Memory/IPhysicalMemory.cs
+++ /dev/null
@@ -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);
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
new file mode 100644
index 00000000..8f585b0f
--- /dev/null
+++ b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -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);
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj b/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj
index 88761ddf..76c12690 100644
--- a/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj
+++ b/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj
@@ -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" />
diff --git a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
index c74f6fca..f987c83c 100644
--- a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
@@ -1115,6 +1115,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
Translator = new Translator(CpuMemory);
+ // TODO: This should eventually be removed.
+ // The GPU shouldn't depend on the CPU memory manager at all.
+ _system.Device.Gpu.SetVmm(CpuMemory);
+
MemoryManager = new KMemoryManager(_system, CpuMemory);
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs
index bca9ba7c..951994ef 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs
@@ -40,44 +40,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
public MemoryManager Gmm { get; }
- private class MemoryProxy : IPhysicalMemory
- {
- private ARMeilleure.Memory.MemoryManager _cpuMemory;
-
- public MemoryProxy(ARMeilleure.Memory.MemoryManager 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);
- }
-
- public int GetPageSize()
- {
- return 4096;
- }
- }
-
public AddressSpaceContext(ServiceCtx context)
{
Gmm = context.Device.Gpu.MemoryManager;
- var memoryProxy = new MemoryProxy(context.Process.CpuMemory);
-
- context.Device.Gpu.SetVmm(memoryProxy);
-
_maps = new SortedList<long, Range>();
_reservations = new SortedList<long, Range>();
}