mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-27 07:37:00 +00:00
gpu allocation optimizations (ryubing/ryujinx!195)
See merge request ryubing/ryujinx!195
This commit is contained in:
parent
718652599d
commit
c94ffaa00a
20 changed files with 297 additions and 234 deletions
|
|
@ -60,6 +60,15 @@ namespace Ryujinx.Memory
|
|||
/// <param name="data">Span to store the data being read into</param>
|
||||
/// <exception cref="InvalidMemoryRegionException">Throw for unhandled invalid or unmapped memory accesses</exception>
|
||||
void Read(ulong va, Span<byte> data);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a span of CPU mapped memory.
|
||||
/// </summary>
|
||||
/// <param name="va">Virtual address of the data in memory</param>
|
||||
/// <param name="length">Length of the data in memory</param>
|
||||
/// <param name="data">Span that references the data being read</param>
|
||||
/// <exception cref="InvalidMemoryRegionException">Throw for unhandled invalid or unmapped memory accesses</exception>
|
||||
bool TryReadUnsafe(ulong va, int length, out Span<byte> data);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to CPU mapped memory.
|
||||
|
|
|
|||
|
|
@ -159,6 +159,13 @@ namespace Ryujinx.Memory
|
|||
|
||||
AssertValidAddressAndSize(va, data.Length);
|
||||
|
||||
if (IsContiguousAndMapped(va, data.Length))
|
||||
{
|
||||
nuint pa = TranslateVirtualAddressChecked(va);
|
||||
|
||||
GetPhysicalAddressSpan(pa, data.Length).CopyTo(data);
|
||||
}
|
||||
|
||||
int offset = 0, size;
|
||||
|
||||
if ((va & PageMask) != 0)
|
||||
|
|
@ -182,6 +189,28 @@ namespace Ryujinx.Memory
|
|||
}
|
||||
}
|
||||
|
||||
public virtual bool TryReadUnsafe(ulong va, int length, out Span<byte> data)
|
||||
{
|
||||
if (!IsContiguousAndMapped(va, length))
|
||||
{
|
||||
data = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
data = Span<byte>.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
AssertValidAddressAndSize(va, length);
|
||||
|
||||
nuint pa = TranslateVirtualAddressChecked(va);
|
||||
|
||||
data = GetPhysicalAddressSpan(pa, length);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual T ReadTracked<T>(ulong va) where T : unmanaged
|
||||
{
|
||||
SignalMemoryTracking(va, (ulong)Unsafe.SizeOf<T>(), false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue