diff options
author | gdkchan <gab.dark.100@gmail.com> | 2024-08-05 11:00:41 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-05 11:00:41 -0300 |
commit | 4a4b11871e362016b41c56d4dd4654ade0b894e0 (patch) | |
tree | c8cafe8f577411b371550c06d2ea03625586fd35 | |
parent | e85ee673b10da5a314e68cea88caeacd2918f311 (diff) |
Fix same textures with unmapped start being considered different (#7141)1.1.1371
* 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>
-rw-r--r-- | src/Ryujinx.Memory/Range/IMultiRangeItem.cs | 18 | ||||
-rw-r--r-- | src/Ryujinx.Memory/Range/MemoryRange.cs | 18 | ||||
-rw-r--r-- | src/Ryujinx.Memory/Range/MultiRangeList.cs | 17 |
3 files changed, 37 insertions, 16 deletions
diff --git a/src/Ryujinx.Memory/Range/IMultiRangeItem.cs b/src/Ryujinx.Memory/Range/IMultiRangeItem.cs index 87fde2465..5f9611c75 100644 --- a/src/Ryujinx.Memory/Range/IMultiRangeItem.cs +++ b/src/Ryujinx.Memory/Range/IMultiRangeItem.cs | |||
@@ -4,6 +4,22 @@ namespace Ryujinx.Memory.Range | |||
4 | { | 4 | { |
5 | MultiRange Range { get; } | 5 | MultiRange Range { get; } |
6 | 6 | ||
7 | ulong BaseAddress => Range.GetSubRange(0).Address; | 7 | ulong BaseAddress |
8 | { | ||
9 | get | ||
10 | { | ||
11 | for (int index = 0; index < Range.Count; index++) | ||
12 | { | ||
13 | MemoryRange subRange = Range.GetSubRange(index); | ||
14 | |||
15 | if (!MemoryRange.IsInvalid(ref subRange)) | ||
16 | { | ||
17 | return subRange.Address; | ||
18 | } | ||
19 | } | ||
20 | |||
21 | return MemoryRange.InvalidAddress; | ||
22 | } | ||
23 | } | ||
8 | } | 24 | } |
9 | } | 25 | } |
diff --git a/src/Ryujinx.Memory/Range/MemoryRange.cs b/src/Ryujinx.Memory/Range/MemoryRange.cs index 46aca9ba0..20e9d00bb 100644 --- a/src/Ryujinx.Memory/Range/MemoryRange.cs +++ b/src/Ryujinx.Memory/Range/MemoryRange.cs | |||
@@ -6,6 +6,11 @@ namespace Ryujinx.Memory.Range | |||
6 | public readonly record struct MemoryRange | 6 | public readonly record struct MemoryRange |
7 | { | 7 | { |
8 | /// <summary> | 8 | /// <summary> |
9 | /// Special address value used to indicate than an address is invalid. | ||
10 | /// </summary> | ||
11 | internal const ulong InvalidAddress = ulong.MaxValue; | ||
12 | |||
13 | /// <summary> | ||
9 | /// An empty memory range, with a null address and zero size. | 14 | /// An empty memory range, with a null address and zero size. |
10 | /// </summary> | 15 | /// </summary> |
11 | public static MemoryRange Empty => new(0UL, 0); | 16 | public static MemoryRange Empty => new(0UL, 0); |
@@ -59,12 +64,23 @@ namespace Ryujinx.Memory.Range | |||
59 | } | 64 | } |
60 | 65 | ||
61 | /// <summary> | 66 | /// <summary> |
67 | /// Checks if a given sub-range of memory is invalid. | ||
68 | /// Those are used to represent unmapped memory regions (holes in the region mapping). | ||
69 | /// </summary> | ||
70 | /// <param name="subRange">Memory range to check</param> | ||
71 | /// <returns>True if the memory range is considered invalid, false otherwise</returns> | ||
72 | internal static bool IsInvalid(ref MemoryRange subRange) | ||
73 | { | ||
74 | return subRange.Address == InvalidAddress; | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
62 | /// Returns a string summary of the memory range. | 78 | /// Returns a string summary of the memory range. |
63 | /// </summary> | 79 | /// </summary> |
64 | /// <returns>A string summary of the memory range</returns> | 80 | /// <returns>A string summary of the memory range</returns> |
65 | public override string ToString() | 81 | public override string ToString() |
66 | { | 82 | { |
67 | if (Address == ulong.MaxValue) | 83 | if (Address == InvalidAddress) |
68 | { | 84 | { |
69 | return $"[Unmapped 0x{Size:X}]"; | 85 | return $"[Unmapped 0x{Size:X}]"; |
70 | } | 86 | } |
diff --git a/src/Ryujinx.Memory/Range/MultiRangeList.cs b/src/Ryujinx.Memory/Range/MultiRangeList.cs index 1804ff5c8..c3c6ae797 100644 --- a/src/Ryujinx.Memory/Range/MultiRangeList.cs +++ b/src/Ryujinx.Memory/Range/MultiRangeList.cs | |||
@@ -30,7 +30,7 @@ namespace Ryujinx.Memory.Range | |||
30 | { | 30 | { |
31 | var subrange = range.GetSubRange(i); | 31 | var subrange = range.GetSubRange(i); |
32 | 32 | ||
33 | if (IsInvalid(ref subrange)) | 33 | if (MemoryRange.IsInvalid(ref subrange)) |
34 | { | 34 | { |
35 | continue; | 35 | continue; |
36 | } | 36 | } |
@@ -56,7 +56,7 @@ namespace Ryujinx.Memory.Range | |||
56 | { | 56 | { |
57 | var subrange = range.GetSubRange(i); | 57 | var subrange = range.GetSubRange(i); |
58 | 58 | ||
59 | if (IsInvalid(ref subrange)) | 59 | if (MemoryRange.IsInvalid(ref subrange)) |
60 | { | 60 | { |
61 | continue; | 61 | continue; |
62 | } | 62 | } |
@@ -99,7 +99,7 @@ namespace Ryujinx.Memory.Range | |||
99 | { | 99 | { |
100 | var subrange = range.GetSubRange(i); | 100 | var subrange = range.GetSubRange(i); |
101 | 101 | ||
102 | if (IsInvalid(ref subrange)) | 102 | if (MemoryRange.IsInvalid(ref subrange)) |
103 | { | 103 | { |
104 | continue; | 104 | continue; |
105 | } | 105 | } |
@@ -143,17 +143,6 @@ namespace Ryujinx.Memory.Range | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /// <summary> | 145 | /// <summary> |
146 | /// Checks if a given sub-range of memory is invalid. | ||
147 | /// Those are used to represent unmapped memory regions (holes in the region mapping). | ||
148 | /// </summary> | ||
149 | /// <param name="subRange">Memory range to checl</param> | ||
150 | /// <returns>True if the memory range is considered invalid, false otherwise</returns> | ||
151 | private static bool IsInvalid(ref MemoryRange subRange) | ||
152 | { | ||
153 | return subRange.Address == ulong.MaxValue; | ||
154 | } | ||
155 | |||
156 | /// <summary> | ||
157 | /// Gets all items on the list starting at the specified memory address. | 146 | /// Gets all items on the list starting at the specified memory address. |
158 | /// </summary> | 147 | /// </summary> |
159 | /// <param name="baseAddress">Base address to find</param> | 148 | /// <param name="baseAddress">Base address to find</param> |