diff options
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Memory')
| -rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 26 | ||||
| -rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/UnmapEventArgs.cs | 12 |
2 files changed, 35 insertions, 3 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs index b0f7e799..0d4a41f0 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -366,6 +366,22 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// <summary> + /// Runs remap actions that are added to an unmap event. + /// These must run after the mapping completes. + /// </summary> + /// <param name="e">Event with remap actions</param> + private void RunRemapActions(UnmapEventArgs e) + { + if (e.RemapActions != null) + { + foreach (Action action in e.RemapActions) + { + action(); + } + } + } + + /// <summary> /// Maps a given range of pages to the specified CPU virtual address. /// </summary> /// <remarks> @@ -379,12 +395,15 @@ namespace Ryujinx.Graphics.Gpu.Memory { lock (_pageTable) { - MemoryUnmapped?.Invoke(this, new UnmapEventArgs(va, size)); + UnmapEventArgs e = new(va, size); + MemoryUnmapped?.Invoke(this, e); for (ulong offset = 0; offset < size; offset += PageSize) { SetPte(va + offset, PackPte(pa + offset, kind)); } + + RunRemapActions(e); } } @@ -398,12 +417,15 @@ namespace Ryujinx.Graphics.Gpu.Memory lock (_pageTable) { // Event handlers are not expected to be thread safe. - MemoryUnmapped?.Invoke(this, new UnmapEventArgs(va, size)); + UnmapEventArgs e = new(va, size); + MemoryUnmapped?.Invoke(this, e); for (ulong offset = 0; offset < size; offset += PageSize) { SetPte(va + offset, PteUnmapped); } + + RunRemapActions(e); } } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/UnmapEventArgs.cs b/src/Ryujinx.Graphics.Gpu/Memory/UnmapEventArgs.cs index 305747f8..837b5aab 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/UnmapEventArgs.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/UnmapEventArgs.cs @@ -1,14 +1,24 @@ -namespace Ryujinx.Graphics.Gpu.Memory +using System; +using System.Collections.Generic; + +namespace Ryujinx.Graphics.Gpu.Memory { public class UnmapEventArgs { public ulong Address { get; } public ulong Size { get; } + public List<Action> RemapActions { get; private set; } public UnmapEventArgs(ulong address, ulong size) { Address = address; Size = size; } + + public void AddRemapAction(Action action) + { + RemapActions ??= new List<Action>(); + RemapActions.Add(action); + } } } |
