From a0e6647860b689cd2c3d865e6b235b12ec96b89a Mon Sep 17 00:00:00 2001 From: riperiperi Date: Mon, 3 Feb 2020 19:11:22 +0000 Subject: Compare shader code using a span instead of individual reads. (#917) * Compare shader code using a span instead of individual reads. * Add comment for new parameter. * Remove unnecessary Math.Min --- Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs | 2 +- Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 7 ++++++- 2 files changed, 7 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 17c00062..fbe2cbc4 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryAccessor.cs @@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { ulong processVa = _context.MemoryManager.Translate(gpuVa); - ulong size = Math.Min(_context.MemoryManager.GetSubSize(gpuVa), maxSize); + ulong size = _context.MemoryManager.GetSubSize(gpuVa, maxSize); return _context.PhysicalMemory.GetSpan(processVa, size); } diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs index ffca6f33..e89255c8 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -237,14 +237,19 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Gets the number of mapped or reserved pages on a given region. /// /// Start GPU virtual address of the region + /// Maximum size of the data /// Mapped size in bytes of the specified region - internal ulong GetSubSize(ulong gpuVa) + internal ulong GetSubSize(ulong gpuVa, ulong maxSize) { ulong size = 0; while (GetPte(gpuVa + size) != PteUnmapped) { size += PageSize; + if (size >= maxSize) + { + return maxSize; + } } return size; -- cgit v1.2.3