mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-20 11:44:15 +00:00
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:
parent
6982282cc8
commit
f565b0e5a6
2 changed files with 53 additions and 6 deletions
|
@ -685,14 +685,28 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
Texture overlap = _textureOverlaps[index];
|
Texture overlap = _textureOverlaps[index];
|
||||||
|
|
||||||
bool rangeMatches = range != null ? overlap.Range.Equals(range.Value) : overlap.Info.GpuAddress == info.GpuAddress;
|
|
||||||
if (!rangeMatches)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureMatchQuality matchQuality = overlap.IsExactMatch(info, flags);
|
TextureMatchQuality matchQuality = overlap.IsExactMatch(info, flags);
|
||||||
|
|
||||||
|
if (matchQuality != TextureMatchQuality.NoMatch)
|
||||||
|
{
|
||||||
|
// If the parameters match, we need to make sure the texture is mapped to the same memory regions.
|
||||||
|
|
||||||
|
// If a range of memory was supplied, just check if the ranges match.
|
||||||
|
if (range != null && !overlap.Range.Equals(range.Value))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no range was supplied, we can check if the GPU virtual address match. If they do,
|
||||||
|
// we know the textures are located at the same memory region.
|
||||||
|
// If they don't, it may still be mapped to the same physical region, so we
|
||||||
|
// do a more expensive check to tell if they are mapped into the same physical regions.
|
||||||
|
if (overlap.Info.GpuAddress != info.GpuAddress && !_context.MemoryManager.CompareRange(overlap.Range, info.GpuAddress))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (matchQuality == TextureMatchQuality.Perfect)
|
if (matchQuality == TextureMatchQuality.Perfect)
|
||||||
{
|
{
|
||||||
texture = overlap;
|
texture = overlap;
|
||||||
|
|
|
@ -343,6 +343,39 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
return new MultiRange(regions.ToArray());
|
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>
|
/// <summary>
|
||||||
/// Validates a GPU virtual address.
|
/// Validates a GPU virtual address.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue