Match texture if the physical range is the same (#1934)

* Match texture if the physical range is the same

* XML docs and comments
This commit is contained in:
gdkchan 2021-01-23 09:38:00 -03:00 committed by GitHub
parent 6982282cc8
commit f565b0e5a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 6 deletions

View file

@ -343,6 +343,39 @@ namespace Ryujinx.Graphics.Gpu.Memory
return new MultiRange(regions.ToArray());
}
/// <summary>
/// Checks if a given GPU virtual memory range is mapped to the same physical regions
/// as the specified physical memory multi-range.
/// </summary>
/// <param name="range">Physical memory multi-range</param>
/// <param name="va">GPU virtual memory address</param>
/// <returns>True if the virtual memory region is mapped into the specified physical one, false otherwise</returns>
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;
}
/// <summary>
/// Validates a GPU virtual address.
/// </summary>