mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 01:25:25 +00:00
Avoid potential race
This commit is contained in:
parent
c61c1ea898
commit
a4956591ec
|
@ -324,9 +324,27 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
/// <param name="rangeAction">The action to call for each modified range</param>
|
||||
public void ReregisterRanges(Action<ulong, ulong> rangeAction)
|
||||
{
|
||||
ulong currentSync = _context.SyncNumber;
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue