aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs b/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs
new file mode 100644
index 00000000..bc07bfad
--- /dev/null
+++ b/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs
@@ -0,0 +1,102 @@
+using Ryujinx.Cpu.Tracking;
+using Ryujinx.Memory.Tracking;
+using System;
+
+namespace Ryujinx.Graphics.Gpu.Memory
+{
+ /// <summary>
+ /// A tracking handle for a region of GPU VA, represented by one or more tracking handles in CPU VA.
+ /// </summary>
+ class GpuRegionHandle : IRegionHandle
+ {
+ private readonly CpuRegionHandle[] _cpuRegionHandles;
+
+ public bool Dirty
+ {
+ get
+ {
+ foreach (var regionHandle in _cpuRegionHandles)
+ {
+ if (regionHandle.Dirty)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ public ulong Address => throw new NotSupportedException();
+ public ulong Size => throw new NotSupportedException();
+ public ulong EndAddress => throw new NotSupportedException();
+
+ /// <summary>
+ /// Create a new GpuRegionHandle, made up of mulitple CpuRegionHandles.
+ /// </summary>
+ /// <param name="cpuRegionHandles">The CpuRegionHandles that make up this handle</param>
+ public GpuRegionHandle(CpuRegionHandle[] cpuRegionHandles)
+ {
+ _cpuRegionHandles = cpuRegionHandles;
+ }
+
+ /// <summary>
+ /// Dispose the child handles.
+ /// </summary>
+ public void Dispose()
+ {
+ foreach (var regionHandle in _cpuRegionHandles)
+ {
+ regionHandle.Dispose();
+ }
+ }
+
+ /// <summary>
+ /// Register an action to perform when the tracked region is read or written.
+ /// The action is automatically removed after it runs.
+ /// </summary>
+ /// <param name="action">Action to call on read or write</param>
+ public void RegisterAction(RegionSignal action)
+ {
+ foreach (var regionHandle in _cpuRegionHandles)
+ {
+ regionHandle.RegisterAction(action);
+ }
+ }
+
+ /// <summary>
+ /// Register an action to perform when a precise access occurs (one with exact address and size).
+ /// If the action returns true, read/write tracking are skipped.
+ /// </summary>
+ /// <param name="action">Action to call on read or write</param>
+ public void RegisterPreciseAction(PreciseRegionSignal action)
+ {
+ foreach (var regionHandle in _cpuRegionHandles)
+ {
+ regionHandle.RegisterPreciseAction(action);
+ }
+ }
+
+ /// <summary>
+ /// Consume the dirty flag for the handles, and reprotect so it can be set on the next write.
+ /// </summary>
+ public void Reprotect(bool asDirty = false)
+ {
+ foreach (var regionHandle in _cpuRegionHandles)
+ {
+ regionHandle.Reprotect(asDirty);
+ }
+ }
+
+ /// <summary>
+ /// Force the handles to be dirty, without reprotecting.
+ /// </summary>
+ public void ForceDirty()
+ {
+ foreach (var regionHandle in _cpuRegionHandles)
+ {
+ regionHandle.ForceDirty();
+ }
+ }
+ }
+}