diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs index a0247acf..3cbbd253 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// <summary> /// GPU mapped memory accessor. /// </summary> - class MemoryAccessor + public class MemoryAccessor { private GpuContext _context; @@ -20,6 +20,17 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// <summary> + /// Reads a byte array from GPU mapped memory. + /// </summary> + /// <param name="gpuVa">GPU virtual address where the data is located</param> + /// <param name="size">Size of the data in bytes</param> + /// <returns>Byte array with the data</returns> + public byte[] ReadBytes(ulong gpuVa, ulong size) + { + return Read(gpuVa, size).ToArray(); + } + + /// <summary> /// Reads data from GPU mapped memory. /// This reads as much data as possible, up to the specified maximum size. /// </summary> @@ -63,6 +74,30 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// <summary> + /// Reads a 64-bits unsigned integer from GPU mapped memory. + /// </summary> + /// <param name="gpuVa">GPU virtual address where the value is located</param> + /// <returns>The value at the specified memory location</returns> + public ulong ReadUInt64(ulong gpuVa) + { + ulong processVa = _context.MemoryManager.Translate(gpuVa); + + return BitConverter.ToUInt64(_context.PhysicalMemory.Read(processVa, 8)); + } + + /// <summary> + /// Reads a 8-bits unsigned integer from GPU mapped memory. + /// </summary> + /// <param name="gpuVa">GPU virtual address where the value is located</param> + /// <param name="value">The value to be written</param> + public void WriteByte(ulong gpuVa, byte value) + { + ulong processVa = _context.MemoryManager.Translate(gpuVa); + + _context.PhysicalMemory.Write(processVa, MemoryMarshal.CreateSpan(ref value, 1)); + } + + /// <summary> /// Writes a 32-bits signed integer to GPU mapped memory. /// </summary> /// <param name="gpuVa">GPU virtual address to write the value into</param> |
