aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Memory
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-01-22 17:14:46 -0300
committerGitHub <noreply@github.com>2024-01-22 17:14:46 -0300
commitf241f88558b3fe90d76fc21123bd06b9e4c3d2da (patch)
tree7135051e6a5dc2227d87724777cb63f76453db58 /src/Ryujinx.Graphics.Gpu/Memory
parent90455a05e6d7fe4305c997f20f76d2411197a182 (diff)
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
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Memory')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs43
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs10
2 files changed, 10 insertions, 43 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
index 5e19bddc..74d52705 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
@@ -330,49 +330,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
- /// Writes data to GPU mapped memory, stopping at the first unmapped page at the memory region, if any.
- /// </summary>
- /// <param name="va">GPU virtual address to write the data into</param>
- /// <param name="data">The data to be written</param>
- public void WriteMapped(ulong va, ReadOnlySpan<byte> data)
- {
- if (IsContiguous(va, data.Length))
- {
- Physical.Write(Translate(va), data);
- }
- else
- {
- int offset = 0, size;
-
- if ((va & PageMask) != 0)
- {
- ulong pa = Translate(va);
-
- size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
-
- if (pa != PteUnmapped && Physical.IsMapped(pa))
- {
- Physical.Write(pa, data[..size]);
- }
-
- offset += size;
- }
-
- for (; offset < data.Length; offset += size)
- {
- ulong pa = Translate(va + (ulong)offset);
-
- size = Math.Min(data.Length - offset, (int)PageSize);
-
- if (pa != PteUnmapped && Physical.IsMapped(pa))
- {
- Physical.Write(pa, data.Slice(offset, size));
- }
- }
- }
- }
-
- /// <summary>
/// Runs remap actions that are added to an unmap event.
/// These must run after the mapping completes.
/// </summary>
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
index 1ca6071b..69a3054a 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -1,4 +1,5 @@
using Ryujinx.Cpu;
+using Ryujinx.Graphics.Device;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Gpu.Shader;
using Ryujinx.Memory;
@@ -83,6 +84,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
+ /// Creates a new device memory manager.
+ /// </summary>
+ /// <returns>The memory manager</returns>
+ public DeviceMemoryManager CreateDeviceMemoryManager()
+ {
+ return new DeviceMemoryManager(_cpuMemory);
+ }
+
+ /// <summary>
/// Gets a host pointer for a given range of application memory.
/// If the memory region is not a single contiguous block, this method returns 0.
/// </summary>