From 82cefc8dd3babb781d4b7229435e26911fb083dd Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 29 Aug 2021 16:52:38 -0300 Subject: Handle indirect draw counts with non-zero draw starts properly (#2593) --- Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs') 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 /// /// Type of the data /// GPU virtual address where the data is located + /// True if read tracking is triggered on the memory region /// The data at the specified memory location - public T Read(ulong va) where T : unmanaged + public T Read(ulong va, bool tracked = false) where T : unmanaged { - return MemoryMarshal.Cast(GetSpan(va, Unsafe.SizeOf()))[0]; + int size = Unsafe.SizeOf(); + + if (IsContiguous(va, size)) + { + ulong address = Translate(va); + + if (tracked) + { + return Physical.ReadTracked(address); + } + else + { + return Physical.Read(address); + } + } + else + { + Span data = new byte[size]; + + ReadImpl(va, data, tracked); + + return MemoryMarshal.Cast(data)[0]; + } } /// -- cgit v1.2.3