mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-24 10:36:03 +00:00
Avoid potential race
This commit is contained in:
parent
c61c1ea898
commit
a4956591ec
1 changed files with 20 additions and 2 deletions
|
@ -324,9 +324,27 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// <param name="rangeAction">The action to call for each modified range</param>
|
/// <param name="rangeAction">The action to call for each modified range</param>
|
||||||
public void ReregisterRanges(Action<ulong, ulong> rangeAction)
|
public void ReregisterRanges(Action<ulong, ulong> rangeAction)
|
||||||
{
|
{
|
||||||
ulong currentSync = _context.SyncNumber;
|
ref var ranges = ref ThreadStaticArray<BufferModifiedRange>.Get();
|
||||||
foreach (BufferModifiedRange range in this)
|
|
||||||
|
// 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)
|
if (range.SyncNumber != currentSync)
|
||||||
{
|
{
|
||||||
rangeAction(range.Address, range.Size);
|
rangeAction(range.Address, range.Size);
|
||||||
|
|
Loading…
Reference in a new issue