mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-31 13:57:11 +02:00
Add support to IVirtualMemoryManager for zero-copy reads (#6251)
* - WritableRegion: enable wrapping IMemoryOwner<byte> - IVirtualMemoryManager impls of GetWritableRegion() use pooled memory when region is non-contiguous. - IVirtualMemoryManager: add GetReadOnlySequence() and impls - ByteMemoryPool: add new method RentCopy() - ByteMemoryPool: make class static, remove ctor and singleton field from earlier impl * - BytesReadOnlySequenceSegment: move from Ryujinx.Common.Memory to Ryujinx.Memory - BytesReadOnlySequenceSegment: add IsContiguousWith() and Replace() methods - VirtualMemoryManagerBase: - remove generic type parameters, instead use ulong for virtual addresses and nuint for host/physical addresses - implement IWritableBlock - add virtual GetReadOnlySequence() with coalescing of contiguous segments - add virtual GetSpan() - add virtual GetWritableRegion() - add abstract IsMapped() - add virtual MapForeign(ulong, nuint, ulong) - add virtual Read<T>() - add virtual Read(ulong, Span<byte>) - add virtual ReadTracked<T>() - add virtual SignalMemoryTracking() - add virtual Write() - add virtual Write<T>() - add virtual WriteUntracked() - add virtual WriteWithRedundancyCheck() - VirtualMemoryManagerRefCountedBase: remove generic type parameters - AddressSpaceManager: remove redundant methods, add required overrides - HvMemoryManager: remove redundant methods, add required overrides, add overrides for _invalidAccessHandler handling - MemoryManager: remove redundant methods, add required overrides, add overrides for _invalidAccessHandler handling - MemoryManagerHostMapped: remove redundant methods, add required overrides, add overrides for _invalidAccessHandler handling - NativeMemoryManager: add get properties for Pointer and Length - throughout: removed invalid <inheritdoc/> comments * make HvMemoryManager class sealed * remove unused method * adjust MemoryManagerHostTracked * let MemoryManagerHostTracked override WriteImpl()
This commit is contained in:
parent
8e74fa3456
commit
5def0429f8
14 changed files with 635 additions and 819 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Memory
|
||||
{
|
||||
|
@ -6,6 +7,7 @@ namespace Ryujinx.Memory
|
|||
{
|
||||
private readonly IWritableBlock _block;
|
||||
private readonly ulong _va;
|
||||
private readonly IMemoryOwner<byte> _memoryOwner;
|
||||
private readonly bool _tracked;
|
||||
|
||||
private bool NeedsWriteback => _block != null;
|
||||
|
@ -20,6 +22,12 @@ namespace Ryujinx.Memory
|
|||
Memory = memory;
|
||||
}
|
||||
|
||||
public WritableRegion(IWritableBlock block, ulong va, IMemoryOwner<byte> memoryOwner, bool tracked = false)
|
||||
: this(block, va, memoryOwner.Memory, tracked)
|
||||
{
|
||||
_memoryOwner = memoryOwner;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (NeedsWriteback)
|
||||
|
@ -33,6 +41,8 @@ namespace Ryujinx.Memory
|
|||
_block.WriteUntracked(_va, Memory.Span);
|
||||
}
|
||||
}
|
||||
|
||||
_memoryOwner?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue