From 5795bb15282498b3824a5d15fe1ff78b85a18c23 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 27 May 2020 11:07:10 -0300 Subject: Support separate textures and samplers (#1216) * Support separate textures and samplers * Add missing bindless flag, fix SNORM format on buffer textures * Add missing separation * Add comments about the new handles --- Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs | 12 ++++++------ Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Memory') diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs index cfc6f7f5..38f448d9 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs @@ -46,11 +46,11 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// - /// Reads a structure from GPU mapped memory. + /// Reads data from GPU mapped memory. /// - /// Type of the structure - /// GPU virtual address where the structure is located - /// The structure at the specified memory location + /// 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); @@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { ulong processVa = _context.MemoryManager.Translate(gpuVa); - return BitConverter.ToInt32(_context.PhysicalMemory.GetSpan(processVa, 4)); + return _context.PhysicalMemory.Read(processVa); } /// @@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { ulong processVa = _context.MemoryManager.Translate(gpuVa); - return BitConverter.ToUInt64(_context.PhysicalMemory.GetSpan(processVa, 8)); + return _context.PhysicalMemory.Read(processVa); } /// diff --git a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs index 5d9b5561..4a80aa1a 100644 --- a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs +++ b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Gpu.Memory { @@ -33,6 +34,17 @@ namespace Ryujinx.Graphics.Gpu.Memory return _cpuMemory.GetSpan(address, size); } + /// + /// Reads data from the application process. + /// + /// Type of the structure + /// Address to read from + /// The data at the specified memory location + public T Read(ulong address) where T : unmanaged + { + return MemoryMarshal.Cast(GetSpan(address, Unsafe.SizeOf()))[0]; + } + /// /// Writes data to the application process. /// -- cgit v1.2.3