From 0dbfe3c23ee072ec9dbc477f955a163107af2be1 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 31 Dec 2019 21:08:02 -0300 Subject: Re-add NVDEC project (not integrated) --- Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs | 37 ++++++++++++++++++++++++++- Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Memory') 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 /// /// GPU mapped memory accessor. /// - class MemoryAccessor + public class MemoryAccessor { private GpuContext _context; @@ -19,6 +19,17 @@ namespace Ryujinx.Graphics.Gpu.Memory _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, ulong size) + { + return Read(gpuVa, size).ToArray(); + } + /// /// Reads data from GPU mapped memory. /// This reads as much data as possible, up to the specified maximum size. @@ -62,6 +73,30 @@ namespace Ryujinx.Graphics.Gpu.Memory return BitConverter.ToInt32(_context.PhysicalMemory.Read(processVa, 4)); } + /// + /// Reads a 64-bits unsigned integer from GPU mapped memory. + /// + /// GPU virtual address where the value is located + /// The value at the specified memory location + public ulong ReadUInt64(ulong gpuVa) + { + ulong processVa = _context.MemoryManager.Translate(gpuVa); + + return BitConverter.ToUInt64(_context.PhysicalMemory.Read(processVa, 8)); + } + + /// + /// Reads a 8-bits unsigned integer from GPU mapped memory. + /// + /// GPU virtual address where the value is located + /// The value to be written + public void WriteByte(ulong gpuVa, byte value) + { + ulong processVa = _context.MemoryManager.Translate(gpuVa); + + _context.PhysicalMemory.Write(processVa, MemoryMarshal.CreateSpan(ref value, 1)); + } + /// /// Writes a 32-bits signed integer to GPU mapped memory. /// diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs index 62ab0e47..33be04d3 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -252,7 +252,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// /// GPU virtual address to be translated /// CPU virtual address - internal ulong Translate(ulong gpuVa) + public ulong Translate(ulong gpuVa) { ulong baseAddress = GetPte(gpuVa); -- cgit v1.2.3