aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Memory/IWritableBlock.cs
diff options
context:
space:
mode:
authorjhorv <38920027+jhorv@users.noreply.github.com>2024-04-21 06:57:35 -0400
committerGitHub <noreply@github.com>2024-04-21 12:57:35 +0200
commit216026c096d844f8bf09ee0e185dec4111c64095 (patch)
tree222eb5476aacb79f9d67abd799ee1657c2d63e7c /src/Ryujinx.Memory/IWritableBlock.cs
parent7070cf6ae502b5c11551fceb164bc9f158ba980b (diff)
Use pooled memory and avoid memory copies (#6691)
* perf: use ByteMemoryPool * feat: KPageTableBase/KPageTable new methods to read and write `ReadOnlySequence<byte>` * new: add IWritableBlock.Write(ulong, ReadOnlySequence<byte>) with default impl * perf: use GetReadOnlySequence() instead of GetSpan() * perf: make `Parcel` IDisposable, use `ByteMemoryPool` for internal allocation, and make Parcel consumers dispose of it * remove comment about copySize * remove unnecessary Clear()
Diffstat (limited to 'src/Ryujinx.Memory/IWritableBlock.cs')
-rw-r--r--src/Ryujinx.Memory/IWritableBlock.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Ryujinx.Memory/IWritableBlock.cs b/src/Ryujinx.Memory/IWritableBlock.cs
index 0858e0c9..78ae2479 100644
--- a/src/Ryujinx.Memory/IWritableBlock.cs
+++ b/src/Ryujinx.Memory/IWritableBlock.cs
@@ -1,9 +1,25 @@
using System;
+using System.Buffers;
namespace Ryujinx.Memory
{
public interface IWritableBlock
{
+ /// <summary>
+ /// Writes data to CPU mapped memory, with write tracking.
+ /// </summary>
+ /// <param name="va">Virtual address to write the data into</param>
+ /// <param name="data">Data to be written</param>
+ /// <exception cref="InvalidMemoryRegionException">Throw for unhandled invalid or unmapped memory accesses</exception>
+ void Write(ulong va, ReadOnlySequence<byte> data)
+ {
+ foreach (ReadOnlyMemory<byte> segment in data)
+ {
+ Write(va, segment.Span);
+ va += (ulong)segment.Length;
+ }
+ }
+
void Write(ulong va, ReadOnlySpan<byte> data);
void WriteUntracked(ulong va, ReadOnlySpan<byte> data) => Write(va, data);