From f565b0e5a6bebc09381aabb046e9b0b6285b7d10 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 23 Jan 2021 09:38:00 -0300 Subject: Match texture if the physical range is the same (#1934) * Match texture if the physical range is the same * XML docs and comments --- Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (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 7021cd20..5776836c 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -343,6 +343,39 @@ namespace Ryujinx.Graphics.Gpu.Memory return new MultiRange(regions.ToArray()); } + /// + /// Checks if a given GPU virtual memory range is mapped to the same physical regions + /// as the specified physical memory multi-range. + /// + /// Physical memory multi-range + /// GPU virtual memory address + /// True if the virtual memory region is mapped into the specified physical one, false otherwise + public bool CompareRange(MultiRange range, ulong va) + { + va &= ~PageMask; + + for (int i = 0; i < range.Count; i++) + { + MemoryRange currentRange = range.GetSubRange(i); + + ulong address = currentRange.Address & ~PageMask; + ulong endAddress = (currentRange.EndAddress + PageMask) & ~PageMask; + + while (address < endAddress) + { + if (Translate(va) != address) + { + return false; + } + + va += PageSize; + address += PageSize; + } + } + + return true; + } + /// /// Validates a GPU virtual address. /// -- cgit v1.2.3