diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
index faaccf13cf..b9b533fb73 100644
--- a/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
@@ -324,9 +324,27 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// The action to call for each modified range
public void ReregisterRanges(Action rangeAction)
{
- ulong currentSync = _context.SyncNumber;
- foreach (BufferModifiedRange range in this)
+ ref var ranges = ref ThreadStaticArray.Get();
+
+ // Range list must be consistent for this operation.
+ lock (_lock)
{
+ if (ranges.Length < Count)
+ {
+ Array.Resize(ref ranges, Count);
+ }
+
+ int i = 0;
+ foreach (BufferModifiedRange range in this)
+ {
+ ranges[i++] = range;
+ }
+ }
+
+ ulong currentSync = _context.SyncNumber;
+ for (int i = 0; i < Count; i++)
+ {
+ BufferModifiedRange range = ranges[i];
if (range.SyncNumber != currentSync)
{
rangeAction(range.Address, range.Size);