diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2021-08-29 16:52:38 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-29 16:52:38 -0300 |
| commit | 82cefc8dd3babb781d4b7229435e26911fb083dd (patch) | |
| tree | 769fb8595890c414fd8721e345ef3f0764c80e25 /Ryujinx.Graphics.Gpu/Memory | |
| parent | 15e7fe3ac940a1768a25326e66683ad0f23127e0 (diff) | |
Handle indirect draw counts with non-zero draw starts properly (#2593)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 27 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs | 15 |
2 files changed, 38 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs index b747b558..2dc1edd2 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -63,10 +63,33 @@ namespace Ryujinx.Graphics.Gpu.Memory /// </summary> /// <typeparam name="T">Type of the data</typeparam> /// <param name="va">GPU virtual address where the data is located</param> + /// <param name="tracked">True if read tracking is triggered on the memory region</param> /// <returns>The data at the specified memory location</returns> - public T Read<T>(ulong va) where T : unmanaged + public T Read<T>(ulong va, bool tracked = false) where T : unmanaged { - return MemoryMarshal.Cast<byte, T>(GetSpan(va, Unsafe.SizeOf<T>()))[0]; + int size = Unsafe.SizeOf<T>(); + + if (IsContiguous(va, size)) + { + ulong address = Translate(va); + + if (tracked) + { + return Physical.ReadTracked<T>(address); + } + else + { + return Physical.Read<T>(address); + } + } + else + { + Span<byte> data = new byte[size]; + + ReadImpl(va, data, tracked); + + return MemoryMarshal.Cast<byte, T>(data)[0]; + } } /// <summary> diff --git a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs index 8df3c8fb..fd2a7476 100644 --- a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs +++ b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs @@ -139,11 +139,22 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Reads data from the application process. /// </summary> /// <typeparam name="T">Type of the structure</typeparam> - /// <param name="gpuVa">Address to read from</param> + /// <param name="address">Address to read from</param> /// <returns>The data at the specified memory location</returns> public T Read<T>(ulong address) where T : unmanaged { - return MemoryMarshal.Cast<byte, T>(GetSpan(address, Unsafe.SizeOf<T>()))[0]; + return _cpuMemory.Read<T>(address); + } + + /// <summary> + /// Reads data from the application process, with write tracking. + /// </summary> + /// <typeparam name="T">Type of the structure</typeparam> + /// <param name="address">Address to read from</param> + /// <returns>The data at the specified memory location</returns> + public T ReadTracked<T>(ulong address) where T : unmanaged + { + return _cpuMemory.ReadTracked<T>(address); } /// <summary> |
