This commit is contained in:
LotP1 2025-11-21 16:26:37 +01:00
parent be1a05dead
commit 01f43cafea
2 changed files with 17 additions and 1 deletions

View File

@ -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();

View File

@ -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,10 +466,14 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="registerRangeAction">The action to call for each modified range</param>
public void InheritRanges(BufferModifiedRangeList ranges, Action<ulong, ulong> 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
BufferMigration oldMigration = ranges._source;
@ -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
/// <param name="size">Size to clear</param>
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);