mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-02 03:38:50 +02:00
gpu allocation optimizations
ObjectPool now uses ConcurrentBag instead if ConcurrentStack, as it has a smaller memory footprint. Fix compiler warnings related to Audio Command Pools. Switch gpu command initialization to use pointers, that way skipping the allocation of the command which is unnecessary. Skip byte array allocation in Ioctl2/3 if it isn't needed (if the source data is all continuous we don't need to copy it to make it continuous).
This commit is contained in:
@@ -61,6 +61,15 @@ namespace Ryujinx.Memory
|
||||
/// <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.
|
||||
/// </summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user