From cee712105850ac3385cd0091a923438167433f9f Mon Sep 17 00:00:00 2001
From: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
Date: Sat, 8 Apr 2023 01:22:00 +0200
Subject: Move solution and projects to src
---
.../Memory/MultiRangeWritableBlock.cs | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 src/Ryujinx.Graphics.Gpu/Memory/MultiRangeWritableBlock.cs
(limited to 'src/Ryujinx.Graphics.Gpu/Memory/MultiRangeWritableBlock.cs')
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeWritableBlock.cs b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeWritableBlock.cs
new file mode 100644
index 00000000..155dda7b
--- /dev/null
+++ b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeWritableBlock.cs
@@ -0,0 +1,58 @@
+using Ryujinx.Memory;
+using Ryujinx.Memory.Range;
+using System;
+
+namespace Ryujinx.Graphics.Gpu.Memory
+{
+ ///
+ /// A writable block that targets a given MultiRange within a PhysicalMemory instance.
+ ///
+ internal class MultiRangeWritableBlock : IWritableBlock
+ {
+ private readonly MultiRange _range;
+ private readonly PhysicalMemory _physicalMemory;
+
+ ///
+ /// Creates a new MultiRangeWritableBlock.
+ ///
+ /// The MultiRange to write to
+ /// The PhysicalMemory the given MultiRange addresses
+ public MultiRangeWritableBlock(MultiRange range, PhysicalMemory physicalMemory)
+ {
+ _range = range;
+ _physicalMemory = physicalMemory;
+ }
+
+ ///
+ /// Write data to the MultiRange.
+ ///
+ /// Offset address
+ /// Data to write
+ /// Throw when a non-zero offset is given
+ public void Write(ulong va, ReadOnlySpan data)
+ {
+ if (va != 0)
+ {
+ throw new ArgumentException($"{nameof(va)} cannot be non-zero for {nameof(MultiRangeWritableBlock)}.");
+ }
+
+ _physicalMemory.Write(_range, data);
+ }
+
+ ///
+ /// Write data to the MultiRange, without tracking.
+ ///
+ /// Offset address
+ /// Data to write
+ /// Throw when a non-zero offset is given
+ public void WriteUntracked(ulong va, ReadOnlySpan data)
+ {
+ if (va != 0)
+ {
+ throw new ArgumentException($"{nameof(va)} cannot be non-zero for {nameof(MultiRangeWritableBlock)}.");
+ }
+
+ _physicalMemory.WriteUntracked(_range, data);
+ }
+ }
+}
--
cgit v1.2.3