From 111534a74e77664c2ab64c23e74d2173d6029b01 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 25 Jul 2020 03:39:45 -0300 Subject: Remove GPU MemoryAccessor (#1423) * Remove GPU MemoryAccessor * Update outdated XML doc * Update more outdated stuff --- Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs | 85 --------------------------- Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 14 ++++- 2 files changed, 13 insertions(+), 86 deletions(-) delete mode 100644 Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs (limited to 'Ryujinx.Graphics.Gpu/Memory') diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs deleted file mode 100644 index 2c53f699..00000000 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace Ryujinx.Graphics.Gpu.Memory -{ - /// - /// GPU mapped memory accessor. - /// - public class MemoryAccessor - { - private GpuContext _context; - - /// - /// Creates a new instance of the GPU memory accessor. - /// - /// GPU context that the memory accessor belongs to - public MemoryAccessor(GpuContext context) - { - _context = context; - } - - /// - /// Reads a byte array from GPU mapped memory. - /// - /// GPU virtual address where the data is located - /// Size of the data in bytes - /// Byte array with the data - public byte[] ReadBytes(ulong gpuVa, int size) - { - return GetSpan(gpuVa, size).ToArray(); - } - - /// - /// Gets a read-only span of data from GPU mapped memory. - /// This reads as much data as possible, up to the specified maximum size. - /// - /// GPU virtual address where the data is located - /// Size of the data - /// The span of the data at the specified memory location - public ReadOnlySpan GetSpan(ulong gpuVa, int size) - { - ulong processVa = _context.MemoryManager.Translate(gpuVa); - - return _context.PhysicalMemory.GetSpan(processVa, size); - } - - /// - /// Reads data from GPU mapped memory. - /// - /// Type of the data - /// GPU virtual address where the data is located - /// The data at the specified memory location - public T Read(ulong gpuVa) where T : unmanaged - { - ulong processVa = _context.MemoryManager.Translate(gpuVa); - - return MemoryMarshal.Cast(_context.PhysicalMemory.GetSpan(processVa, Unsafe.SizeOf()))[0]; - } - - /// - /// Writes a 32-bits signed integer to GPU mapped memory. - /// - /// GPU virtual address to write the value into - /// The value to be written - public void Write(ulong gpuVa, T value) where T : unmanaged - { - ulong processVa = _context.MemoryManager.Translate(gpuVa); - - _context.PhysicalMemory.Write(processVa, MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref value, 1))); - } - - /// - /// Writes data to GPU mapped memory. - /// - /// GPU virtual address to write the data into - /// The data to be written - public void Write(ulong gpuVa, ReadOnlySpan data) - { - ulong processVa = _context.MemoryManager.Translate(gpuVa); - - _context.PhysicalMemory.Write(processVa, data); - } - } -} \ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs index 2d988f8d..ace94442 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -62,7 +62,6 @@ namespace Ryujinx.Graphics.Gpu.Memory /// /// Gets a read-only span of data from GPU mapped memory. - /// This reads as much data as possible, up to the specified maximum size. /// /// GPU virtual address where the data is located /// Size of the data @@ -87,6 +86,19 @@ namespace Ryujinx.Graphics.Gpu.Memory return _context.PhysicalMemory.GetWritableRegion(processVa, size); } + /// + /// Writes data to GPU mapped memory. + /// + /// Type of the data + /// GPU virtual address to write the value into + /// The value to be written + public void Write(ulong gpuVa, T value) where T : unmanaged + { + ulong processVa = Translate(gpuVa); + + _context.PhysicalMemory.Write(processVa, MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref value, 1))); + } + /// /// Writes data to GPU mapped memory. /// -- cgit v1.2.3