0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-22 23:45:46 +00:00

Fix same textures with unmapped start being considered different (#7141)

* Fix same textures with unmapped start being considered different

* Consolidate IsInvalid check

* InvalidAddress const

* Fix typo

Co-authored-by: riperiperi <rhy3756547@hotmail.com>

---------

Co-authored-by: riperiperi <rhy3756547@hotmail.com>
This commit is contained in:
gdkchan 2024-08-05 11:00:41 -03:00 committed by GitHub
parent e85ee673b1
commit 4a4b11871e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 16 deletions

View file

@ -4,6 +4,22 @@ namespace Ryujinx.Memory.Range
{
MultiRange Range { get; }
ulong BaseAddress => Range.GetSubRange(0).Address;
ulong BaseAddress
{
get
{
for (int index = 0; index < Range.Count; index++)
{
MemoryRange subRange = Range.GetSubRange(index);
if (!MemoryRange.IsInvalid(ref subRange))
{
return subRange.Address;
}
}
return MemoryRange.InvalidAddress;
}
}
}
}

View file

@ -5,6 +5,11 @@ namespace Ryujinx.Memory.Range
/// </summary>
public readonly record struct MemoryRange
{
/// <summary>
/// Special address value used to indicate than an address is invalid.
/// </summary>
internal const ulong InvalidAddress = ulong.MaxValue;
/// <summary>
/// An empty memory range, with a null address and zero size.
/// </summary>
@ -58,13 +63,24 @@ namespace Ryujinx.Memory.Range
return thisAddress < otherEndAddress && otherAddress < thisEndAddress;
}
/// <summary>
/// Checks if a given sub-range of memory is invalid.
/// Those are used to represent unmapped memory regions (holes in the region mapping).
/// </summary>
/// <param name="subRange">Memory range to check</param>
/// <returns>True if the memory range is considered invalid, false otherwise</returns>
internal static bool IsInvalid(ref MemoryRange subRange)
{
return subRange.Address == InvalidAddress;
}
/// <summary>
/// Returns a string summary of the memory range.
/// </summary>
/// <returns>A string summary of the memory range</returns>
public override string ToString()
{
if (Address == ulong.MaxValue)
if (Address == InvalidAddress)
{
return $"[Unmapped 0x{Size:X}]";
}

View file

@ -30,7 +30,7 @@ namespace Ryujinx.Memory.Range
{
var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange))
if (MemoryRange.IsInvalid(ref subrange))
{
continue;
}
@ -56,7 +56,7 @@ namespace Ryujinx.Memory.Range
{
var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange))
if (MemoryRange.IsInvalid(ref subrange))
{
continue;
}
@ -99,7 +99,7 @@ namespace Ryujinx.Memory.Range
{
var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange))
if (MemoryRange.IsInvalid(ref subrange))
{
continue;
}
@ -142,17 +142,6 @@ namespace Ryujinx.Memory.Range
return overlapCount;
}
/// <summary>
/// Checks if a given sub-range of memory is invalid.
/// Those are used to represent unmapped memory regions (holes in the region mapping).
/// </summary>
/// <param name="subRange">Memory range to checl</param>
/// <returns>True if the memory range is considered invalid, false otherwise</returns>
private static bool IsInvalid(ref MemoryRange subRange)
{
return subRange.Address == ulong.MaxValue;
}
/// <summary>
/// Gets all items on the list starting at the specified memory address.
/// </summary>