aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2019-12-31 21:08:02 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit0dbfe3c23ee072ec9dbc477f955a163107af2be1 (patch)
treef7f3501ef32891e80197717ab18b22a8d88fdb9f /Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs
parent6e092c05584ccbbd548ac26c056c1a7edfa6c1a0 (diff)
Re-add NVDEC project (not integrated)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs37
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>