diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2021-10-07 13:43:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-07 13:43:31 +0100 |
| commit | 468774578dfd10342b35ebb66779c1521a91617c (patch) | |
| tree | 5bfdb076182bac84d4747dc8c2143b259a87476c /Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs | |
| parent | ecc64c934da43f881c2821bc9bc52ee42e55af2f (diff) | |
| parent | a4956591ec485e9b23ded32a853f2a63af92b769 (diff) | |
Merge pull request #2713 from riperiperi/fix/modified-inherit
Reregister flush actions when taking a buffer's modified range list.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs index 84cf0dd8..b9b533fb 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs @@ -318,6 +318,40 @@ namespace Ryujinx.Graphics.Gpu.Memory } } + /// <summary> + /// Calls the given action for modified ranges that aren't from the current sync number. + /// </summary> + /// <param name="rangeAction">The action to call for each modified range</param> + public void ReregisterRanges(Action<ulong, ulong> rangeAction) + { + ref var ranges = ref ThreadStaticArray<BufferModifiedRange>.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); + } + } + } + private void ClearPart(BufferModifiedRange overlap, ulong address, ulong endAddress) { Remove(overlap); |
