diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
index 83869ed02..21d0d9467 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
@@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Memory.Range;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Ryujinx.Graphics.Gpu.Memory
@@ -595,6 +596,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
while (oldOverlapCount != overlaps.Length);
+ Debug.Assert(endAddress == overlaps[^1].EndAddress);
+
ulong newSize = endAddress - address;
Buffer[] overlapsArray = overlaps.ToArray();
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
index 03f676af9..0cb3f982b 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
@@ -1,6 +1,8 @@
+using Ryujinx.Common.Logging;
using Ryujinx.Memory.Range;
using System;
using System.Buffers;
+using System.Diagnostics;
using System.Linq;
namespace Ryujinx.Graphics.Gpu.Memory
@@ -157,6 +159,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
public void SignalModified(ulong address, ulong size)
{
ulong endAddress = address + size;
+
+ Debug.Assert(endAddress <= _parent.EndAddress);
+
ulong syncNumber = _context.SyncNumber;
// We may overlap with some existing modified regions. They must be cut into by the new entry.
Lock.EnterWriteLock();
@@ -169,6 +174,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
return;
}
+ Logger.Warning?.Print(LogClass.Gpu, "Signal Modified");
if (first == last)
{
if (first.Address == address && first.EndAddress == endAddress)
@@ -460,9 +466,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// The action to call for each modified range
public void InheritRanges(BufferModifiedRangeList ranges, Action registerRangeAction)
{
+ Logger.Warning?.Print(LogClass.Gpu, "Inherit Ranges");
ranges.Lock.EnterReadLock();
- BufferModifiedRange[] inheritRanges = ranges.ToArray();
+ BufferModifiedRange[] inheritRanges = new BufferModifiedRange[ranges.Count];
+ ranges.Items.AsSpan(0, ranges.Count).CopyTo(inheritRanges);
ranges.Lock.ExitReadLock();
+
+ Debug.Assert(_parent.Address <= ranges._parent.Address && _parent.EndAddress >= ranges._parent.EndAddress);
// Copy over the migration from the previous range list
@@ -490,6 +500,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
foreach (BufferModifiedRange range in inheritRanges)
{
+ Debug.Assert(range.EndAddress <= _parent.EndAddress);
Add(range);
}
@@ -545,6 +556,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
// If the overlap extends outside of the clear range, make sure those parts still exist.
+ Logger.Warning?.Print(LogClass.Gpu, "Clear Part");
if (overlap.Address < address)
{
if (overlap.EndAddress > endAddress)
@@ -572,6 +584,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// Size to clear
public void Clear(ulong address, ulong size)
{
+ Logger.Warning?.Print(LogClass.Gpu, "Clear");
ulong endAddress = address + size;
Lock.EnterWriteLock();
(BufferModifiedRange first, BufferModifiedRange last) = FindOverlapsAsNodes(address, size);